classClosureIndex
final class ClosureIndex
What the closure of an item set adds, precomputed per nonterminal.
Closing an item set adds every rule of every nonterminal reachable from a nonterminal after a dot. Those additions depend only on the nonterminal, so they are computed once: the items that begin with each symbol, and the empty rules, which complete immediately.
Properties§
public int $itemWidthItems encode a rule and a dot position as rule times this width plus dot.
Methods§
public function __construct(Grammar $grammar)Precomputes the closure additions of every nonterminal.
Parameters
$grammar | Grammar | Grammar to index |
Calls 3
- function-call
maxline 45 - method-call ClosureIndex::reachable() line 54
- method-call Grammar::rulesOf() line 55
public function reachable(Grammar $grammar, int $nonterminal): list<int>Answers the nonterminals whose rules the closure of a nonterminal adds.
Parameters
$grammar | Grammar | Grammar to walk |
$nonterminal | int | Nonterminal after the dot |
Returns
list<int> The nonterminal itself and every one reachable through a leading nonterminalTest cases 1
Called from 1
Calls 3
- function-call
array_popline 84 - method-call Grammar::rulesOf() line 85
- function-call
array_keysline 94
public function startsWith(int $nonterminal): array<int, list<int>>Answers the closure items that begin with each symbol, dot advanced past it.
Parameters
$nonterminal | int | Nonterminal after the dot |
Returns
array<int, list<int>> Items by their first symbolTest cases 1
Called from 1
public function emptyRules(int $nonterminal): list<int>Answers the empty rules the closure of a nonterminal completes at once.
Parameters
$nonterminal | int | Nonterminal after the dot |
Returns
list<int> Rule indexesTest cases 1
Called from 1
Private surface 2§
Implementation details, listed for orientation only.
private array<int, array<int, list<int>>> $startsWithprivate array<int, list<int>> $emptyRulesTest cases 7§
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 4
LookaheadSetsTestcallsLr0BuilderTestcallsParseTableBuilderTestcallsLrParserTestcalls