Compiler Construction MCQs with Answers
Practice important Compiler Construction MCQs with answers and explanations.
Multiple Choice Questions
Q281: In lexical analyzers, what happens when two patterns match with same prefix?
- A: Shorter match is selected
- B: Longest match is selected
- C: Alphabetical token is selected
- D: Error is returned
View Answer
B
Q282: Flex is a tool that generates
- A: Assembler
- B: Code optimizer
- C: Lexical analyzer
- D: Parser
View Answer
C
Q283: Which language does Flex generate the lexical analyzer in?
- A: Python
- B: C or C++
- C: Java
- D: Rust
View Answer
B
Q284: Jlex is implemented in _______.
- A: C++
- B: Python
- C: Java
- D: Assembly
View Answer
C
Q285: The file extension for Flex specification files is
- A: .cpp
- B: .lex
- C: .l
- D: .yy
View Answer
C
Q286: The three sections in a Flex input file are separated by
- A: ;;
- B: ::
- C: %%
- D: #
View Answer
C
Q287: In Flex, what section contains token definitions and actions?
- A: First
- B: Second
- C: Third
- D: Header
View Answer
B
Q288: Which keyword is returned by Flex as TOK_IF?
- A: int
- B: if
- C: else
- D: while
View Answer
B
Q289: The regular expression [0-9] matches
- A: Letters
- B: Digits
- C: Spaces
- D: Alphabets
View Answer
B
Q290: The pattern [a-zA-Z_] represents
- A: Uppercase only
- B: Lowercase only
- C: Letters and underscore
- D: Digits
View Answer
C