Machine-translated by Google. Questions are authored in English.
Top

Discussion

Programming language syntax needs a context free grammar rather than a regular expression because

  • A.the scanner has already consumed all the regular structure
  • B.nested constructs require unbounded matching that regular sets lack
  • C.regular expressions cannot describe more than one token at a time
  • D.context free grammars are more efficient to process than automata

Answer: B

Balanced parentheses and nested blocks demand counting to an unbounded depth. A finite automaton has no such memory, whereas the stack of a pushdown automaton supplies exactly that. This is the single clearest reason the two phases use different formalisms.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.