classRule
final class Rule
Restricted visibility: declared "@visibility root". Code outside that scope must not name this declaration.
One production of a grammar, numbered in the order it was declared.
Rule zero is always the augmented start rule. A hidden rule is one the reader synthesised for a mid-rule action; it derives the empty string and is left out of the syntax tree.
Properties§
public int $indexpublic int $lhspublic list<int> $rhspublic int $ordinalpublic int|null $precedenceSymbol = nullMethods§
public function __construct(
public int $index,
public int $lhs,
public list<int> $rhs,
public int $ordinal,
public bool $hidden = false,
public int|null $precedenceSymbol = null,
)Parameters
$index | int | Position among all rules, zero for the start rule |
$lhs | int | Nonterminal the rule derives |
$rhs | list<int> | Symbols the rule expands to, in order |
$ordinal | int | Position among the alternatives of the same nonterminal |
$hidden | bool | Whether the rule was synthesised for a mid-rule action |
$precedenceSymbol | int|null | Terminal named to lend its precedence, if any |
public function length(): intAnswers how many symbols the rule expands to.
Returns
int Length of the right-hand sideTest cases 1
RuleTest::testLengthcalls
Calls 1
- function-call
countline 43
Test cases 28§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 2
Other tests reaching this symbol 26
ClosureIndexTestcallsConflictResolverTest::testReduceOrReducecallsConflictResolverTest::testResolveCountsAnUnrankedShiftReduceConflictAndShiftscallsConflictResolverTest::testResolveCountsAReduceReduceConflictAndKeepsTheEarlierRulecallsConflictResolverTest::testResolveKeepsPlainShiftsAndReductionscallsConflictResolverTest::testResolveLetsAHigherRankedLaterRuleWinUnderLemonsPolicycallsConflictResolverTest::testShiftOrReducecallsConflictResolverTest::testShiftOrReduceLeavesABareRankUnresolvedcallsLookaheadSetsTestcallsLr0BuilderTestcallsNullableSetTestcallsParseTableBuilderTest::testExpandLookaheadscallsParseTableBuilderTest::testExpandShiftscallsBisonGrammarReaderTest::testReadcallsBisonGrammarReaderTest::testReadNumbersMidRuleActionsBeforeTheirRulecallsLemonGrammarReaderTest::testReadcallsGrammarBuilderTestcallsGrammarTest::testMemberPrecedenceLooksThroughATokenClasscallsGrammarTest::testPrecedenceOfcallsGrammarTest::testRulePrecedencePrefersTheNamedTerminalcallsGrammarTest::testRulePrecedenceTakesTheFirstRankedTerminalUnderLemonsPolicycallsGrammarTest::testRulePrecedenceTakesTheLastTerminalUnderBisonsPolicycallsGrammarTest::testRulesMustBeNumberedInOrdercallsGrammarTest::testRulesOfcallsGrammarTest::testStartSymbolcallsLrParserTestcalls