classAction
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.
$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 $tagpublic string $codepublic string|null $namedReferencepublic Location $locationMethods§
public function __construct(
public string|null $tag,
public string $code,
public string|null $namedReference,
public Location $location,
)Parameters
$tag | string|null | The type tag before the braces, or null when none is given |
$code | string | The code without its braces |
$namedReference | string|null | The `[name]` after the braces, or null when none is given |
$location | Location | Where the tag or the opening brace is written |
public function location(): LocationAnswers where the item begins.
Returns
Location Line and column of the tag or the opening braceTest cases 1
ActionTest::testLocationcalls
Test cases 11§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 1
ActionTest::testLocationcalls
Other tests reaching this symbol 10
TreeDumper::itemcallsAlternativeTest::testSymbolscallsBisonGrammarCompilerTestcallsBisonGrammarReaderTestcallsParserTest::testParsecallsPrinterTest::testAlternativecallsPrinterTest::testRulecallsRhsPrinterTest::testPrintcallsRuleParserTest::testCheckEmptycallsRuleParserTest::testItemcalls
Relations§
Instantiated in 1
Constant reads 1
Type checks 4
- instanceof BisonParser\Syntax\RuleParser::checkEmpty() packages/bison-parser/src/Syntax/RuleParser.php:108
- instanceof BisonParser\Syntax\RuleParser::checkEmpty() packages/bison-parser/src/Syntax/RuleParser.php:112
- instanceof SqlParser\Compiler\BisonGrammarReader::alternative() packages/sql-parser/src/Compiler/BisonGrammarReader.php:148
- instanceof SqlParser\Compiler\BisonGrammarReader::continues() packages/sql-parser/src/Compiler/BisonGrammarReader.php:168