We can increase the modularity of our expression type by abstracting out a
separate type of symbols (here the enumerated type AOp) for the operators used
in the expressions. Note the use of a generalized ternary Bop constructor
(for "binary operator") which now must be applied to an operator symbol before
it is applied to the representations of its left and right sub-expressions.
This generalization is the first step of several which will result in a more flexible and reusable type.
|
|
Bop
constructor (the sample tree must also be extended)