You are on page 1of 5

COMPILER CONSTRUCTION

Name: MUHAMMAD IBRAHIM AHMED ID# F2018266025


Resource Person: Sir Nabeel Sabir Sec: V-6

PROJECT: Develop Predictive Parser the following MINI C Language

 DELIVERAVLE – II

 Requirements for DELV.2

6. LL(1) Grammar

7. First and Follow Sets

8. Predictive Parser Table

9. Parser Software using LL(1) approach (it will print parse tree in the form of
productions)
6. LL(1) Grammar:

Removing left recursion and Non-Determinism:

CProgram  void main () { stmtSet }


StmtSet  stmt; stmtSet`
StmtSet` € | stmtSet
Stmt  decStmt | AS | coutStmt | cinStmt
decStmt  Type idset
Type  int
idSet  id idset`
idSet` € | ,idSet
AS  id=E
E  (E)E` | idE` | intLiteral E`
E` +EE` | *EE` | €
coutStmt  cout << id
cinStmt  cin >> id

7. First & Follow Sets:

 First Sets:
CP = {void}
stmtSet = {int, id, cout, cin}
stmtSet` = {int, id, cout, cin, €}
stmt = {int, id, cout, cin}
decStmt = {int}
Type = {int}
idSet = {id}

idSet` = {€, } ,
AS = {id}
E = {(, id, intLiteral}
E` = {+, *, €}
coutStmt = {cout}
cinStmt = {cin}

 Follow Sets:

CProgram = {$}
stmtSet = {}}
stmtSet`={}}
stmt = {;}
decStmt = {;}
Type = {id}
idSet = {;}
idSet` = {;}
AS = {;}
E = {+, *, ), ;}
E` = {+, *, ), ;}
coutStmt = {;}
cinStmt = {;}

8. First & Follow Sets:

No ; voi m int ( ) { } id , + * cout cin intL < > $


n- d a itera < >
Te i l
rm n
ina
l
CP CP
rog v
ra oid
m mai
n ()
{st
mts
Set
}
st stmtS stmtSet stmtSe stmtSet
mt et stmt; tstm stmt
Set stmt; stmtSet t;stmtS ;stmtSe
stmtS ` et t
et`
st stmtS stm stmtSet stmtSe stmtSet
mt et` tSet `stm t`st `stm
Set stmtS ` tSet mtSet tSet
` et €
st stmt stmt stmt stmt
mt de AS coutSt cinStm
cStmt mt t
de decSt
cSt mt
mt Type
idSet
Ty Type
pe int
idS idset
et id
idSet`
idS id idSe
et` Set t`
` ,ids
 et

AS ASi
d=E
E E EidE E
 ` intL
(E) itera
E` l E`
E` E` E E` E`
 `  *
€  +E EE`
€ E`| |€

co coutSt
utS mtc
tmt out<<
id
cin coutSt
St mtci
mt n>>id
9. Generate Parse-Table (jFlap7.1):

This Parse button is disabled don’t know


what is wrong with it.

You might also like