WorksheetsGATE Questions on Lexical Analysis
Total questions: 10
Worksheet time: 5mins
Name
Class
Date
1.
1. The number of tokens in the given C statement is (a) . printf("pt = %d, &pt = %x", pt, &pt);
2.
2. In any compiler, we can recognize keywords of a language during ____.
a)
Parsing of the program
b)
The code generation
c)
Lexical analysis of the program
d)
Dataflow analysis
3.
3. The lexical Analysis for any modern programming language such as Java needs the power of which one of the below machine models in a sufficient and necessary sense?
a)
Finite state Automata
b)
Non-deterministic automata
c)
Deterministic pushdown automata
d)
Turing Machine
4.
4.The output of any lexical analyzer is?
a)
A Parse Tree
b)
Machine Code
c)
Intermediate Code
d)
A Stream of Tokens
5.
5. Consider the given statements related to the compiler construction:
(1.) Lexical Analysis is specified by context-free grammar and implemented with pushdown automata.
(2.) Syntax Analysis is defined by regular expressions and implemented with a finite-state machine.
Which of the above statement(s) is/are correct?
a)
Only (1)
b)
Only (2)
c)
Both (1) and (2)
d)
Neither (1) nor (2)
6.
6.Which data structure in a compiler is used for managing information about variables and their attributes?
a)
Abstract Syntax Tree
b)
Symbol Table
c)
Semantic Stack
d)
Parse Table
7.
7.Which of the following strings can definitely be said to be tokens without looking at the next input character while compiling a Pascal program?
I. begin II. program III. <>
a)
I
b)
II
c)
III
d)
All of the above
8.
8. 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 Anlayser
d)
The Syntax Analyser
9.
9. The number of tokens in the Fortran statement DO 10 I = 1.25 is
a)
3
b)
4
c)
5
d)
None of the above
10.
10. The number of tokens in the following C code segment is
switch(inputvalue)
{ case 1 : b =c*d; break;
default : b =b++; break;
}
a)
27
b)
29
c)
26
d)
24
100 %
