Question: ( 4 0 points ) Given the following grammar that accepts a prefix expression, S ' E E + E E | E F F

(40 points) Given the following grammar that accepts a prefix expression,
S'E
E+EE
|E
F
F num 10
| num 26
where,+, num 10 and num 26 are terminals, num 10 is a sequence of decimal digits, and num 26 is a
sequence of lower-case English letters. Answer the following questions:
(a)(5 pts) Derive ++512cy using right-most derivation.
(b)(5 pts) Construct a CFSM for the grammar.
(c)(5 pts) Find the first and follow sets for all non-terminals.
(d)(5 pts) Draw the parse table based on your answers in (b) and (c).
(e)(10 pts) Show the rules/actions sections of Flex and Bison specifications for the grammar to
interpret the language where num 10 is interpreted as a decimal integer and num 26 as a base-26
number. The decimal value of a letter is based on its alphabetic order, a=0,b=1,dots, and z=
The decimal value of cy can be calculated as 2**26+24=76. The unary operator means
negation. As an example, the result of ++512cy is 83.
(f)(8 pts) Based on the grammar and the parse table in (d), show parse process of the input in
(a). Annotate each terminal and non-terminal on the stack with its attribute value based on your
answer in (e).
(g)(2 pts) How is the parsing process in (f) related to the derivation in (a)?
 (40 points) Given the following grammar that accepts a prefix expression,

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!