USE SCHEME LANGUAGE Use a functional language to traverse an Abstract Syntax Tre
ID: 3869049 • Letter: U
Question
USE SCHEME LANGUAGE
Use a functional language to traverse an Abstract Syntax Tree and generate pseudo-assembly code.
Your program should be able to generate pseudo-assembly code for the constructs used in Figure 15.2. Other statements (such as the for loop) or expressions (such as the division operator) used in Figure 15.10 on p. 804 are optional.
The pseudo-assembly code may either be returned as a list of strings or printed directly to the terminal (e.g., with println in Scheme or Printf.printf in OCaml).
You may omit the declaration block at the top of the code (the section beginning -- first few lines generated during symbol table traversal) in Figure 15.7. Begin with the label main:.
Explanation / Answer
#include "stdio.h" __int64 factorial(__int64 n) { return ( n==0 ? 1 : n*factorial(n-1) ); } int main(int argc, char* argv[]) { for (int n=0; nRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.