Engineering Questions with Answers - Multiple Choice Questions

MCQs on Lexical Analyser – 2

1 - Question

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

Answer: c
Explanation: The process of forming tokens from an input stream of characters is called tokenization.




2 - Question

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

Answer: c
Explanation:
Lexeme
Token category

 

Sum	"Identifier"
=	"Assignment operator"
3	"Integer literal"
+	"Addition operator"
2	"Integer literal"
;	"End of statement".



3 - Question

Which grammar defines Lexical Syntax?
a) Regular Grammar
b) Syntactic Grammar
c) Context free Grammar
d) Lexical Grammar

View Answer

Answer: d
Explanation: The specification of a programming language often includes a set of rules, the lexical grammar, which defines the lexical syntax.




4 - Question

Two Important lexical categories are __________
a) White Space
b) Comments
c) None of the mentioned
d) White Space & Comments

View Answer

Answer: d
Explanation: Two important common lexical categories are white space and comments.




5 - Question

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

Answer: a
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 - Question

What goes over the characters of the lexeme to produce value?
a) Scanner
b) Parser
c) Evaluator
d) Lexical generator

View Answer

Answer: a
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 - Question

Lexers are often generated by a lexer generator, same as parser generators.
a) True
b) False

View Answer

Answer: a
Explanation: Lexers are often generated by a lexer generator same as parser.




8 - Question

Which one is a lexer Generator?
a) ANTLR
b) DRASTAR
c) FLEX
d) All of the mentioned

View Answer

Answer: d
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 - Question

Which of the lexical analyser can handle Unicode?
a) Java CC
b) JFLex
c) Quex
d) All of the mentioned

View Answer

Answer: d
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 - Question

What is the output of a lexical analyzer?
a) Machine Code
b) Intermediate Code
c) Stream of Token
d) Parse Tree

View Answer

Answer: c
Explanation: The output given is in the form of tokens.

Get weekly updates about new MCQs and other posts by joining 18000+ community of active learners