GATE || Compiler Design || Lexical analysis || Pyq (2010 to 2025 )

Last Updated :
Discuss
Comments

Question 1

A lexical analyzer uses the following patterns to recognize three tokens T1, T2, and T3 over the alphabet {a,b,c}.

T1 : a?(b|c)*a

T2 : b?(a|c)*b

T3 : 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 processes by the analyzer, which one of the following is the sequence of tokens it outputs?

[GATE 2018 || MCQ|| 2-mark]

  • T1T2T3

  • T1T1T3

  • T2T1T3

  • T3T3

Question 2

Match the following according to input (from the left column) to the compiler phase (in the right column) that processes it:

(P) Syntax tree

(i) Code generator

(Q) Character stream

(ii) Syntax analyzer

(R) Intermediate
      representation

(iii) Semantic analyzer

(S) Token stream

(iv) Lexical analyzer

[GATE 2017|| SET - 2 MCQ|| 2-mark]

  • P-ii, Q-iii, R-iv, S-i

  • P-ii, Q-i, R-iii, S-iv

  • P-iii, Q-iv, R-i, S-ii

  • P-i, Q-iv, R-ii, S-iii

Question 3

Match the following

List-1

P. Lexical analysis

Q. Top-down parsing

R. Semantic analysis

S. Runtime environments

List-2

(i) Leftmost derivation

(ii) Type checking

(iii) Regular expressions

(iv) Activation records 

[GATE 2016 || SET -2 MCQ|| 1-mark]



  • P-i, Q-ii, R-iv, S-iii

  • P-iii, Q-i, R-ii, S-iv

  • P-ii, Q-iii, R-i, S-iv

  • P-iv, Q-i, R-ii, S-iii

Question 4

Match the following:

Screenshot-2025-10-15-124200
.

[GATE 2015||SET-2 MCQ|| 1-mark]


  • P-2, Q-3, R-1, S-4

  • P-2, Q-1, R-4, S-3

  • P-2, Q-4, R-1, S-3

  • P-2, Q-3, R-4, S-1

Question 5

In a compiler, keywords of a language are recognized during:-

[GATE 2011 || MCQ|| 1-mark]


  • parsing of the program

  • the code generation

  • the lexical analysis of the program

  • dataflow analysis

Question 6

The lexical analysis for a modern computer language such as Java needs the power of which one of the following machine models in a necessary and sufficient sense?

[GATE 2011 || MCQ|| 1-mark]


  • Finite state automata

  • Deterministic pushdown automata

  • Non-Deterministic pushdown automata

  • Turing machine

Question 7

Which data structure in a compiler is used for managing information about variables and their attributes? [GATE 2010 || MCQ|| 1-mark]


  • Abstract syntax tree

  • Symbol table

  • Semantic stack

  • Parse Table

Question 8

Which ONE of the following statements is FALSE regarding the symbol table?

[GATE 2025|| SET-1 MCQ || 1-mark]

  • Symbol table is responsible for keeping track of the scope of variables.

  • Symbol table can be implemented using a binary search tree.

  • Symbol table is not required after the parsing phase.

  • Symbol table is created during the lexical analysis phase.

Question 9

Consider the following two sets:

Screenshot-2025-10-13-173610

Which one of the following options is the CORRECT match from Set X to Set Y? [GATE 2024|| SET-2 MCQ|| 1-mark]

  • P-4; Q-1; R-3; S-2

  • P-2; Q-3; R-1; S-4

  • P-2; Q-1; R-3; S-4

  • P-4; Q-3; R-2; S-1

There are 9 questions to complete.

Take a part in the ongoing discussion