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

Discussion

Patterns for tokens are most naturally described by

  • A.regular expressions
  • B.context free grammars written in Backus Naur form
  • C.attribute grammars carrying semantic rules on each production
  • D.the quadruples that the middle of the compiler has already produced

Answer: A

Correct answer: regular expressions

Token patterns are exactly the kind of thing regular expressions describe: identifiers, numbers, operators and keywords are all regular languages, and a regular expression can be turned mechanically into the automaton that recognises it. Context free grammars are needed for the nested structure the parser handles, and are more machinery than the scanner requires.

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

Post your comment

Please log in or register to post a comment.