You are on page 1of 3

AMC ENGINEERING COLLEGE, BENGALURU – 560083

(Affiliated to VTU, Belagavi, ACITE Approved, NBA Accredited)


Department of Computer Science and Engineering

QUESTION BANK
Sem/Subject/Code: 5th/AUTOMATA THEORY AND COMPILER DESIGN
/21CS51
Prepared By: Mala M
Module-2 Compiler Questions
1. Explain the role of Lexical Analyzer. Define Tokens, Patterns and Lexemes.
2. Define Token, Patterns and Lexeme for the statement char a[]= “Hello”
3. What is meant by input buffering? Explain the use of sentinels with Lookahead
code.
4. Write regular definitions for Identifiers, unsigned numbers and draw the
transition diagram for the same
5. Construct the transition diagram to recognize the tokens given below, also write
the regular definitions:
1) Identifier
2) Relational operator
3) Unsigned numbers
Module-3

1. Define CFG. Construct the CFG for the L={anbn|n>=1}


2. Construct the CFG for the L= {aibjck| i=j+k}
Note: Practice more problems on Constructing CFG
3. List the different Error-Recovery strategies of Parser and briefly explain
each of them.
4. Given the grammar
S(L)/a
L L , S/S
i) Do the necessary changes to make it suitable for LL(1) parser.
ii) Check the resultant grammar is LL(1) or not.
iii) Construct the predictive parsing table
iv) Show the moves made by the predictive parser on the input(a,(a,a)).
5. Show that the following grammar is ambiguous:
E → E + E | E * E | ( E) | id .
Write an unambiguous grammar for the same if * is having higher priority
compared to + and both are right associative.
6. What are LL(1) grammars? Explain the conditions that should hold good
for LL(1) grammars with example.
7. Define ambiguity. Check whether the grammar is ambiguous, if so
eliminate ambiguity
stmt-> if expr then stmt
| if expr then stmt else stmt
|other
8. Write a grammar for if-them-else statement of Fortan language. Eliminate
the “dangling –else” ambiguity in the same
9. Consider the following context free grammar
S → SS + | SS * | a and the input string aa + a*
i. Give LMD and RMD
ii. Parse Tree
iii. Is the grammar ambiguous? Why
iv. Describe the language generated by the grammar
v. Left factor the grammar
10. Write a recursive descent parser for the grammar:
S → cAd
A → ab | a
and for the input ‘cad’, demonstrate the tracing using recursive descent
parser.
11. Define left factoring and give the algorithm for the same. Run the
left
factoring algorithm for the grammar given below :
S → iEtS | iEtSeS | a
E→b

12. Eliminate the left recursion from the following grammar:


E→E+T|T
T→T*F|F
F → (E) | id
13. Construct the LL( 1) parsing table for the following productions :
E→ E+ T|T
T →T * F|F
F→(E)|ID
14. Compute : (i) First( ) and Follow( )
(i) Predictive parsing table for the given grammar
D →L ; T
L →L ;id | id
T →int | real

You might also like