final class Rule
Public API: explicitly declared with @visibility public.

One rule of the grammar: a nonterminal and the alternatives that derive it.

Reading a ruledoctest
$file = (new \BisonParser\Parser())->parse("%%\nexpr[e]: NUM | expr '+' expr ;\n");
    $rule = $file->rules()[0];
    $rule->name->value // => 'expr'
    $rule->namedReference // => 'e'
    count($rule->alternatives) // => 2

Properties§

public Symbol $name
public string|null $namedReference
public list<Alternative> $alternatives
public Location $location

Methods§

public function __construct(
    public Symbol $name,
    public string|null $namedReference,
    public list<Alternative> $alternatives,
    public Location $location,
)

Parameters

$nameSymbolThe nonterminal on the left-hand side
$namedReferencestring|nullThe `[name]` after the nonterminal, or null when none is given
$alternativeslist<Alternative>The right-hand sides in file order, at least one
$locationLocationWhere the rule is written

Test cases 12§

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

Dedicated tests 1
Other tests reaching this symbol 11

Relations§

Instantiated in 1
Type checks 3
Type declarations 3