classTerminalIndex
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
$symbols | SymbolTable | Symbols of the grammar the tokens are for |
Turns lexemes into tokens and closes the stream with the end marker.
Parameters
$lexemes | list<Lexeme> | Lexemes in text order |
$source | string | The SQL text, for error positions |
Returns
list<Token> The tokens, the end marker lastThrows
LexicalException When a lexeme names a terminal the grammar lacksTest cases 2
Called from 3
- method-call SqlParser\MySql\MySqlParser::tokenize() packages/sql-parser/src/MySql/MySqlParser.php:94
- method-call SqlParser\PostgreSql\PostgreSqlParser::tokenize() packages/sql-parser/src/PostgreSql/PostgreSqlParser.php:90
- method-call SqlParser\Sqlite\SqliteParser::tokenize() packages/sql-parser/src/Sqlite/SqliteParser.php:95
Calls 5
- method-call TerminalIndex::token() line 43
- function-call
substrline 43 - new Token line 46
- class-const SymbolTable::END() line 46
- function-call
strlenline 46
Turns one lexeme into a token.
Parameters
$lexeme | Lexeme | Lexeme to number |
$source | string | The SQL text, for error positions |
$leading | string | Whitespace and comments written before the lexeme |
Returns
Token The tokenThrows
LexicalException When the lexeme names a terminal the grammar lacksTest cases 3
Called from 1
Calls 4
- method-call SymbolTable::id() line 64
- method-call SymbolTable::isTerminal() line 65
- static-call LexicalException::unknownTerminal() line 66
- new Token line 69
Private surface 1§
Implementation details, listed for orientation only.
private SymbolTable $symbolsTest 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
MySqlParserTestcallsPostgreSqlParserTestcallsSqliteParserTestcalls
Relations§
Instantiated in 3
- new SqlParser\MySql\MySqlParser::tokenize() packages/sql-parser/src/MySql/MySqlParser.php:94
- new SqlParser\PostgreSql\PostgreSqlParser::tokenize() packages/sql-parser/src/PostgreSql/PostgreSqlParser.php:90
- new SqlParser\Sqlite\SqliteParser::tokenize() packages/sql-parser/src/Sqlite/SqliteParser.php:95
Method calls 3
- method-call SqlParser\MySql\MySqlParser::tokenize() packages/sql-parser/src/MySql/MySqlParser.php:94
- method-call SqlParser\PostgreSql\PostgreSqlParser::tokenize() packages/sql-parser/src/PostgreSql/PostgreSqlParser.php:90
- method-call SqlParser\Sqlite\SqliteParser::tokenize() packages/sql-parser/src/Sqlite/SqliteParser.php:95