Add basic support for math expressions with IN-SOLVE
Created by: dvkt
This is basic support for expressions as per #41 (closed).
The syntax is: IN num-var SOLVE math-expression
Right now it only supports the big four +-*/
operations. It could be expanded to support abs
and ceil
probably, if that's the direction we want to go, but this was the simplest since it's just re-using C++'s operators.
Example
DATA:
square/num is number
square/res is number
x is number
y is number
z is number
PROCEDURE:
sub-procedure square
in square/res solve square/num * square/num
end sub-procedure
store 10 in square/num
call square
display "the square of " square/num " is " square/res crlf
store 1 in x
store 2 in y
in z solve x + y
display x " + " y " = " z crlf
in z solve x * (20 / (1 + y + y)) - 3.14
display "z: " z crlf
Output
$ ./math-bin
the square of 10 is 100
1 + 2 = 3
z: 0.86