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

%fallback FALLBACK TOKEN TOKEN... .: tokens the parser retries as the fallback when they cause an error.

The first symbol is the fallback; the ones after it fall back to it.

Reading a fallback declarationdoctest
$file = (new \LemonParser\Parser())->parse("%fallback ID ABORT AFTER.\n");
    $fallback = $file->declarations()[0];
    [$fallback->fallback()?->name, array_map(static fn ($symbol) => $symbol->name, $fallback->tokens())] // => ['ID', ['ABORT', 'AFTER']]

Properties§

public list<Symbol> $symbols
public Location $location

Methods§

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

Parameters

$symbolslist<Symbol>The fallback first, then the tokens that fall back to it
$locationLocationWhere the `%` sign is
public function fallback(): Symbol|null

Answers the token the others fall back to.

Returns

Symbol|null The first symbol, or null when none was written
Test cases 1
public function tokens(): list<Symbol>

Lists the tokens that fall back.

Returns

list<Symbol> Every symbol after the first
Test cases 1
Calls 1
public function location(): Location

{@inheritDoc}

Returns

Test cases 1

Test cases 8§

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

Dedicated tests 3
Other tests reaching this symbol 5

Relations§

Instantiated in 1
Constant reads 1
Type checks 1