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

Discussion

Recognising the end of the input is signalled to the parser by

  • A.a distinguished end of file token returned by the scanner
  • B.the scanner returning no value at all from its next call
  • C.the parser detecting that no production can be applied
  • D.an exception raised by the input buffering routines

Answer: A

Correct answer: a distinguished end of file token returned by the scanner

The parser needs to know that the input has ended in the same form as everything else it consumes, so the scanner returns a special end of file token, conventionally written as a dollar sign in grammars. The grammar then has a production that accepts the start symbol followed by that token, which is how it recognises a complete program.

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

Post your comment

Please log in or register to post a comment.