classPrecedenceDeclaration
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.
$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 $associativitypublic list<Symbol> $symbolspublic Location $locationMethods§
public function __construct(
public Associativity $associativity,
public list<Symbol> $symbols,
public Location $location,
)Parameters
$associativity | Associativity | Which keyword it is |
$symbols | list<Symbol> | The terminals, in order |
$location | Location | Where the `%` sign is |
public function location(): LocationTest 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
TreeDumper::declarationcallsGrammarFileTest::testDeclarationscallsGrammarFileTest::testRulescallsLemonGrammarCompilerTestcallsLemonGrammarReaderTestcallsParserTest::testParsecallsDeclarationPrinterTest::testPrintcallsPrinterTest::testPrintcallsDeclarationReaderTest::testReadcallsGrammarReaderTest::testReadcalls