This set of Compilers Multiple Choice Questions & Answers (MCQs) focuses on “Lexical Analyser – 2”.
1. The process of forming tokens from an input stream of characters is called __________
a) Liberalisation
b) Characterisation
c) Tokenization
d) None of the mentioned
View Answer
Explanation: The process of forming tokens from an input stream of characters is called tokenization.
2. When expression sum=3+2 is tokenized then what is the token category of 3?
a) Identifier
b) Assignment operator
c) Integer Literal
d) Addition Operator
View Answer
Explanation:
Lexeme
Token category
Sum "Identifier" = "Assignment operator" 3 "Integer literal" + "Addition operator" 2 "Integer literal" ; "End of statement".
3. Which grammar defines Lexical Syntax?
a) Regular Grammar
b) Syntactic Grammar
c) Context free Grammar
d) Lexical Grammar
View Answer
Explanation: The specification of a programming language often includes a set of rules, the lexical grammar, which defines the lexical syntax.
4. Two Important lexical categories are __________
a) White Space
b) Comments
c) None of the mentioned
d) White Space & Comments
View Answer
Explanation: Two important common lexical categories are white space and comments.
5. It has encoded within it information on the possible sequences of characters that can be contained within any of the tokens it handles. The mentioned function is performed by?
a) Scanner
b) Parser
c) Syntactic Analyser
d) All of the mentioned
View Answer
Explanation: The first stage, the scanner, is FSM. It has encoded information on the possible sequences of characters that can be contained within any of the tokens it handles.
6. What goes over the characters of the lexeme to produce value?
a) Scanner
b) Parser
c) Evaluator
d) Lexical generator
View Answer
Explanation: In order to construct a token, the lexical analyzer needs a second stage, the evaluator, which goes over the characters of the lexeme to produce a value.
7. Lexers are often generated by a lexer generator, same as parser generators.
a) True
b) False
View Answer
Explanation: Lexers are often generated by a lexer generator same as parser.
8. Which one is a lexer Generator?
a) ANTLR
b) DRASTAR
c) FLEX
d) All of the mentioned
View Answer
Explanation: ANTLR – Can generate lexical analyzers and parsers.
DFASTAR – Generates DFA matrix table-driven lexers in C++.
Flex – variant of the “lex” (C/C++).
Ragel – A state machine and lexer generator with output in C, C++, C#, Objective-C, D, Java, Go and Ruby.
9. Which of the lexical analyser can handle Unicode?
a) Java CC
b) JFLex
c) Quex
d) All of the mentioned
View Answer
Explanation: JavaCC – JavaCC generates lexical analyzers written in Java.
JFLex – A lexical analyzer generator for Java.
Quex – A fast universal lexical analyzer generator for C and C++.
FsLex – A lexer generator for byte and Unicode character input for F#.
10. What is the output of a lexical analyzer?
a) Machine Code
b) Intermediate Code
c) Stream of Token
d) Parse Tree
View Answer
Explanation: The output given is in the form of tokens.
Sanfoundry Global Education & Learning Series – Compilers.
To practice all areas of Compilers, here is complete set of 1000+ Multiple Choice Questions and Answers.
- Practice Computer Science MCQs
- Practice MCA MCQs
- Check Compiler Design Books
- Apply for Computer Science Internship
- Check Computer Science Books