Compiler Assignment-1
Compiler Assignment-1
(ACSE0504)
Assignment- Unit 1&2
SEM/SEC:
V(A+B+C+D+E)
Assignment Given Date: 19/09/2024 Maximum Points: 10
Assignment Submission Date: 2/10/2024 Weightage in University Exam: 10 Marks
Faculty Name: ROHIT CHAUDHARY
1.Illustrate the phases of compiler with following Example .(Sum= old Sum+rate*50) [CO1]
2. Let G be a Context Free Grammar for which the production Rules are given below:
[CO1]
S -> aB|bA
A -> a|aS|bAA
B -> b|bS|aBB
Drive the string “aaabbabbba” using the above grammar (using Left Most Derivation and Right
most Derivation and draw the parse tree.
E → E+E | E*E| a| b
C → bC / ∈
B → cC
D → EF
E→g/∈
F→f/∈
8) Write Basic operations about shift-reduce parsing and parse the string Using S-R parser.
[CO2]
Consider the grammar
E –> 2E2
E –> 3E3
E –> 4
Perform Shift Reduce parsing for input string “32423”
T →T *F/F
F →F /a/b
10) ( a) Give Operator –precedence parsing algorithm. Consider the following grammar
and build up operator precedence table. Also parse the input string (id+(id*id))
[CO2]
EE+T|T
TT*F|F
F(E)|id
(b) Construct the parsing table for the following grammar: S→AA, A→aA|b [CO2]
a) LR(0)
b) SLR(1)
c) CLR (1)
d) LALR