Lexical Analysis MCQs December 19, 2025December 13, 2024 by u930973931_answers 10 min Score: 0 Attempted: 0/10 Subscribe 1. What is the main function of the lexical analyzer? (A) Check the syntax of the program (B) Break the input source code into tokens (C) Convert high-level code into machine code (D) Optimize the code 2. Which of the following represents a sequence of characters that matches a specific pattern? (A) Lexeme (B) Token (C) Grammar (D) Syntax 3. Which of the following is true about tokens? (A) Tokens are keywords only. (B) Tokens are the smallest units of code with a defined meaning. (C) Tokens are instructions that the computer executes. (D) Tokens are only used in the code generation phase. 4. Which of the following tools is commonly used for lexical analysis? (A) YACC (B) Bison (C) GCC (D) Lex 5. Which of the following is NOT typically a part of the lexical analysis phase? (A) Identifying keywords (B) Identifying identifiers and operators (C) Assigning memory addresses to variables (D) Converting the input into tokens 6. What is the role of regular expressions in lexical analysis? (A) They specify the patterns to identify tokens (B) They define the syntax of the programming language (C) They convert source code into machine code (D) They are used for semantic checking 7. What type of automaton is commonly used to perform lexical analysis? (A) Pushdown Automata (B) Turing Machine (C) Finite Automata (D) Linear Bounded Automata 8. Which of the following is a common output of lexical analysis? (A) An Abstract Syntax Tree (B) Optimized machine code (C) A list of tokens (D) A syntax tree 9. Which of the following is a characteristic of a lexical error? (A) It occurs when a token is identified but not found in the lexicon. (B) It occurs during the syntax analysis phase. (C) It refers to incorrect grammar in the source code. (D) It occurs during code generation. 10. What is the purpose of finite automata in lexical analysis? (A) To match strings of characters with regular expressions and identify tokens (B) To check the validity of the programās semantic rules (C) To define the syntax of the language (D) To generate intermediate code from source code