Recall & Review
beginner
What is the primary purpose of the Lex/Flex tool?
Lex/Flex is used to generate lexical analyzers, which break input text into meaningful tokens for further processing in compilers.
Click to reveal answer
beginner
How does Lex/Flex define patterns to recognize tokens?
Lex/Flex uses regular expressions to specify patterns that match sequences of characters representing tokens.
Click to reveal answer
beginner
What is the output of running Lex/Flex on a specification file?
It produces C source code for a lexical analyzer that can be compiled and used to scan input text.
Click to reveal answer
intermediate
Explain the role of actions in Lex/Flex specifications.
Actions are code snippets executed when a pattern matches; they typically return tokens or perform processing.
Click to reveal answer
intermediate
What is the difference between Lex and Flex?
Flex is a modern, faster, and open-source alternative to the original Lex tool, with compatible syntax and features.
Click to reveal answer
What kind of patterns does Lex/Flex use to identify tokens?
✗ Incorrect
Lex/Flex uses regular expressions to define patterns for tokens.
What language is the output code from Lex/Flex written in?
✗ Incorrect
Lex/Flex generates C source code for the lexical analyzer.
Which of the following best describes an action in Lex/Flex?
✗ Incorrect
Actions are code snippets run when a pattern matches input.
Flex is considered:
✗ Incorrect
Flex is a modern, open-source alternative to Lex.
What is the main role of a lexical analyzer generated by Lex/Flex?
✗ Incorrect
The lexical analyzer breaks input text into tokens for the compiler.
Describe how Lex/Flex uses regular expressions and actions to create a lexical analyzer.
Think about how patterns and code snippets work together in Lex/Flex.
You got /3 concepts.
Explain the difference between Lex and Flex and why Flex is commonly used today.
Consider tool history and features.
You got /3 concepts.