classWordScanner
final class WordScanner
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|nullReads the word at the cursor, if one starts there.
Parameters
$scan | Scan | The tokenization in progress |
$trivia | TriviaScanner | Skips what lies between the word and the tokens looked at |
Returns
Lexeme|null The lexeme, or null when no word starts hereTest cases 1
Called from 1
Calls 2
- method-call WordScanner::contextual() line 41
- method-call Scan::lexeme() line 44
public function contextual(Scan $scan, string $name, TriviaScanner $trivia): stringDecides whether a context-dependent keyword is a keyword here.
Parameters
$scan | Scan | The tokenization in progress, positioned after the word |
$name | string | The keyword read |
$trivia | TriviaScanner | Skips what lies between the word and the tokens looked at |
Returns
string The keyword, or IDTest cases 1
Called from 1
Calls 2
- method-call Scan::last() line 58
- method-call WordScanner::ahead() line 59
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
$scan | Scan | The tokenization in progress |
$trivia | TriviaScanner | Skips what lies between tokens |
$count | int | How many tokens to look at |
Returns
list<string|null> Terminal names, null past the endTest cases 1
Called from 1
Calls 4
- new Scan line 84
- new Cursor line 84
- method-call TriviaScanner::skip() line 88
- method-call WordScanner::probe() line 89
public function probe(Scan $probe): stringReads 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
$probe | Scan | A scan positioned on the token |
Returns
string Terminal nameTest cases 1
Called from 1
Calls 4
- method-call WordScanner::skipQuoted() line 111
- function-call
in_arrayline 119 - class-const OperatorScanner::OPERATORS() line 134
- function-call
strlenline 136
public function skipQuoted(Cursor $cursor, string $quote): voidSkips a quoted run, or the rest of the text when it never closes.
Parameters
$cursor | Cursor | Reads the SQL text, positioned on the opening quote |
$quote | string | The quote character |
Test cases 1
Called from 2
Calls 3
- method-call Cursor::takeQuoted() line 154
- method-call Cursor::seek() line 155
- function-call
strlenline 155
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
SqliteLexerTestcallsSqliteParserTestcalls