Hi. This is a homework question.
I need to develop an RDP for algebraic expressions.
like a+b+c*d/(h-g)
etc
the rules are: exp=exp(+|-)term|term
term=term*factor|term/factor|factor
factor=id|exp
now the thing is that I created a few functions for exp, term, factor
and I am able to successively and successfully separate all the terms like
a
+
b
etc
the issue here is that I need to generate native code
like
a
b
+
c
etc like an abstract stack machine
I stored a,+,b,+,c etc in an array and then using the array I am trying to generate the native code.
Is this how it is supposed to be? or should the output be correctly executed only recursively without using array manipulation