final class LookaheadSets
Restricted visibility: declared "@visibility root". Code outside that scope must not name this declaration.

The LALR(1) lookahead of every reduction, by the method of DeRemer and Pennello.

Each nonterminal transition of the automaton is a node. Its direct reads are the terminals that can follow it at once; the reads relation adds what follows a nullable nonterminal after it; the includes relation adds what follows a rule that ends with it. The lookahead of a completed rule is the union over the transitions the rule was entered from.

Methods§

public function __construct(
    Grammar $grammar,
    Lr0Automaton $automaton,
    NullableSet $nullable,
    Digraph $digraph = new \SqlParser\Automaton\Digraph(),
)

Computes the lookahead sets.

Parameters

$grammarGrammarGrammar the automaton was built from
$automatonLr0AutomatonIts LR(0) automaton
$nullableNullableSetIts nullable nonterminals
$digraphDigraphCloses sets over the relations
Calls 9
public function reads(
    Lr0Automaton $automaton,
    array<int, array<int, int>> $nodes,
    int $terminalCount,
    NullableSet $nullable,
): array{array<int, array<int, int>>, array<int, list<int>>}

Computes the direct reads of every nonterminal transition and the reads relation between them.

Parameters

$automatonLr0AutomatonThe automaton
$nodesarray<int, array<int, int>>Transition number by state and nonterminal
$terminalCountintHow many terminals a read set may hold
$nullableNullableSetNonterminals that derive the empty string

Returns

array{array<int, array<int, int>>, array<int, list<int>>} Direct reads of each transition, and the transitions each one reads through a nullable nonterminal
Test cases 1
Called from 1
Calls 5
public function of(int $state): array<int, array<int, int>>

Answers the lookahead of every rule completed in a state.

Parameters

$stateintState number

Returns

array<int, array<int, int>> Bitset of terminals by rule index
Test cases 2
Called from 1

Private surface 1§

Implementation details, listed for orientation only.

private array<int, array<int, array<int, int>>> $lookaheads

Test cases 5§

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 2

Relations§

Instantiated in 1
Method calls 1