Reputation: 21
So I am trying to build and AST for boolean expression. Basically the expression is composed of boolean operands separated by AND, OR, NOT and paranthesis. Ex:
(true AND false) AND NOT(NOT true)
false AND NOT TRUE OR true
I am working in C# and I have classes for the TreeNode which holds the operands of an expression (LHS, RHS) and the the operator and I also have classes for the leafs of the tree that hold the boolean values.
What I am not sure how to represent is the unary NOT operator... Should I use the TreeNode class and use just on of the branches? Should I create a 'Link' class that links two expressions via an unary operator edge?
Upvotes: 2
Views: 1695
Reputation: 32429
I see three possibilities:
Upvotes: 2