Lexical Analysis


Question 1
In a two-pass assembler, resolution of subroutine calls and inclusion of labels in the symbol table is done during
A
Second pass
B
first pass and second pass respectively
C
second pass and first pass respectively
D
first pass
ISRO CSE 2020   Compiler Design
Question 2
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
ISRO CSE 2020   Compiler Design


Question 3
Consider the following statements.

I. Symbol table is accessed only during lexical analysis and syntax analysis.
II. Compilers for programming languages that support recursion necessarily need heap storage for memory allocation in the run-time environment.
III. Errors violating the condition 'any variable must be declared before its use' are detected during syntax analysis.

Which of the above statements is/are TRUE?
A
I only
B
I and III only
C
II only
D
None of I, II and III
GATE CSE 2020   Compiler Design
Question 4
A particular BNF definition for a "word is given by the following rules.
< word > :: =< letter > I < letter > < charpair > I < letter >< intpair >
< charpair > :: =< letter >< letter > I < charpair >< letter >< letter >
< intpair > :: = < integer >< integer > I < intpair >< integer >< integer >
< letter > :: = a I b I c I ......I Y I Z
< integer > :: = 0 I 1 I 2 I ......I 9
Which of the following lexical entries can be derived from < word >?
I. pick
II. picks
III. c44
A
I, II and III
B
I and II only
C
I and III only
D
II and III only
ISRO CSE 2018   Compiler Design
Question 5
A lexical analyzer uses the following patterns to recognize three tokens T_{1}, T_{2}, \; and \; T_{3} over the alphabet {a,b,c}.

T_{1}:a?(b|c)^* a
T_{2}:b?(a|c)^* b
T_{3}:c?(b|a)^* c

Note that 'x?' means 0 or 1 occurrence of the symbol x. Note also that the analyzer outputs the token that matches the longest possible prefix.

If the string bbaacabc is processed by the analyzer, which one of the following is the sequence of tokens it outputs?
A
T_{1}T_{2}T_{3}
B
T_{1}T_{1}T_{3}
C
T_{2}T_{1}T_{3}
D
T_{3}T_{3}
GATE CSE 2018   Compiler Design


There are 5 questions to complete.

6 thoughts on “Lexical Analysis”

  1. everything is fantastic but facebook,whatsapp,telegram,and linkedin icon are in wrong position kindly change it’s position

    Reply

Leave a Comment