classKeywordTable
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
$keywords | array<string, string> | Terminal name by upper-cased keyword or operator |
$functions | array<string, string> | Terminal name by upper-cased function name |
public static function load(string $path): selfLoads the table generated for one release.
Parameters
$path | string | Keyword resource file |
Returns
self The tableThrows
RuntimeException When the file is missing or malformedTest cases 6
Called from 1
public function lookup(string $word, bool $function, SqlMode $mode): string|nullAnswers the terminal a word or operator stands for, if it is a keyword.
Parameters
$word | string | Word or operator as written |
$function | bool | Whether a parenthesis follows, so function names count too |
$mode | SqlMode | Mode deciding `NOT` and `||` |
Returns
string|null Terminal name, or null for an identifierTest cases 2
Calls 1
- function-call
strtoupperline 63
public function has(string $word): boolReports whether the release knows a keyword or operator at all.
Parameters
$word | string | Word or operator as written |
Returns
bool True when it is a keyword, in any lookupTest cases 1
Calls 1
- function-call
strtoupperline 84
Private surface 2§
Implementation details, listed for orientation only.
private array<string, string> $keywordsprivate array<string, string> $functionsTest 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
MySqlLexerTest::testMergedcallsMySqlLexerTest::testNextcallsMySqlLexerTest::testScanReadsAnEmptyHostNameAsTheServerDoescallsMySqlLexerTest::testScanReadsAStatementIntoTerminalscallsMySqlLexerTest::testScanRejectsAnUnreadableCharactercallsNumberScannerTest::testFractioncallsNumberScannerTest::testScancallsNumberScannerTest::testScanNotesAQualifiedIdentifierThatStartsWithADigitcallsOperatorScannerTest::testMultiCharactercallsOperatorScannerTest::testScancallsOperatorScannerTest::testScanRejectsAForeignCharactercallsOperatorScannerTest::testScanRejectsAParameterMarkerGluedToANamecallsOperatorScannerTest::testSeparatorcallsQuotedScannerTest::testQuotedIdentifiercallsQuotedScannerTest::testQuotedIdentifierRejectsAnUnterminatedIdentifiercallsQuotedScannerTest::testScanReadsPrefixedLiteralscallsQuotedScannerTest::testScanReadsStringsAndIdentifierscallsQuotedScannerTest::testScanRejectsAnOddHexadecimalLiteralcallsQuotedScannerTest::testStringcallsQuotedScannerTest::testStringRejectsAnUnterminatedStringcallsScanTest::testLexemecallsTriviaScannerTest::testBlockCommentcallsTriviaScannerTest::testBlockCommentRejectsAnUnterminatedCommentcallsTriviaScannerTest::testSkipDropsAVersionCommentForANewerReleasecallsTriviaScannerTest::testSkipPassesWhitespaceAndCommentscallsTriviaScannerTest::testSkipReadsAVersionCommentBodyAsSqlcallsVariableScannerTest::testAtcallsVariableScannerTest::testHostnamecallsVariableScannerTest::testIdentifierOrKeywordcallsVariableScannerTest::testIdentifierOrKeywordRejectsAMissingNamecallsVariableScannerTest::testSystemVariablecallsWordScannerTest::testDollarQuotedcallsWordScannerTest::testDollarQuotedRejectsAnUnterminatedStringcallsWordScannerTest::testIdentifiercallsWordScannerTest::testIdentifierLexemecallsWordScannerTest::testScancallsWordScannerTest::testWordKeepsAKeywordBeforeADotAsAnIdentifiercallsWordScannerTest::testWordLooksUpFunctionsAcrossSpacesUnderIgnoreSpacecallsMySqlParserTestcalls