Written assignment-1
CSC 340 (First term 2014-2015)
KSU
Consider the following grammar
P S
SStmt | B
B } | ST
T } | ;B
Stmt if (Tem Pred Term) then Stmt else Stmt Stmt do Stmt while(Term Pred Term)
Stmt Identifier = Exp
Exp Integer | Integer + Exp | integer-1 Exp
Term Integer | Identifier Pred = ==+!=+ <+ <=
Part-I (Written Part)
(a) Is the above CFG ambiguous? Is so rewrite it to resolve all ambiguities.
(b) Give the first sets of the non-terminals and the follow sets of the terminals and non-terminals.
(c) Give the LL(1) parsing table for this grammar.
c) Is the grammar an LL(1) grammar? Why? Or why not?
Due date for part-I: 25 April 2015
Part-II (Programming Part)
Write an LL(1) parser after doing all necessary modifications. The input of the program should be the output of the lexical analyzer you wrote in assignement-2. The output should indicate whether the input contains a syntax error.
Due date for part-II: Sunday 3 May 2015