I am writing a translator. I have done this before, but have never tried one that can work with type expressions 3 + 4 * 2 / ( 1 − 5 ) ^ 2 ^ 3.
I have no problem with the parsing process, in fact it is about my virtual machine, which then executes the code.
My goal was a quick interpreter, so I decided not to use a stack-based virtual machine where you would need more than one instruction to multiply, for example (push, push, mul)
The assembly code for the virtual machine generated by the parser is as follows:
3 + 4 * 2 / ( 1 − 5 ) ^ 2 ^ 3
becomes
sub 1 5
pow result 2
pow result 3
div 2 result
mul 4 result
add 3 result
(The result is correct)
, , Python PHP?
, !