Role of the Lexical Analyzer MCQs December 19, 2025December 13, 2024 by u930973931_answers 10 min Score: 0 Attempted: 0/10 Subscribe 1. What is the primary function of the lexical analyzer in the compilation process? (A) Divide the source code into meaningful tokens (B) Translate the source code into intermediate code (C) Convert high-level code to machine code (D) Perform error checking and recovery 2. Which of the following tasks is NOT performed by the lexical analyzer? (A) Identifying keywords and operators (B) Removing whitespace and comments (C) Identifying identifiers and constants (D) Generating intermediate code 3. What does the lexical analyzer use to match input patterns and generate tokens? (A) Pushdown automata (B) Context-free grammar (C) Finite automata (D) Turing machines 4. How does the lexical analyzer handle whitespace and comments in the source code? (A) It removes them to simplify the analysis process (B) It treats them as tokens for error detection (C) It includes them as part of the token list (D) It translates them into machine code 5. Which of the following is an output of the lexical analysis phase? (A) A parse tree (B) A list of tokens (C) Intermediate code (D) An abstract syntax tree 6. What is the role of regular expressions in the lexical analysis process? (A) Specify patterns for token recognition (B) Define the syntax of the source code (C) Perform error checking during compilation (D) Optimize the code for execution 7. What happens when the lexical analyzer encounters an invalid token? (A) It reports a lexical error to the syntax analyzer (B) It ignores the token and continues analyzing the code (C) It tries to repair the token by modifying it (D) It generates an error and stops the compilation process 8. In which phase of compilation does the lexical analyzer operate? (A) Code generation (B) Lexical analysis (C) Semantic analysis (D) Syntax analysis 9. Which of the following does the lexical analyzer NOT do? (A) Recognize tokens such as keywords and identifiers (B) Perform syntax checking (C) Remove unnecessary whitespace and comments (D) Pass tokens to the syntax analyzer 10. What is the role of the symbol table in lexical analysis? (A) It stores identifiers and their attributes (B) It stores the generated machine code (C) It is used for semantic checking (D) It stores intermediate representations of the code