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.

Reading a symboldoctest
$symbol = new \BisonParser\Ast\Symbol(\BisonParser\Ast\SymbolKind::CharLiteral, '+', new \BisonParser\Ast\Location(3, 9));
    $symbol->isIdentifier() // => false
    $symbol->value // => '+'

Properties§

public SymbolKind $kind
public string $value
public Location $location
public string|null $spelling = null

Methods§

public function __construct(
    public SymbolKind $kind,
    public string $value,
    public Location $location,
    public string|null $spelling = null,
)

Parameters

$kindSymbolKindHow the symbol is spelled
$valuestringThe identifier, the decoded character, or the decoded string
$locationLocationWhere the symbol is written
$spellingstring|nullA literal as written, quotes and escapes included; null for an identifier
public function isIdentifier(): bool

Reports whether the symbol is spelled as an identifier.

Returns

bool True for an identifier, false for a character literal or string
Test cases 1
Calls 1

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

Relations§

Instantiated in 1
Type declarations 6