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

Discussion

A scanner that returned all tokens as a list before parsing began would

  • A.use more memory but is otherwise a perfectly workable design
  • B.be unable to recognise the tokens of most programming languages
  • C.make the longest match rule impossible to implement correctly
  • D.prevent the parser from reporting any syntax errors at all

Answer: A

Precomputing the token list is a legitimate design and is used where the stream must be examined more than once. The only real cost is holding the whole list rather than one token at a time. Tools that examine a program more than once often prefer exactly this arrangement.

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

Post your comment

Please log in or register to post a comment.