Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Answer both please. 3. (40) Consider the following context free grammar for an arithmetic expression contain ing operation - only -> number -> - number

Answer both please. 3. (40) Consider the following context free grammar for an arithmetic expression contain ing operation - only

-> number

-> - number |

(a) The following is an attribute grammar to define the value of any arithmetic expres sion specified by the grammar above.

-> number

B .value := .value

B .st := number.value

-> - number

B 2.st := 1.st - number.value

B 1.value := 2.value

->

B .value := .st

Draw a decorated parse tree for 1-2-3-4 using the attribute grammar.

(b) Instead of the value of an arithmetic expression, we would like to know the number of numbers in an arithmetic expression. For example, in 1-2-3-4, we have four numbers.

Write an attribute grammar to define the number of numbers of any arithmetic expression following the grammar in part a).

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 Administration The Complete Guide To Dba Practices And Procedures

Authors: Craig S. Mullins

2nd Edition

0321822943, 978-0321822949

More Books

Students also viewed these Databases questions

Question

Advance warning and an explanation for the layoff.

Answered: 1 week ago

Question

Assessment of skills and interests.

Answered: 1 week ago