Hi, i think that parse the code with maths operations like +,-,/,* can be more dificult that make it as functions like Add Sub Div and Mul, think on this:
Add(2,Sub(5,Mul(2,7)))
Equivalent with other operators:
2+(5-(2*7))
To make it with brackets can be more dificult to parse on this last way than with math functions like Add, its easy to make a compiler for first one than the last one that can be more complicated, think that all the rest of functions will work like Add functions, you will not add more extra code to parse complex maths functions.
Another tip, to make flow control functions like If - Endif, Repeat - Until, While - Wend. It can be implemented with only one internal function a Jump function that can examine and, or, xor, not operators, and conditions like x=2, z<3, etc, it must be a not jump conditional function.
To understand better i will explain the if - endif.
If instruction need operators of condition and jump address(to endif)
Endif dont have code really only we put this address on If jump address.
When we are parsing the code if we found an if function we increment a IfCounter(to be sure that every If is associated to its endif) and save the Address on a StackPointer for IfJumpAddresses with IfCounter as index of this array, that will contain the jump address (endif address) to make it if NotJump Condition function ist not true, and when we found EndIf function we put the address before endif function, and put it on IfJumpAddresses(IfCounter) and we decrease this IfCounter.
If you have any question email me at
balrog@balrogsoftware.com