-
Notifications
You must be signed in to change notification settings - Fork 26
Open
Description
I have a grammar like the following:
expr =
number : literal
.operators infix left
'*' : times
.operators infix flat
comparator : relation
comparator =
'<' : less
'<=' : lessequals
I am attempting to codegen the relation with a loop like the following:
struct owl_ref r = ...
struct parsed_expr expr = parsed_expr_get(r);
struct owl_ref left = expr.operand;
struct owl_ref comparator = expr.comparator;
assert(!comparator.empty); // This assertion fails.
struct owl_ref right = owl_next(expr.operand);
bool first = true;
for (; !right.empty; right = owl_next(left)) {
if (!first) {
printf(" && ");
} else {
first = false;
}
printf("(");
codegen_expr(left, false);
const char *operator = "<"; // codegen_comparator(comparator);
printf(" %s ", operator);
codegen_expr(right, false);
printf(")");
left = right;
// comparator = owl_next(comparator);
}
My goal is to turn something like: 1 <= 2 < 3 into (1 <= 2) && (2 < 3) but expr.comparator is empty. Is this a limitation in Owl or a misunderstanding on my part?
I can provide a more involved example if you need something to debug, but figured I'd ask first.
Metadata
Metadata
Assignees
Labels
No labels