
A tree traversal can be used to return the value of a logical expression tree, given that the values of the logical variables are known.
A dictionary is passed to the tree evaluation routine that maps variable names to values.
Diagnostic print statements are used to show a trace of the evaluation.
( X & Y ) | ( ( ! X ) & ( ! Y ) )
Here is the JavaScript code.
Here is the output of the JavaScript code.
The next step is to separate the
evaluate process, that takes a tree and an environment to evaluate a result, into two parts.
generate to generate code from the tree
execute to execute code given the environment.
The stack-based code is the basis for instruction set code.