final class LemonRules
Restricted visibility: declared "@visibility root". Code outside that scope must not name this declaration.

Reads the rules a Lemon grammar writes.

Lemon writes one alternative per line rather than grouping them, so the alternatives of a rule are gathered by name as the file is read. Within a line it allows an alternation between tokens in a single position, which stands for as many alternatives as the positions multiply out to, and it lets each symbol carry an alias the parser uses to name its value.

Methods§

public function readFrom(
    string $input,
    LemonSymbols $symbols,
): array<string, list<list<string>>>

Reads every rule, telling the symbol table what each name turned out to be.

Parameters

$inputstringContents of the grammar file
$symbolsLemonSymbolsSymbol table to record names in

Returns

array<string, list<list<string>>> Rule name => its alternatives, each a list of symbol names
Test cases 4
Called from 1
Calls 7
public function alternatives(string $rhs, LemonSymbols $symbols): non-empty-list<list<string>>

Multiplies out one right-hand side into the alternatives it stands for.

A position written as A|B means either, so a right-hand side with two such positions stands for four alternatives. Positions Lemon marks with a leading percent sign configure the parser rather than name a symbol.

Parameters

$rhsstringRight-hand side as the grammar writes it
$symbolsLemonSymbolsSymbol table to record names in

Returns

non-empty-list<list<string>> Every alternative the right-hand side stands for
Test cases 5
Called from 1
Calls 11

Private surface 1§

Implementation details, listed for orientation only.

private LemonText $text = new \SqlFaker\Compiler\Lemon\LemonText()

Test cases 9§

Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.

Dedicated tests 8
Other tests reaching this symbol 1

Relations§

Instantiated in 1
Method calls 1
Type declarations 1