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

Discussion

White space and comments are usually handled by the scanner by

  • A.recognising and discarding them without producing any token
  • B.passing them to the parser as tokens to be ignored later
  • C.storing them in the symbol table for the code generator
  • D.reporting them as errors if they appear between two tokens

Answer: A

Discarding them in the scanner keeps the grammar free of any mention of layout. The scanner still counts newlines so that later diagnostics can name the correct source line. Comments are therefore invisible to the grammar while remaining visible to the reader.

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

Post your comment

Please log in or register to post a comment.