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

Discussion

A language is straightforward to parse when it offers

  • A.the requirement that all variables be of the same single type
  • B.a grammar that is unambiguous and within a well known class
  • C.a small number of reserved keywords in the whole language
  • D.the absence of any comments in the source program text

Answer: B

Correct answer: a grammar that is unambiguous and within a well known class

An unambiguous grammar gives each valid program exactly one parse tree, so there is no choice for the parser to resolve. Belonging to a class such as LL(1) or LALR(1) means an efficient deterministic parser can be generated automatically.

Neither the number of keywords nor the presence of comments affects this, both being matters for the scanner, and a single type would simplify semantic analysis rather than parsing. The grammar's properties are what decide parsing difficulty.

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

Post your comment

Please log in or register to post a comment.