Question: https://www.chegg.com/homework-help/Programming-Language-Pragmatics-4th-edition-chapter-2-problem-18E-solution-9780124104099 (answer for 2.18) 4.5 Lisp has the unusual property that its programs take the form of parenthe- sized lists. The natural syntax tree for

https://www.chegg.com/homework-help/Programming-Language-Pragmatics-4th-edition-chapter-2-problem-18E-solution-9780124104099 (answer for 2.18) 4.5 Lisp has the unusual property that itsprograms take the form of parenthe- sized lists. The natural syntax treehttps://www.chegg.com/homework-help/Programming-Language-Pragmatics-4th-edition-chapter-2-problem-18E-solution-9780124104099 (answer for 2.18)

4.5 Lisp has the unusual property that its programs take the form of parenthe- sized lists. The natural syntax tree for a Lisp program is thus a tree of binary cells (known in Lisp as cons cells), where the first child represents the first element of the list and the second child represents the rest of the list. The syntax tree for (cdr '(a b c)) appears in Figure 4.16. (The notation 'L is syntactic sugar for (quote L).) Extend the CFG of Exercise 2.18 to create an attribute grammar that will build such trees. When a parse tree has been fully decorated, the root should have an attribute v that refers to the syntax tree. You may assume that each atom has a synthesized attribute v that refers to a syntax tree node that holds information from the scanner. In your semantic functions, you may assume the availability of a cons function that takes two references as arguments and returns a reference to a new cons cell containing those references. 4.5 Lisp has the unusual property that its programs take the form of parenthe- sized lists. The natural syntax tree for a Lisp program is thus a tree of binary cells (known in Lisp as cons cells), where the first child represents the first element of the list and the second child represents the rest of the list. The syntax tree for (cdr '(a b c)) appears in Figure 4.16. (The notation 'L is syntactic sugar for (quote L).) Extend the CFG of Exercise 2.18 to create an attribute grammar that will build such trees. When a parse tree has been fully decorated, the root should have an attribute v that refers to the syntax tree. You may assume that each atom has a synthesized attribute v that refers to a syntax tree node that holds information from the scanner. In your semantic functions, you may assume the availability of a cons function that takes two references as arguments and returns a reference to a new cons cell containing those references

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!