classAlternative
final class Alternative
Public API: explicitly declared with
@visibility public.One right-hand side of a rule, as the sequence of items written between | separators.
Symbols, actions, predicates and modifiers are kept in the order they appear, so an action followed by more symbols is where Bison would put a mid-rule action.
$file = (new \BisonParser\Parser())->parse("%%\nexpr: expr '+' { \$\$ = 1; } expr %prec PLUS ;\n");
$alternative = $file->rules()[0]->alternatives[0];
count($alternative->items) // => 5
array_map(static fn ($symbol) => $symbol->value, $alternative->symbols()) // => ['expr', '+', 'expr']Properties§
public list<RhsItem> $itemspublic Location $locationMethods§
Test cases 13§
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 12
GrammarFileTest::testAllDeclarationscallsGrammarFileTest::testRulescallsRuleTest::testAlternativescallsBisonGrammarCompilerTestcallsBisonGrammarReaderTestcallsParserTestcallsPrinterTest::testAlternativecallsPrinterTest::testPrintcallsPrinterTest::testRulecallsGrammarParserTestcallsRuleParserTest::testParsecallsRuleParserTest::testParseAcceptsSemicolonsBetweenAlternativescalls
Relations§
Instantiated in 1
Method calls 1
Type declarations 5
- type BisonParser\Printer\Printer packages/bison-parser/src/Printer/Printer.php:90
- type BisonParser\Syntax\RuleParser packages/bison-parser/src/Syntax/RuleParser.php:81
- type SqlFaker\Compiler\Bison\BisonGrammarCompiler packages/sql-faker/src/Compiler/Bison/BisonGrammarCompiler.php:117
- type SqlParser\Compiler\BisonGrammarReader packages/sql-parser/src/Compiler/BisonGrammarReader.php:138
- type SqlParser\Compiler\BisonGrammarReader packages/sql-parser/src/Compiler/BisonGrammarReader.php:165