I am developing a rule system which can accept relational and logical operators.
A simple expression in the rule system could be as simple as
EmployeeAgeProperty >= IntegerProperty:27
where I define what would substitute the EmployeeHireDateProperty
and my rulesystem will evaluate that. Assume that each simple expression like above would evaluate to a true/false. My regex for this would be
(?P<lhs>[A-Z][a-zA-Z]*Property):{0,1}(?P<lhsPrimitiveValue>[A-Za-z0-9]*)\ *(?P<operator>[><=]|!=|<=|>=|in|not_in)\ *(?P<rhs>[A-Z][a-zA-Z]*Property):{0,1}(?P<rhsPrimitiveValue>[A-Za-z0-9]*)
lhs = Left Hand Side
rhs = Right Hand side.
Now, I want to combine number of simple expressions into compound expressions via logical operators And/Or(lets assume Not is out of context).
So, a valid compound expression would be
SimpleExpression1 and SimpleExpression2 or SimpleExpression3
where each simple expression inturn would match the above regex.
I want my regex group to return ('SimpleExpression1', 'and', SimpleExpression2', 'or', 'SimpleExpression3')
I could comeup with something like this
([\w\d!=< ]*)\ *(and|or)\ *([\w\d!=< ]*)
which would match a single compound expression with one and/or. But couldn't able to expand further.