Small expression parser.
see tests/calculator.cpp
+, -, *, /, %, =, :=
The operators bind values to names. Operator =
creates a constant while :=
makes a variable that is evaluated any time it's in the expression.
Enter: a = 0
(a = 0) = 0
Enter: b = 0
(b = 0) = 0
Enter: c := a + b
(c := (a + b)) = 0
Enter: a = 2
(a = 2) = 2
Enter: b = 2
(b = 2) = 2
Enter: c
c = 4
Enter: b = 10
(b = 10) = 10
Enter: c
c = 12
Here a
and b
are constans and c
is a variable.
Enter: 2 + 2 * 2
(2 + (2 * 2)) = 6
Enter: (2 + 2) * 2
((2 + 2) * 2) = 8
Same as the calculator, but you enter an expresstion with 'X' and the example draws all 'Y' values as a line.