classSymbol
final class Symbol
Restricted visibility: declared "@visibility public
Bison tells string tokens apart by their spelling, so `"\'"` and `"'"`
are two tokens; the spelling is kept for that, next to the decoded value.". Code outside that scope must not name this declaration.
A reference to a grammar symbol as it is written in a declaration or rule.
The value is the identifier itself, the decoded character of a character literal, or the decoded text of a string alias, so '\n' and "\n" both carry a newline.
$symbol = new \BisonParser\Ast\Symbol(\BisonParser\Ast\SymbolKind::CharLiteral, '+', new \BisonParser\Ast\Location(3, 9));
$symbol->isIdentifier() // => false
$symbol->value // => '+'Properties§
public SymbolKind $kindpublic string $valuepublic Location $locationpublic string|null $spelling = nullMethods§
public function __construct(
public SymbolKind $kind,
public string $value,
public Location $location,
public string|null $spelling = null,
)Parameters
$kind | SymbolKind | How the symbol is spelled |
$value | string | The identifier, the decoded character, or the decoded string |
$location | Location | Where the symbol is written |
$spelling | string|null | A literal as written, quotes and escapes included; null for an identifier |
public function isIdentifier(): boolReports whether the symbol is spelled as an identifier.
Returns
bool True for an identifier, false for a character literal or stringTest cases 1
Calls 1
- class-const SymbolKind::Identifier() line 47
Test cases 31§
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 30
TreeDumpercallsCodePropsTest::testLocationcallsStartTest::testLocationcallsPrecedenceDeclarationTest::testLocationcallsSymbolDeclarationTest::testLocationcallsSymbolEntryTest::testAliascallsGrammarFileTest::testAllDeclarationscallsGrammarFileTest::testRulescallsAlternativeTest::testSymbolscallsPrecItemTest::testLocationcallsRuleTest::testAlternativescallsSymbolItemTest::testLocationcallsBisonGrammarCompilerTestcallsBisonGrammarReaderTestcallsParserTestcallsDeclarationPrinterTest::testEntriescallsDeclarationPrinterTest::testPrintcallsDeclarationPrinterTest::testPropscallsDeclarationPrinterTest::testTargetscallsPrinterTest::testAlternativecallsPrinterTest::testPrintcallsPrinterTest::testRulecallsRhsPrinterTest::testPrintcallsSymbolPrinterTest::testSymbolcallsDeclarationParserTest::testDirectivecallsGrammarParserTestcallsRuleParserTest::testAlternativecallsRuleParserTest::testCheckEmptycallsSymbolListParserTest::testSymbolscallsSymbolListParserTest::testTargetscalls
Relations§
Instantiated in 1
Type declarations 6
- type BisonParser\Ast\Declaration\Symbols\SymbolEntry packages/bison-parser/src/Ast/Declaration/Symbols/SymbolEntry.php:29
- type BisonParser\Ast\Rule\PrecItem packages/bison-parser/src/Ast/Rule/PrecItem.php:26
- type BisonParser\Ast\Rule\Rule packages/bison-parser/src/Ast/Rule/Rule.php:31
- type BisonParser\Ast\Rule\SymbolItem packages/bison-parser/src/Ast/Rule/SymbolItem.php:28
- type BisonParser\Printer\SymbolPrinter packages/bison-parser/src/Printer/SymbolPrinter.php:33
- type BisonParser\Syntax\SymbolListParser packages/bison-parser/src/Syntax/SymbolListParser.php:251