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

Discussion

A scanner generator such as Lex takes as input

  • A.the intermediate code and produces optimised intermediate code
  • B.a symbol table specification and produces its implementation
  • C.regular expressions describing the tokens and produces a scanner
  • D.a context free grammar and produces a parser for that grammar

Answer: C

Correct answer: regular expressions describing the tokens and produces a scanner

Lex and its successors take a specification pairing regular expressions with actions and generate a scanner - typically as a finite automaton driven by a table.

Regular expressions suffice because token structure is regular: identifiers, numbers and operators can all be described without recursion. Nested structures such as balanced parentheses cannot, which is why the parser needs a context-free grammar and a different generator, and why the two tools are separate.

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

Post your comment

Please log in or register to post a comment.