final class PrecedenceDeclaration
    implements Declaration
Public API: explicitly declared with @visibility public.

%left, %right or %nonassoc followed by terminals and a period.

Each declaration ranks its terminals one level above those of the declarations before it, which is why the order in the file matters.

Reading a precedence declarationdoctest
$file = (new \LemonParser\Parser())->parse("%left PLUS MINUS.\n%left STAR SLASH.\n");
    $second = $file->declarations()[1];
    [$second->associativity->value, array_map(static fn ($symbol) => $symbol->name, $second->symbols)] // => ['left', ['STAR', 'SLASH']]

Properties§

public Associativity $associativity
public list<Symbol> $symbols
public Location $location

Methods§

public function __construct(
    public Associativity $associativity,
    public list<Symbol> $symbols,
    public Location $location,
)

Parameters

$associativityAssociativityWhich keyword it is
$symbolslist<Symbol>The terminals, in order
$locationLocationWhere the `%` sign is
public function location(): Location

{@inheritDoc}

Returns

Test cases 1

Test cases 11§

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 10

Relations§

Instantiated in 1
Constant reads 1
Type checks 1