consider the following grammar declaration -> type var-list type -> int | float
ID: 3838894 • Letter: C
Question
consider the following grammar
declaration -> type var-list
type -> int | float
var-list -> identifier, var-list | identifier
a. rewrite it in a form more suitable for bottom-up parsing.
b. construct the DFA of LR(0) items for the rewritten grammar.
c. construct the SLR(1) parsing table for the rewritten grammar.
d. show the parsing stack and the action of an SLR(1) parser for the input string int x,y,z using the table of part(c).
e. construct the DFA of LALR(1) items by propagating the lookaheads through the DFA of LR(0) items of part(b).
f. construct the LALR(1) parsing table for the rewritten grammar.
Explanation / Answer
Dear,
Modified grammer for bottom up parsing
declaration -> type var-list
type ->type identifier| int | float
var-list -> identifier , var-list | identifier
Hope this will help you
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.