Question: 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
(a) The following is an attribute grammar to define the value of any arithmetic expres sion specified by the grammar above.
B
B
B
B
B
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
Get step-by-step solutions from verified subject matter experts
