-
Notifications
You must be signed in to change notification settings - Fork 0
Lazy
xtay2 edited this page Feb 16, 2023
·
1 revision
The Lazy
non-terminal is used to solve circular dependencies in rules. For example: An expression contains multiple values, but a value can be an expression.
-
Lazy(Supplier<Rule> ruleSupplier)
: Takes a method that supplies a rule.
static Rule brackets() {
return new Multiple(true,
new Literal("["),
new Lazy(ThisClass::brackets),
new Literal("]")
);
}
Matches
""
"[ ][ ]"
"[[] []]"
"[ [[][]] [] ]"
Fails
"[["
"[]]"