A scanner generator such as Lex takes as input
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.
Please log in or register to report this question.