Tools for Lexical Analysis (e.g., Lex) MCQs January 8, 2026December 13, 2024 by u930973931_answers 10 min Score: 0 Attempted: 0/10 Subscribe 1. Which of the following tools is used for lexical analysis in compiler design? (A) Lex (B) YACC (C) Bison (D) GCC 2. What is the main purpose of the Lex tool in lexical analysis? (A) To parse source code (B) To optimize the generated code (C) To generate a lexical analyzer from a regular expression (D) To translate high-level language to machine code 3. Which of the following is a feature of the Lex tool? (A) It converts a context-free grammar into machine code (B) It generates a lexer based on specified regular expressions (C) It generates machine-level code from source code (D) It parses the source code and detects syntax errors 4. Which programming language is commonly used to implement a lexical analyzer generated by Lex? (A) C (B) Python (C) Java (D) Assembly 5. What is the role of a lexical analyzer generated by Lex? (A) To analyze the syntax of the program (B) To identify tokens in the source code (C) To optimize the code (D) To perform semantic analysis 6. Which of the following is an advantage of using Lex for lexical analysis? (A) It automatically handles syntax errors (B) It generates code that can run on all platforms (C) It can handle recursive parsing (D) It generates efficient code for lexical analysis 7. Which of the following is commonly used in conjunction with Lex for syntax analysis? (A) Java (B) GCC (C) YACC (D) Lexical Analyzer 8. What type of input does Lex require to generate a lexical analyzer? (A) A set of regular expressions (B) A context-free grammar (C) A set of tokens (D) A set of machine instructions 9. What does Lex output after processing the specified regular expressions? (A) A lexical analyzer (lexer) (B) A parsing table (C) A machine code file (D) A syntax tree 10. Which of the following best describes Lex’s functionality in the context of a compiler? (A) It is used for generating the symbol table (B) It is responsible for optimizing the source code (C) It handles semantic errors during the compilation process (D) It is used for performing lexical analysis, identifying tokens from the input stream