Question: The language generated by the grammar in Figure 7.8 uses the terminal x to introduce the base. Amore common convention is to separate the base

The language generated by the grammar in Figure 7.8 uses the terminal x to introduce the base. Amore common convention is to separate the base from the string of digits by some terminal symbol. Instead of x 8 4 3 1 to represent , a language following the common convention would use 8 x 4 3 1. (a) Design an LALR(1) grammar for such a language and specify the semantic actions that compute the strings numeric value. In your solution, allow the absence of a base specification to default to base 10, as in Figure 7.8. (b) Discuss the tradeoffs of this language and your grammar as compared with the language and grammar of Figure 7.8. The language generated by the grammar in Figure 7.8 uses the terminal

1 Start Digsans call PRINT(ans val) 2 Digs up Digs deaf up val below.val x below base next up. base below base I SetBasebasespec up. base basespec up val 0 4 setbasen A n 10 x d num (a) (b) Figure 7.8: (a) Grammar that avoids global variables; (b) Parse tree reorganized to facilitate bottom-up attribute propagation

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!