final class TerminalIndex
Restricted visibility: declared "@visibility root". Code outside that scope must not name this declaration.

Numbers lexemes against the terminals of a grammar.

Lexemes name what a scanner recognised and leave out what it skipped. The text between one lexeme and the next is given to the token that follows it, and the text after the last lexeme to the end marker, so the tokens of a text hold every byte of it.

Methods§

public function __construct(private SymbolTable $symbols)

Parameters

$symbolsSymbolTableSymbols of the grammar the tokens are for
public function tokens(list<Lexeme> $lexemes, string $source): list<Token>

Turns lexemes into tokens and closes the stream with the end marker.

Parameters

$lexemeslist<Lexeme>Lexemes in text order
$sourcestringThe SQL text, for error positions

Returns

list<Token> The tokens, the end marker last

Throws

LexicalException When a lexeme names a terminal the grammar lacks
Test cases 2
Called from 3
Calls 5
public function token(Lexeme $lexeme, string $source, string $leading = ''): Token

Turns one lexeme into a token.

Parameters

$lexemeLexemeLexeme to number
$sourcestringThe SQL text, for error positions
$leadingstringWhitespace and comments written before the lexeme

Returns

Token The token

Throws

LexicalException When the lexeme names a terminal the grammar lacks
Test cases 3
Called from 1
Calls 4

Private surface 1§

Implementation details, listed for orientation only.

private SymbolTable $symbols

Test cases 8§

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

Dedicated tests 5
Other tests reaching this symbol 3

Relations§

Instantiated in 3
Method calls 3