How to Convert a Syntax-tree into stack code

Valid inputs consist either of an Expression
March 22, 2023
Describe how a parse tree can be translated into a sequence of assembly language
March 22, 2023

How to Convert a Syntax-tree into stack code

2002 Paper 5 Question 6
Compiler Construction
(a) Assuming a Java type is given to each variable, state a method by which an
overloaded operator (such as +,- etc.) in a Java program can be determined
to be an int, real or other operator. [3 marks]
(b) Explain, using pseudo-code as appropriate, how to convert a syntax-tree into
stack code such as that used in the JVM. For the purposes of this question, you
only need consider trees representing bodies of void-returning functions, and
these bodies only as consisting of a list of statements of the form int x = e;
or x = e; where x ranges over variables and e over expressions; expressions
contain variables, integer constants, the binary operator + and static method
invocations. [10 marks]
(c) Show how a sequence of simple stack code instructions, such as those used
in your answer to part (b) above, can be translated into a sequence of
instructions for a register-oriented architecture of your choice, for example
ARM or Pentium. [7 marks]