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

Discussion

If the scanner and the parser disagree about the set of token names

  • A.the parser will silently correct the discrepancy at runtime
  • B.the discrepancy is harmless because names are only documentation
  • C.the scanner generator will automatically reconcile the two sets
  • D.the compiler will not build, or will misinterpret the token stream

Answer: D

Correct answer: the compiler will not build, or will misinterpret the token stream

The token names are a contract between the two phases, usually held in a shared header that the parser generator produces and the scanner includes. If they disagree the build fails, or worse the numeric codes silently mismatch and the parser interprets one token as another. This is why the header is generated rather than written twice by hand.

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

Post your comment

Please log in or register to post a comment.