Question: Hi.. This is a 300 point assignment that needs to submit this week. I need a good detail explaination for this. kindly help! The grammar

"Hi.. This is a 300 point assignment that needs to submit this week. I need a good detail explaination for this. kindly help!"

The grammar below generates nested lists of numbers. The semantic actions are intended to count the number of elements just inside each parenthesized list. For each list found by Rule 2, Marker 44 prints out the number of elements found just inside the list.

For example, the input

( ( 1 2 3 ) ( 1 2 3 4 5 6 ) )

Should print 3, 6, and 2.

(a) The grammar uses a global variable count to determine the number of elements in a list. What is wrong with that approach?

(b) Change the semantic actions so that the appropriate values are synthesized by the rules to allow counting without a global variable.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!