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

Reads SQLite's identifiers and keywords, deciding the three keywords that depend on context.

WINDOW, OVER and FILTER cannot fall back to identifiers in the grammar, so the tokenizer decides for them by looking around: WINDOW is a keyword before a name and AS, OVER after a closing parenthesis and before a parenthesis or a name, FILTER after a closing parenthesis and before an opening one.

Methods§

public function scan(Scan $scan, TriviaScanner $trivia): Lexeme|null

Reads the word at the cursor, if one starts there.

Parameters

$scanScanThe tokenization in progress
$triviaTriviaScannerSkips what lies between the word and the tokens looked at

Returns

Lexeme|null The lexeme, or null when no word starts here
Test cases 1
Called from 1
Calls 2
public function contextual(Scan $scan, string $name, TriviaScanner $trivia): string

Decides whether a context-dependent keyword is a keyword here.

Parameters

$scanScanThe tokenization in progress, positioned after the word
$namestringThe keyword read
$triviaTriviaScannerSkips what lies between the word and the tokens looked at

Returns

string The keyword, or ID
Test cases 1
Called from 1
Calls 2
public function ahead(Scan $scan, TriviaScanner $trivia, int $count): list<string|null>

Names the next tokens without consuming them, identifiers of every spelling as ID.

Parameters

$scanScanThe tokenization in progress
$triviaTriviaScannerSkips what lies between tokens
$countintHow many tokens to look at

Returns

list<string|null> Terminal names, null past the end
Test cases 1
Called from 1
Calls 4
public function probe(Scan $probe): string

Reads one token of a look-ahead probe, as SQLite's own probe classifies it.

Anything that may serve as an identifier, a string included, counts as ID; every other token keeps its own name.

Parameters

$probeScanA scan positioned on the token

Returns

string Terminal name
Test cases 1
Called from 1
Calls 4
public function skipQuoted(Cursor $cursor, string $quote): void

Skips a quoted run, or the rest of the text when it never closes.

Parameters

$cursorCursorReads the SQL text, positioned on the opening quote
$quotestringThe quote character
Test cases 1
Called from 2
Calls 3

Test cases 7§

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 2

Relations§

Instantiated in 1
Method calls 1
Type declarations 1