October 2016
Intermediate to advanced
320 pages
6h 39m
English
Currently, our language only supports numerical expressions. Another useful addition would be to support Boolean expressions that do not evaluate to numeric values but to true or false. Possible examples would include expressions such as 3 = 4 (which would always evaluate to false), 2 < 4 (which would always evaluate to true), or a <= 5 (which depends on the value of variable a).
As before, let's start by extending the object model of our syntax tree. We'll start with an Equals node that represents an equality check between two expressions. Using this node, the 1 + 2 = 4 - 1 expression would produce the following syntax tree (and should of course eventually evaluate to true):
The syntax tree that should result ...
Read now
Unlock full access