use a functional language to traverse an Abstract Syntax Tree. Input will be pro
ID: 3865915 • Letter: U
Question
use a functional language to traverse an Abstract Syntax Tree.
Input will be provided as a tree literal for Scheme, as shown on pp. 379-381 of the textbook. The tree will be an AST for a program. For example, the syntax tree for the program in Figure 15.2 on p. 778 could be represented in Scheme as:
'(program
((assign (var i int) (call (func getint void int) ()))
(assign (var j int) (call (func getint void int) ()))
(while (neq (var i int) (var j int))
((if (gt (var i int) (var j int))
((assign (var i int) (minus (var i int) (var j int))))
((assign (var j int) (minus (var j int) (var i int)))))))
(call (func putint int void) ((var i int)))))
Explanation / Answer
solution is:
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.