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

Reads the symbol lists that follow %token, %nterm, %type, %start, %left and their kin.

The lists differ in what a string means: after %token it is the alias of the identifier before it, after %left and %type it is a token of its own, and after %token it may also carry a token number.

Methods§

public function tokenDeclarations(TokenStream $tokens): list<SymbolEntry>

Reads the entries of a %token list: an identifier or character literal, its number, and the string that aliases it.

Parameters

$tokensTokenStreamTokens positioned after the directive

Returns

list<SymbolEntry> The entries, at least one

Throws

SyntaxException When the list is empty or malformed
Test cases 2
Called from 1
Calls 3
public function ntermDeclarations(TokenStream $tokens): list<SymbolEntry>

Reads the entries of a %nterm list: identifiers only, under optional tags.

Parameters

$tokensTokenStreamTokens positioned after the directive

Returns

list<SymbolEntry> The entries, at least one

Throws

SyntaxException When the list is empty or malformed
Test cases 4
Called from 1
Calls 2
public function precedenceDeclarations(TokenStream $tokens): list<SymbolEntry>

Reads the entries of a precedence list, where a string is a token of its own.

Parameters

$tokensTokenStreamTokens positioned after the directive

Returns

list<SymbolEntry> The entries, at least one

Throws

SyntaxException When the list is empty or malformed
Test cases 1
Called from 1
Calls 4
public function typeDeclarations(TokenStream $tokens): list<SymbolEntry>

Reads the entries of a %type list, plain symbols under optional tags.

Parameters

$tokensTokenStreamTokens positioned after the directive

Returns

list<SymbolEntry> The entries, at least one

Throws

SyntaxException When the list is empty or malformed
Test cases 1
Called from 1
Calls 4
public function entries(
    TokenStream $tokens,
    bool $numbered,
    bool $aliased,
    list<SymbolKind> $starts,
): list<SymbolEntry>

Reads tagged entries until something that is neither a tag nor a symbol.

Parameters

$tokensTokenStreamTokens positioned at the list
$numberedboolWhether an integer may follow an identifier
$aliasedboolWhether a string after an identifier is its alias
$startslist<SymbolKind>The kinds of symbol that may start an entry

Returns

list<SymbolEntry> The entries, at least one

Throws

SyntaxException When the list is empty, a tag has no symbol after it, or an entry starts with a symbol of another kind
Test cases 5
Called from 4
Calls 10
public function entry(
    TokenStream $tokens,
    string|null $tag,
    bool $numbered,
    bool $aliased,
): SymbolEntry

Reads one entry: a symbol with the number and alias the list allows.

Parameters

$tokensTokenStreamTokens positioned on the symbol
$tagstring|nullTag in force
$numberedboolWhether an integer may follow an identifier
$aliasedboolWhether a string after an identifier is its alias

Returns

SymbolEntry The entry
Test cases 1
Called from 1
Calls 8
public function symbols(TokenStream $tokens): list<Symbol>

Reads the symbols that follow %start.

Parameters

$tokensTokenStreamTokens positioned after the directive

Returns

list<Symbol> The symbols, at least one

Throws

SyntaxException When no symbol follows
Test cases 2
Called from 1
Calls 6
public function targets(TokenStream $tokens): list<Symbol|Tag>

Reads the symbols and tags that follow the code of %destructor or %printer.

Parameters

$tokensTokenStreamTokens positioned after the code

Returns

list<Symbol|Tag> The targets, at least one

Throws

SyntaxException When no target follows
Test cases 2
Called from 1
Calls 10
public function passesLine(TokenStream $tokens): bool

Passes over a #line directive that falls inside a list, where Bison treats it as whitespace.

A directive followed by anything else ends the list and is kept as a node of its own, so only a directive between two entries is lost.

Parameters

$tokensTokenStreamThe tokens

Returns

bool True when a directive was passed over
Test cases 1
Called from 3
Calls 8
public function kind(Token $token): SymbolKind|null
public function describe(list<SymbolKind> $kinds): string

Words an error message with the kinds of symbol that were expected.

Parameters

$kindslist<SymbolKind>The kinds, at least one

Returns

string For instance "an identifier or a character literal"
Test cases 1
Called from 1
Calls 7

Test cases 30§

Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.

Dedicated tests 24
Other tests reaching this symbol 6

Relations§

Instantiated in 2
Method calls 11
Type declarations 2