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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started