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

The alternative currently being read.

An alternative is finished by whatever comes after it — a pipe, a semicolon, or the start of the next rule — rather than by a token of its own, so its parts accumulate until one of those appears. Holding them here means the reader flushes and starts over in one call instead of resetting five variables at each of the three places an alternative can end, which is where a forgotten reset would leave one alternative's action attached to the next.

Methods§

public function setAction(string $action): void

Attaches the semantic action that runs when this alternative reduces.

Parameters

$actionstringHost-language code, without its braces
Test cases 2
Called from 1
public function setPrecedenceSymbol(string|null $symbol): void

Overrides the alternative's precedence with that of a named terminal.

Parameters

$symbolstring|nullTerminal to take the precedence of, or null when `%prec` named none
Test cases 2
Called from 1
public function setDynamicPrecedence(int|null $precedence): void

Sets the dynamic precedence used to resolve an ambiguity at parse time.

Parameters

$precedenceint|nullThe declared rank, or null when `%dprec` named none
Test cases 2
Called from 1
public function setMergeFunction(string|null $function): void

Sets the function that merges two ambiguous parses of this alternative.

Parameters

$functionstring|nullMerge function name, or null when `%merge` named none
Test cases 2
Called from 1
public function complete(): BisonAlternativeNode

Takes the alternative that has been read and starts a new one.

Returns

BisonAlternativeNode The completed alternative
Test cases 12
Called from 3
Calls 1

Private surface 5§

Implementation details, listed for orientation only.

private list<BisonSymbolNode> $symbols = []
private ?string $action = null
private ?string $precedenceSymbol = null
private ?int $dynamicPrecedence = null
private ?string $mergeFunction = null

Test cases 14§

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

Dedicated tests 7
Other tests reaching this symbol 7

Relations§

Instantiated in 1
Method calls 9
Type declarations 2