Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

3. Consider the following grammar for infix arithmetic expressions. E -> E + T -> E - T -> + T -> - T ->

3. Consider the following grammar for infix arithmetic expressions.

E -> E + T

-> E - T

-> + T

-> - T

-> T

T -> T * F

-> T / F

-> F

F -> ( E )

-> i

a) Add semantic actions in appropriate positions in the rules to effect

a translation from infix to postfix code for the 8087 FPU. The

instructions corresponding to the various stack operations are given

in the following table.

load i on stack: fld i

negate: fchs

add: fadd

subtract: fsub

multiply: fmul

divide: fdiv

b) Construct a parse tree with actions to derive the output for the

expression -a + b*c - d/e.

c) Convert the translation grammar produced in (a) to a form that can be

parsed by a recursive descent parser.

d) Write procedures E, T, and F for a recursive descent parser for the

grammar in (c). Include any extra code needed for the translation.

4. Consider the following grammar G (with start symbol A).

A -> i B := e

B -> S B

B ->

S -> [ e C ]

S -> .i

C -> , e C

C ->

a) Construct the leftmost derivation and the associated parse tree

for the input i [ e ] := e.

b) Calculate the FIRST and FOLLOW sets for all non-terminals in the

grammar G.

c) Calculate the SELECT sets for each production.

d) Construct the LL( 1) parsing table for this grammar.

e) Show the sequence of configurations of an LL( 1) parser for the

input i [ e ] := e.

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

Step: 3

blur-text-image

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

Database And Expert Systems Applications 31st International Conference Dexa 2020 Bratislava Slovakia September 14 17 2020 Proceedings Part 1 Lncs 12391

Authors: Sven Hartmann ,Josef Kung ,Gabriele Kotsis ,A Min Tjoa ,Ismail Khalil

1st Edition

303059002X, 978-3030590024

More Books

Students also viewed these Databases questions