0% found this document useful (0 votes)
66 views

2nd Sess Comp

The document contains a past exam paper for the subject Compiler Design from Radha Govind Engineering College. It lists 4 questions related to compiler design topics like grammar properties, parser construction, and operator precedence parsing. Specifically, it asks about LR(0) item sets, LL(1) grammars, predictive parsing tables, recursive descent parsing, and shift-reduce parsing.

Uploaded by

api-3812391
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
66 views

2nd Sess Comp

The document contains a past exam paper for the subject Compiler Design from Radha Govind Engineering College. It lists 4 questions related to compiler design topics like grammar properties, parser construction, and operator precedence parsing. Specifically, it asks about LR(0) item sets, LL(1) grammars, predictive parsing tables, recursive descent parsing, and shift-reduce parsing.

Uploaded by

api-3812391
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 3

Radha Govind Engineering College, Meerut

II Sessional Test (2006-2007)


B.Tech V Semester (CS)
Compiler Design (TCS 502)

Time: 1:00 hr. MM: 30


Note: Attempt any three questions.

Q.1 Consider the following grammar G

E-> EBE/(E)/num
B-> + / - / * / \

(i) Explain why this grammar is not suitable for a recursive descent parser.
(ii) Obtain a grammar G’ from G, which can be use for recursive descent
parser.
(iii) Find the FIRST(G’) and FOLLOW(G’).

Q.2 Discuss algorithm for computation of the sets of LR(0) or SLR items. Also compute
LR(0) items and draw transition diagram for the grammar G
E-> E+T/ T
T-> TF / F
F-> F* / a / b

Q.3 Discuss the operator precedence parsing algorithm. Parse the input string
id+id*id
for the grammar
T->T+T / T*T/ (T) / id
Where precedence function is-

+ * id $
f 4 2 4 0
g 3 1 5 0

Q.4 Consider the following grammar G

S-> ACB / CbB / Ba


A-> da / BC
B-> g / ε
C-> h / ε

(i) Find FIRST(G) and FOLLOW(G).


(ii) Check G is LL(1) or not.
(iii) Construct parsing table for predictive parser.

Q.5 What is shift reduce parser. Parse the string id+id*id with the help of stack implementation of
shift reduce parser for the grammar given in Q. 3
RADHA GOVIND ENGINEERING COLLEGE, MEERUT
2ND Sessional Test (2005-06)
Subject: Compiler Construction (CS-604)
Class: B.Tech (CS) VI Sem
Time: 1:15 hr. MM: 30
Note: Attempt any four questions.

Q.1 (a) What is parsing? Explain the role of the parser in the compiler.
(b) Write the short note on LEX.

Q.2 Prepare the SLR parsing table for the grammar-

E-> E+T/ T
T-> TF / F
F-> F* / a / b

Q.3 Write the algorithms for calculating FIRST and FOLLOW of grammar and
find the first and follow for

S-> iTCeb /CTe/ TeCb


C-> aCb/ ε
T-> bCT/CT/ ε

Q.4 Write the algorithm for Recursive Descent parser for the following grammar-

E -> TE'
E'-> +TE'/ ε
T -> FT'
T'-> *FT'/ ε
F -> (E) / id

Q.5 What is LL(1) grammar? Write the procedure to check LL(1) and for
constructing LL(1) parsing table
Radha Govind Engineering College, Meerut
Second Sessional Test(2004-05)
B.Tech(CS) VI Sem
Subject: Compiler Construction Code: CS-604
Time: 1:15 hr. MM: 30
Note: Attempt All questions.

Q.1 Discuss the operator precedence-parsing algorithm. Parse the input string
id+id*id for the grammar
E->E+E / E*E/ (E) / id
Where precedence function is-

+ * id $
f 4 2 4 0
g 3 1 5 0

OR
What is left factoring? Why it is done? How we remove the left factor from a
grammar show with the help of an example and also explain left-recursion.

Q2: Translate the arithmetic expression a*-( b+c) into


a) A syntax tree
b) Postfix notation
c) Three-address code
OR
Translate the expression -( a+b) * (c+d) +( a+b+c) into
a) Quadruples
b) Triples
c) Indirect triples

Q.3 Consider the following grammar G

S-> ACB / CbB / Ba


A-> da / BC
B-> g / ε
C-> h / ε

(iv) Find FIRST(G) and FOLLOW(G).


(v) Check G is LL(1) or not.
(vi) Construct parsing table for predictive parser.

-----------------------------------------------------

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy