I can\'t seem to find a pointer in the right direction, I am not even sure what the terms are that I should be researching but countless hours of googling seem to be spinning me
Your parsing of the expression ((Sex == Male AND Age == 25) OR (Sex == Female AND Status == Single)) AND IQ > 120 looks odd. I would parse it as:
* And
* Or
* And
* ==
* Sex
* Male
* ==
* Eyes
* Blue
* And
* ==
* Sex
* Female
* ==
* Status
* Single
* >
* IQ
* 120
The tree type would be :
Node
{
bool evaluate ()
}
AndNode : Node
{
Node left
Node right
bool evaluate ()
{
return left.evaluate () && right.evaluate ()
}
}
// OrNode is similar
EqualsNode : Node
{
Field field
Value value
bool evaluate ()
{
return field.value () == value
}
}
// Likewise for <, >, etc