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

Reads one declaration, following the prologue_declaration and grammar_declaration rules of parse-gram.y.

Methods§

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

Parameters

$symbolsSymbolListParserReads the symbol lists of declarations
Calls 1
public function starts(Token $token): bool

Reports whether a token begins a declaration.

Parameters

$tokenTokenToken to look at

Returns

bool True for a prologue or a directive that is not a rule modifier
Test cases 1
Called from 2
Calls 5
public function line(Token $token): Line

Turns a #line token into its node.

Parameters

$tokenTokenThe token, whose text is the directive as written

Returns

Line The node
Test cases 1
Called from 2
Calls 2
public function directive(Token $token, TokenStream $tokens): Declaration

Reads the arguments of a directive whose name token was just consumed.

Parameters

$tokenTokenThe directive token
$tokensTokenStreamTokens positioned after the directive

Returns

Declaration The declaration

Throws

SyntaxException When the directive lacks its argument or is not a declaration
Test cases 5
Called from 1
Calls 34
public function define(TokenStream $tokens, Location $at): Define

Reads the variable and optional value of a %define.

Parameters

$tokensTokenStreamTokens positioned after the directive
$atLocationWhere the directive is written

Returns

Define The declaration

Throws

SyntaxException When no variable follows
Test cases 2
Called from 1
Calls 12
public function codes(TokenStream $tokens, string $name): list<string>

Reads the one or more braced arguments of a %param directive.

Parameters

$tokensTokenStreamTokens positioned after the directive
$namestringDirective name, for the error

Returns

list<string> Each argument's code without its braces

Throws

SyntaxException When no braced argument follows
Test cases 2
Called from 1
Calls 3

Private surface 1§

Implementation details, listed for orientation only.

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

Test cases 19§

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

Dedicated tests 14
Other tests reaching this symbol 5

Relations§

Instantiated in 2
Method calls 6
Type declarations 2