final class Action
    implements RhsItem
Public API: explicitly declared with @visibility public.

A braced action on a right-hand side, with its optional type tag and [name] reference.

Whether the action is a mid-rule action depends on what follows it in the alternative; the tree records the position and leaves that reading to the caller.

Reading a typed mid-rule actiondoctest
$file = (new \BisonParser\Parser())->parse("%%\ns: 'a' <int>{ \$\$ = 1; }[mid] 'b' ;\n");
    $action = $file->rules()[0]->alternatives[0]->items[1];
    $action->tag // => 'int'
    $action->code // => ' $$ = 1; '
    $action->namedReference // => 'mid'

Properties§

public string|null $tag
public string $code
public string|null $namedReference
public Location $location

Methods§

public function __construct(
    public string|null $tag,
    public string $code,
    public string|null $namedReference,
    public Location $location,
)

Parameters

$tagstring|nullThe type tag before the braces, or null when none is given
$codestringThe code without its braces
$namedReferencestring|nullThe `[name]` after the braces, or null when none is given
$locationLocationWhere the tag or the opening brace is written
public function location(): Location

Answers where the item begins.

Returns

Location Line and column of the tag or the opening brace
Test cases 1

Test cases 11§

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

Dedicated tests 1
Other tests reaching this symbol 10

Relations§

Instantiated in 1
Constant reads 1
Type checks 4
Type declarations 1