Lexical Analysis

Download Q&A
Q. In lexical analysis, what is a 'token'?
  • A. A sequence of characters in the source code
  • B. A data structure representing a keyword or identifier
  • C. A type of error in the source code
  • D. A part of the syntax tree
Q. What is a 'lexeme' in the context of lexical analysis?
  • A. The smallest unit of meaning in a programming language
  • B. The actual sequence of characters that matches a token
  • C. A type of syntax error
  • D. A representation of a variable in the symbol table
Q. What is a 'lexeme'?
  • A. The smallest unit of a program
  • B. A sequence of characters that matches a token
  • C. A type of syntax error
  • D. A part of the symbol table
Q. What is the output of a lexical analyzer typically used for?
  • A. To generate machine code
  • B. To create a syntax tree
  • C. To feed into the parser
  • D. To optimize the code
Q. What is the output of a lexical analyzer when it encounters an unrecognized character?
  • A. A token
  • B. A syntax tree
  • C. An error message
  • D. A symbol table entry
Q. What is the purpose of a finite automaton in lexical analysis?
  • A. To parse the syntax of the code
  • B. To recognize patterns in the input stream
  • C. To generate machine code
  • D. To optimize the code
Q. What is the purpose of a symbol table in the context of lexical analysis?
  • A. To store the tokens generated
  • B. To keep track of variable names and their attributes
  • C. To optimize the code
  • D. To parse the syntax tree
Q. What is the role of regular expressions in lexical analysis?
  • A. To define the grammar of the programming language
  • B. To specify the syntax of the tokens
  • C. To generate intermediate code
  • D. To optimize the parsing process
Q. Which of the following best describes 'tokenization'?
  • A. The process of generating machine code
  • B. The process of converting source code into tokens
  • C. The process of optimizing code
  • D. The process of parsing syntax
Q. Which of the following best describes the relationship between a lexer and a parser?
  • A. The lexer generates machine code, while the parser checks syntax
  • B. The lexer produces tokens, which the parser uses to build a syntax tree
  • C. The lexer and parser perform the same function
  • D. The parser generates tokens, while the lexer checks syntax
Q. Which of the following is a common error detected by a lexical analyzer?
  • A. Syntax errors
  • B. Type errors
  • C. Unrecognized characters
  • D. Semantic errors
Q. Which of the following is a common technique used in lexical analysis?
  • A. Recursive descent parsing
  • B. Finite state machines
  • C. Dynamic programming
  • D. Backtracking
Q. Which of the following is NOT a typical output of a lexical analyzer?
  • A. Tokens
  • B. Symbol table
  • C. Abstract syntax tree
  • D. Error messages
Q. Which of the following tools is commonly used to implement a lexical analyzer?
  • A. Yacc
  • B. Lex
  • C. Bison
  • D. ANTLR
Showing 1 to 14 of 14 (1 Pages)
Soulshift Feedback ×

On a scale of 0–10, how likely are you to recommend The Soulshift Academy?

Not likely Very likely