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

Reads a rule from its left-hand side to its period, as Lemon's rule states do.

Methods§

public function read(Token $lhs, TokenStream $tokens, SymbolRegistry $registry): Rule

Reads a rule whose left-hand side has been taken.

Parameters

$lhsTokenThe nonterminal token
$tokensTokenStreamThe rest
$registrySymbolRegistrySymbols seen so far

Returns

Rule The rule, without precedence mark or code

Throws

SyntaxException Where Lemon reports an error
Test cases 6
Called from 1
Calls 13
public function head(Token $lhs, TokenStream $tokens): string|null

Reads what follows the left-hand side up to and including ::=.

Parameters

$lhsTokenThe nonterminal token
$tokensTokenStreamThe rest

Returns

string|null The alias of the left-hand side, or null

Throws

SyntaxException Where Lemon reports an error
Test cases 5
Called from 1
Calls 3
public function compound(RhsItem $item, Token $token): RhsItem

Adds a terminal to the position before it, making a multi-terminal.

Parameters

$itemRhsItemThe position
$tokenTokenThe `|X` or `/X` token

Returns

RhsItem The position with the terminal added

Throws

SyntaxException When the position holds a nonterminal
Test cases 2
Called from 1
Calls 3
public function alias(
    RhsItem $item,
    TokenStream $tokens,
    Token $lhs,
    string|null $lhsAlias,
): RhsItem

Reads name) after an opening parenthesis and names the position before it.

Parameters

$itemRhsItemThe position
$tokensTokenStreamThe rest
$lhsTokenThe rule's nonterminal, for messages
$lhsAliasstring|nullThe rule's alias, for messages

Returns

RhsItem The named position

Throws

SyntaxException Where Lemon reports an error
Test cases 3
Called from 1
Calls 3

Test cases 20§

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

Dedicated tests 16
Other tests reaching this symbol 4

Relations§

Instantiated in 1
Method calls 1
Type declarations 1