Skip to content
xtay2 edited this page Feb 16, 2023 · 1 revision

Introduction

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.

Constructors

  • Lazy(Supplier<Rule> ruleSupplier): Takes a method that supplies a rule.

Examples

static Rule brackets() {
    return new Multiple(true,
        new Literal("["),
        new Lazy(ThisClass::brackets),
        new Literal("]")
    );
}

Matches

""
"[ ][ ]"
"[[] []]"
"[ [[][]] [] ]"

Fails

"[["
"[]]"
Clone this wiki locally