Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

( 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)?
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Optimization And Data Science Trends And Applications 5th Airoyoung Workshop And Airo Phd School 2021 Joint Event

Authors: Adriano Masone ,Veronica Dal Sasso ,Valentina Morandi

1st Edition

3030862887, 978-3030862886

More Books

Students also viewed these Databases questions

Question

7. What does practice at spontaneity and improvisation look like?

Answered: 1 week ago