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

Reads one rule, following the rules and rhs rules of parse-gram.y.

An alternative ends at |, at ;, or where the next rule or a declaration begins, which is how Bison reads a rule that omits its semicolon. Extra semicolons after a rule are accepted as Bison accepts them.

Methods§

public function __construct(
    private SymbolListParser $symbols = new \BisonParser\Syntax\SymbolListParser(),
    private DeclarationParser $lines = new \BisonParser\Syntax\DeclarationParser(),
)

Parameters

$symbolsSymbolListParserTurns symbol tokens into symbols
$linesDeclarationParserTurns `#line` tokens into nodes
Calls 2
public function alternative(TokenStream $tokens, Location $at): Alternative

Reads the items of one alternative.

Parameters

$tokensTokenStreamTokens positioned on the first item, or on what ends the alternative
$atLocationWhere the alternative begins

Returns

Alternative The alternative

Throws

SyntaxException When an item is malformed
Test cases 1
Called from 2
Calls 3
public function checkEmpty(list<RhsItem> $items): void

Bison rejects %empty on a rule that has components: a symbol, or an action that is followed by another item and hence becomes a midrule symbol.

Parameters

$itemslist<RhsItem>
Test cases 1
Called from 1
Calls 1
public function item(TokenStream $tokens): RhsItem|null
public function action(TokenStream $tokens): Action

Reads a braced action with its optional tag and name.

Parameters

$tokensTokenStreamTokens positioned on the tag or the code

Returns

Action The action

Throws

SyntaxException When a tag is not followed by braced code
Test cases 2
Called from 1
Calls 7
public function modifier(TokenStream $tokens): RhsItem|null

Reads a %-modifier of a right-hand side.

Parameters

$tokensTokenStreamTokens positioned on the directive

Returns

RhsItem|null The modifier, or null when the directive begins a declaration instead

Throws

SyntaxException When the modifier lacks its argument
Test cases 3
Called from 1
Calls 13
public function symbolToken(TokenStream $tokens): Token

Consumes the symbol token that must follow %prec.

Parameters

$tokensTokenStreamTokens positioned after `%prec`

Returns

Token The symbol token

Throws

SyntaxException When no symbol follows
Test cases 2
Called from 1
Calls 4

Private surface 2§

Implementation details, listed for orientation only.

private SymbolListParser $symbols = new \BisonParser\Syntax\SymbolListParser()
private DeclarationParser $lines = new \BisonParser\Syntax\DeclarationParser()

Test cases 22§

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

Dedicated tests 18
Other tests reaching this symbol 4

Relations§

Instantiated in 1
Method calls 1
Type declarations 1