Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(2) Derivation and parse tree (55 points) The questions in this section are based on the grammar given in the colored box at right (a)

image text in transcribed
image text in transcribed
(2) Derivation and parse tree (55 points) The questions in this section are based on the grammar given in the colored box at right (a) what is the associativity of the "operator? (5) assign ld = expr points) (b) What is the associativity of the + operator? 55 expr exgr + term I expr - tera I tera points) teca factor I factor * tern (c) For the " and + operators, do they have the same prectdence, does the " operator have greater facter (expe) precedence than +, or does + have greater precedence than +?(5 points) factor is id I nut (d) Using this grammar show a leftmost derivation and a parse tree for the strings in d.1 and d.2. (20) leAAC C points) Show the parse tree as either a graphical tree or a noe a \begin{tabular}{l|l|l} & 1 & 1 \end{tabular} text-based "indented tree". We've done the first one for you as an example of the desired output format. (d.o)1+2prog=>exprexpr+term=>term+termfactor+term =>1+term=>1+factor1+2 1+tertin>1+fictor (d,1)A+3B (d,2)C=(1+A)+B (e) Modify the grammar to add two new operators as follons, (20 points) - A unary minus operator (-) that has precedence higher than any of ", +, or binary minus. - A binary exponentiatios operator () that has precedence higher than unary minus and is right associative. For ecample, the string 7432 woula be interpteted as x(4((3(2)))) which would evaluate to 1.44444444w

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

Databases A Beginners Guide

Authors: Andy Oppel

1st Edition

007160846X, 978-0071608466

More Books

Students also viewed these Databases questions