classLeafKeys
final class LeafKeys
implements LeafKeys
Maps PostgreSQL tokens to comparison keys for the token correspondence check.
Rule: PG-LEAF-KEY-001. An identifier, and a keyword read through one of the keyword-category nonterminals, is keyed by its decoded name. A string constant is keyed by its decoded value, a bit string by its notation and digits, an integer constant by its value, a numeric constant (FCONST) by its exact text, which the server keeps as the value (PG-LEX-NUMBER-001), a parameter by its canonical marker, an operator by its text. Every other token is keyed by its terminal; the lookahead variants the parser's token filter introduces (NOT_LA, WITH_LA, WITHOUT_LA, NULLS_LA, FORMAT_LA) are the same word as their base keyword and share its key. The noise positions are the union of the family tables. Status: Implemented.
Methods§
public function key(Token $token, string $signature, int $position): ?stringAnswers the comparison key of a token, or null when the token is declared noise.
Parameters
$token | Token | |
$signature | string | |
$position | int |
Returns
?stringTest cases 5
Calls 16
- function-call
in_arrayline 57 - method-call LeafKeys::noise() line 57
- function-call
substrline 60 - function-call
strposline 60 - class-const Keywords::CATEGORIES() line 60
- method-call Identifiers::fold() line 61
- new Identifiers line 61
- method-call Identifiers::decode() line 65
- method-call Strings::decode() line 66
- new Strings line 66
- method-call Strings::digits() line 67
- method-call Numerals::decimal() line 69
- new Numerals line 69
- function-call
str_starts_withline 71 - method-call Numerals::canonical() line 71
- class-const LeafKeys::LOOKAHEAD() line 73
public function noise(): array<string, list<int>>Answers the noise positions of every family by production signature.
Returns
array<string, list<int>>Test cases 1
Called from 1
Calls 11
- static-call LeafNoise::positions() line 84
- static-call TypesNoise::positions() line 84
- static-call ExpressionNoise::positions() line 84
- static-call InvocationNoise::positions() line 84
- static-call QueryNoise::positions() line 85
- static-call ManipulationNoise::positions() line 85
- static-call TableNoise::positions() line 85
- static-call CatalogNoise::positions() line 85
- static-call RoutineNoise::positions() line 86
- static-call AccessNoise::positions() line 86
- static-call UtilityNoise::positions() line 86
Private surface 2§
Implementation details, listed for orientation only.
private const LOOKAHEAD = ['NOT_LA' => 'NOT', 'WITH_LA' => 'WITH', 'WITHOUT_LA' => 'WITHOUT', 'NULLS_LA' …private static array<string, list<int>>|null $noise = nullTest cases 6§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 6
LeafKeysTest::testKeyDecodesConstantscallsLeafKeysTest::testKeyDecodesIdentifiersAndKeywordsUsedAsNamescallsLeafKeysTest::testKeyGivesALookaheadTerminalTheKeyOfItsKeywordcallsLeafKeysTest::testKeyIsNullForNoiseAndForTheEndMarkercallsLeafKeysTest::testKeyKeepsTheExactTextOfANumericConstantcallsLeafKeysTest::testNoiseMergesTheFamilyTablescalls