classFallback
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.
$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> $symbolspublic Location $locationMethods§
public function fallback(): Symbol|nullAnswers the token the others fall back to.
Returns
Symbol|null The first symbol, or null when none was writtenTest cases 1
public function tokens(): list<Symbol>Lists the tokens that fall back.
Returns
list<Symbol> Every symbol after the firstTest cases 1
FallbackTest::testTokenscalls
Calls 1
- function-call
array_sliceline 51
public function location(): LocationTest cases 8§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.