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

Discussion

Optional constructs in a grammar are handled in recursive descent by

  • A.always attempting the option and backtracking if it fails
  • B.obliging the programmer to spell the construct out in full
  • C.putting the decision off until the meaning of the program is examined
  • D.testing whether the lookahead is in the FIRST set of the option

Answer: D

A simple conditional on the lookahead decides whether to parse the optional part. This is the direct code equivalent of an epsilon production in the grammar. Optional constructs are therefore among the easiest cases to write by hand.

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

Post your comment

Please log in or register to post a comment.