Do I need to write a new compileExpression code for the code generation?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Do I need to write a new compileExpression code for the code generation?

Henoktes722
Do I need to write a new code for handling expression for code generation? Like in my first implementation, project 10, compileExpression works like the grammar in Fig 10.5. "term (op term)*".

Example "1 + 2"

So my code first compiles the term, integer constant, then the operation add, then the integer constant 2.
But as you described, for stack based platform, the above example must first push the operands before the operator. So do I need to change my compileExpression code? If that is not the case how can I implement it?
Reply | Threaded
Open this post in threaded view
|

Re: Do I need to write a new compileExpression code for the code generation?

WBahn
Administrator
Henoktes722 wrote
Do I need to write a new code for handling expression for code generation? Like in my first implementation, project 10, compileExpression works like the grammar in Fig 10.5. "term (op term)*".

Example "1 + 2"

So my code first compiles the term, integer constant, then the operation add, then the integer constant 2.
But as you described, for stack based platform, the above example must first push the operands before the operator. So do I need to change my compileExpression code? If that is not the case how can I implement it?
Focus on the material in Section 11.1.2.