Which of the following features cannot be captured by context-free grammars?
Syntax of if-then-else statements
Syntax of recursive procedures
Whether a variable has been declared before its use
Variable names of arbitrary length
It will be C.
Since CFG's are used to show syntactic rules while designing compiler, and syntactic rules don't check for meaningful things such as if a variable has been declared before its use or not. Such things are meant to be handled by Semantic Analysis phase (requires power of a context sensitive grammar).
For D, a regular expression does not restrict the string length. Languages have restriction for variable name length for storing purpose like in symbol table.
For A, if then else is inherently ambiguous. But CFG can represent inherently ambiguous languages just that there are more than one parse trees possible for some strings.
C is CSL or CFL ?
(For those who are wondering like me.)
Answer is here: https://gateoverflow.in/45246/is-c-language-cfl-or-strict-csl
c will be answer bcz the limitation of syntax analyzer are
i think ww can be use for c where w is (a+b)*
"A disadvantage is, it makes you...