Question: Write an attribute grammar based on the CFG of Figure 4.11 that will build a syntax tree with the structure described in Figure 4.14. Figure

Write an attribute grammar based on the CFG of Figure 4.11 that will build a syntax tree with the structure described in Figure 4.14.

Figure 4.11:

program stmt list $$ stmt list + stmt list decl | stmt list stmt | e decl int id real id stmt → id := expr | read id write expr + term | expr add op term → factor | term mult op factor еxpr term factor → +

Figure 4.14:

program stmt list $$ stmt list + stmt list decl | stmt

program stmt list $$ stmt list + stmt list decl | stmt list stmt | e decl int id real id stmt id := expr | read id write expr + term | expr add op term factor | term mult op factor xpr term factor + ( expr ) | id | int_const | real_const | float ( expr ) | trunc ( expr ) add-op +| - * | / mult_op

Step by Step Solution

3.44 Rating (160 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

ANSWER Class of node program stmtlist decl stmt expr term factor Variants intdecl realdecl read writ... View full answer

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 Programming Language Pragmatics Questions!