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

Reads MySQL's words: keywords, identifiers, introducers and dollar-quoted strings.

A word followed at once by . and another word is an identifier whatever it spells, which is how a schema may be named after a keyword. Otherwise the word is looked up as a keyword, and as a function name too when a parenthesis follows it at once.

Methods§

public function scan(Scan $scan): Lexeme|null

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

Parameters

$scanScanThe tokenization in progress

Returns

Lexeme|null The lexeme, or null when no word starts here

Throws

LexicalException When a dollar-quoted string never closes
Test cases 1
Called from 1
Calls 4
public function word(Scan $scan, int $start): Lexeme

Reads a word that may be a keyword.

Parameters

$scanScanThe tokenization in progress, positioned on the word
$startintOffset the word began at

Returns

Lexeme The lexeme
Test cases 2
Called from 1
Calls 7
public function identifier(Scan $scan, int $start): Lexeme

Reads a word that is an identifier whatever it spells, as after ..

Parameters

$scanScanThe tokenization in progress, positioned on the word
$startintOffset the word began at

Returns

Lexeme The lexeme
Test cases 1
Called from 2
Calls 4
public function identifierLexeme(Scan $scan, int $start, string $text): Lexeme

Makes the identifier lexeme MySQL would, quoted when it holds non-ASCII bytes.

Parameters

$scanScanThe tokenization in progress
$startintOffset the identifier began at
$textstringThe identifier as written

Returns

Lexeme An IDENT or IDENT_QUOTED lexeme
Test cases 1
Called from 4
Calls 2
public function dollarQuoted(Scan $scan): Lexeme|null

Reads a dollar-quoted string, if one starts at the cursor.

Parameters

$scanScanThe tokenization in progress, positioned on the dollar sign

Returns

Lexeme|null The lexeme, or null when the dollar sign starts an identifier

Throws

LexicalException When the string never closes
Test cases 2
Called from 1
Calls 4

Test cases 14§

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

Dedicated tests 8
Other tests reaching this symbol 6

Relations§

Instantiated in 1
Method calls 5
Type declarations 3