classRule
final class Rule
Public API: explicitly declared with
@visibility public.One rule of the grammar: a nonterminal and the alternatives that derive it.
$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) // => 2Properties§
public Symbol $namepublic string|null $namedReferencepublic list<Alternative> $alternativespublic Location $locationMethods§
public function __construct(
public Symbol $name,
public string|null $namedReference,
public list<Alternative> $alternatives,
public Location $location,
)Parameters
$name | Symbol | The nonterminal on the left-hand side |
$namedReference | string|null | The `[name]` after the nonterminal, or null when none is given |
$alternatives | list<Alternative> | The right-hand sides in file order, at least one |
$location | Location | Where 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
TreeDumper::dumpcallsGrammarFileTest::testAllDeclarationscallsGrammarFileTest::testRulescallsBisonGrammarCompilerTestcallsBisonGrammarReaderTestcallsParserTestcallsPrinterTest::testPrintcallsPrinterTest::testRulecallsGrammarParserTest::testParsecallsGrammarParserTest::testParseKeepsLineDirectivesAmongTheRulescallsRuleParserTestcalls