Skip to content
Official PYQ · 1987

GATE CS 1987 Q1-xiii — Regular and Context-free Languages

Explain with AI

FORTRAN is a:

Choose one option
View worked solution

Answer: C

Most real-world programming languages, including FORTRAN, are not context-free. They fall under the class of Context-Sensitive Languages (CSL) due to several semantic and syntactic features that cannot be verified by a pushdown automaton (PDA):

  • Declare-before-use: A variable must be declared before it is used. This requires matching the identifier at its declaration with its subsequent usages, which is structurally equivalent to the language L={wcw∣w∈{a,b}∗}L = \{w c w \mid w \in \{a,b\}^*\}. This language is context-sensitive but not context-free.
  • Type Checking and Parameter Matching: Verifying that the number and types of arguments in a function call match its definition also requires context-sensitive analysis.

While the phrase-structure (syntax) of programming languages is often approximated using Context-Free Grammars (CFGs) for parsing convenience, the complete language (including static semantics) is Context-Sensitive.

Hence, the correct option is C.

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Regular and Context-free Languages questions