Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The questions in this section are based on the grammar given as the following: prog -> assign | expr assign -> id = expr expr

The questions in this section are based on the grammar given as the following:

prog -> assign | expr assign -> id = expr expr -> expr + term | expr - term | term term -> factor | factor * term factor -> ( expr ) | id | num id -> A | B | C num -> 0 | 1 | 2 | 3

(2a) What is the associativity of the * operator? (5 points)

(2b) What is the associativity of the + operator? (5 points)

(2c) For the * and + operators, do they have the same precedence, does the * operator have greater precedence than +, or does + have greater precedence than * ? (5 points)

(2e) Modify the grammar to add a new operator as it follows. (10 points) A unary minus operator (-) that has precedence higher than any of *, +, or binary minus.

(2d) Using this grammar show a leftmost derivation and a parse tree for the strings in d.1 (10 points) Show the parse tree as a graphical tree. We've done the first one (Example) for you as an example of the

desired output format. (Example) 1 + 2

2

prog => expr => expr + term => term + term => factor + term => 1 + term => 1 + factor => 1 + 2

(2d) C = (1 + A) * B

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

Microsoft Visual Basic 2017 For Windows Web And Database Applications

Authors: Corinne Hoisington

1st Edition

1337102113, 978-1337102117

More Books

Students also viewed these Databases questions

Question

9 How can training be evaluated?

Answered: 1 week ago

Question

Bachelors degree in Information Systems or Statistics

Answered: 1 week ago