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

The words and operators MySQL's lexer turns into keyword tokens.

Function names are keywords only when a parenthesis follows them at once, which is what lets a column be called count. Two lookups depend on the SQL mode: NOT binds tightly under HIGH_NOT_PRECEDENCE, and || is OR unless PIPES_AS_CONCAT makes it concatenation.

Methods§

public function __construct(
    private array<string, string> $keywords,
    private array<string, string> $functions,
)

Parameters

$keywordsarray<string, string>Terminal name by upper-cased keyword or operator
$functionsarray<string, string>Terminal name by upper-cased function name
public static function load(string $path): self

Loads the table generated for one release.

Parameters

$pathstringKeyword resource file

Returns

self The table

Throws

RuntimeException When the file is missing or malformed
Test cases 6
Called from 1
Calls 3
public function lookup(string $word, bool $function, SqlMode $mode): string|null

Answers the terminal a word or operator stands for, if it is a keyword.

Parameters

$wordstringWord or operator as written
$functionboolWhether a parenthesis follows, so function names count too
$modeSqlModeMode deciding `NOT` and `||`

Returns

string|null Terminal name, or null for an identifier
Test cases 2
Calls 1
public function has(string $word): bool

Reports whether the release knows a keyword or operator at all.

Parameters

$wordstringWord or operator as written

Returns

bool True when it is a keyword, in any lookup
Test cases 1
Calls 1

Private surface 2§

Implementation details, listed for orientation only.

private array<string, string> $keywords
private array<string, string> $functions

Test cases 44§

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 39

Relations§

Static calls 1
Type declarations 2