-
Notifications
You must be signed in to change notification settings - Fork 0
Resolving Expressions
Jan Winkler edited this page Oct 11, 2016
·
2 revisions
Two structurally equivalent Expressions can be resolved against one another. This ranges from simple examples, such as
Expression A: ?a
Expression B: 5
Bindings:
* ?a = 5
to more complex structures like this:
Expression A: ((?a ?b) ?c 5)
Expression B: ((1 2) (4 (test1 test2)) 5)
Bindings:
* ?a = 1
* ?b = 2
* ?c = (4 (test1 test2))
You can put variables on both sides of the resolution:
Expression A: (?a 2)
Expression B: (1 ?b)
Bindings:
* ?a = 1
* ?b = 2
In C++, Expressions are resolved against each other like this:
Expression exA = Expression::parseSingle("(?a 2)");
Expression exB = Expression::parseSingle("(1 ?b)");
std::map<std::string, Expression> mapBindings;
if(exA.match(exB, mapBindings)) {
// Structural match, no incompatible fields
// Now do something with the bindings in mapBindings
} else {
// No match
}