Compilers Multiple Choice Questions on “Lexical Analyser”.
1. In a compiler the module that checks every character of the source text is called __________
a) The code generator
b) The code optimizer
c) The lexical analyzer
d) The syntax analyzer
Answer: a
Clarification: Lexical analysis is the process of converting a sequence of characters into a sequence of tokens.
2. The context free grammar is ambiguous if ______________
a) The grammar contains non-terminals
b) Produces more than one parse tree
c) Production has two non-terminals side by side
d) None of the mentioned
Answer: b
Clarification: Since more than one parse tree is generated hence one than option is available .Therefore it’s ambiguous.
3. What is another name for Lexical Analyser?
a) Linear Phase
b) Linear Analysis
c) Scanning
d) All of the mentioned
Answer: d
Clarification: Lexical Analyzer is also called “Linear Phase” or “Linear Analysis” or “Scanning“.
4. An individual token is called ________
a) Lexeme
b) Lex
c) Lexeme & Lex
d) None of the mentioned
Answer: a
Clarification: Individual Token is also Called Lexeme.
5. Lexical Analyser’s Output is given to Syntax Analysis.
a) True
b) False
Answer: a
Clarification: Lexical Analyzer’s Output is given to Syntax Analysis.
6. Which phase of the compiler is Lexical Analyser?
a) First
b) Second
c) Third
d) None of the mentioned
Answer: a
Clarification: Lexical Analyzer is First Phase of Compiler.
7. Input to Lexical Analyser is _________
a) Source Code
b) Object Code
c) Lexeme
d) None of the mentioned
Answer: a
Clarification: Lexical analyser’s Input is Source Code.
8. Lexical Analysis Identifies Different Lexical Units in a _______
a) Source Code
b) Object Code
c) Lexeme
d) None of the mentioned
Answer: a
Clarification: Lexical Analysis Identifies Different Lexical Units in a source Code.
9. Which one is a type of Lexeme?
a) Identifiers
b) Constants
c) Keywords
d) All of the mentioned
Answer: d
Clarification: All of them along with Operators are different types of lexemes.
10. A ________ is a string of characters which form a syntactic unit.
a) Lexeme
b) Lex
c) Lexeme & Lex
d) None of the mentioned
Answer: a
Clarification: A lexeme is a string of characters that form a syntactic unit.