classLiteralRule
final class LiteralRule
Lowers the literal productions of every release into exact values.
Rule: MYSQL-LITERAL-001. Scope: literal, literal_or_null, null_as_literal, signed_literal, signed_literal_or_null, text_literal, NUM_literal, int64_literal, temporal_literal, param_marker, text_string, TEXT_STRING_sys, TEXT_STRING_sys_nonewline, TEXT_STRING_literal, TEXT_STRING_filesystem, TEXT_STRING_password, TEXT_STRING_hash, TEXT_STRING_validated, TEXT_STRING_sys_list, json_attribute. A quoted string is decoded by MYSQL-STRING-DECODE-001 under the escape setting of the profile; adjacent strings are the segments of one literal; an introducer or the national prefix belongs to the literal. A number keeps its exact text, a hexadecimal or bit literal its digits whatever its spelling. At an expression position the result is a scalar; at any other position it is a text operand. Every value is recorded as an operand leaf. Constructs: StringLiteral, NumberLiteral, RadixLiteral, NullLiteral, BooleanLiteral, TemporalLiteral, SignedLiteral, Parameter, Text. Terminates: the segment list is walked along its spine in a loop; every other child is a strict subtree. Source: https://dev.mysql.com/doc/refman/8.4/en/literals.html. Status: Implemented.
Methods§
public function __construct(private Lowering $lowering)Parameters
$lowering | Lowering | The lowering this rule belongs to |
public function escapes(): EscapeRuleAnswers the escape rule of the profile.
Returns
Test cases 1
Called from 6
- method-call SqlSemantics\Platform\MySql\Lowering\Leaf\LiteralRule::literal() packages/sql-semantics-mysql/src/Lowering/Leaf/LiteralRule.php:131
- method-call SqlSemantics\Platform\MySql\Lowering\Leaf\LiteralRule::string() packages/sql-semantics-mysql/src/Lowering/Leaf/LiteralRule.php:196
- method-call SqlSemantics\Platform\MySql\Lowering\Leaf\LiteralRule::string() packages/sql-semantics-mysql/src/Lowering/Leaf/LiteralRule.php:197
- method-call SqlSemantics\Platform\MySql\Lowering\Leaf\LiteralRule::string() packages/sql-semantics-mysql/src/Lowering/Leaf/LiteralRule.php:198
- method-call SqlSemantics\Platform\MySql\Lowering\Leaf\LiteralRule::text() packages/sql-semantics-mysql/src/Lowering/Leaf/LiteralRule.php:247
- method-call SqlSemantics\Platform\MySql\Lowering\Leaf\LiteralRule::text() packages/sql-semantics-mysql/src/Lowering/Leaf/LiteralRule.php:250
Calls 1
- static-call EscapeRule::under() line 113
Lowers a literal at an expression position.
Parameters
$literal | Node |
Returns
Throws
ImplementationGap When the production has no ruleCalls 9
- class-const LiteralRule::FORWARD() line 124
- class-const LiteralRule::NUMBERS() line 127
- new NumberLiteral line 128
- class-const LiteralRule::TEMPORAL() line 130
- new TemporalLiteral line 131
- method-call LiteralRule::decode() line 131
- method-call LiteralRule::escapes() line 131
- method-call LiteralRule::string() line 134
- method-call LiteralRule::constant() line 137
Lowers the keyword, signed, hexadecimal and bit literal productions.
Parameters
$form | Form |
Returns
Throws
ImplementationGap When the production has no ruleCalled from 1
Calls 13
- new RadixSpelling line 147
- new NullLiteral line 150
- new BooleanLiteral line 151
- new RadixLiteral line 153
- class-const Radix::Hexadecimal() line 153
- method-call RadixSpelling::digits() line 153
- method-call Form::token() line 153
- class-const Radix::Bit() line 154
- method-call LiteralRule::introducer() line 155
- new SignedLiteral line 157
- method-call LiteralRule::number() line 157
- method-call Form::node() line 157
- static-call ImplementationGap::production() line 159
public function number(Node $number): NumberLiteralLowers an unsigned number literal.
Parameters
$number | Node |
Returns
Throws
ImplementationGap When the production has no ruleTest cases 1
Called from 2
Calls 4
- class-const LiteralRule::FORWARD() line 171
- class-const LiteralRule::NUMBERS() line 174
- static-call ImplementationGap::production() line 175
- new NumberLiteral line 178
public function string(Node $literal): StringLiteralLowers a character string literal with its adjacent segments, introducer and national prefix.
Parameters
$literal | Node |
Returns
Throws
ImplementationGap When a production has no ruleCalled from 1
Calls 7
- function-call
array_unshiftline 191 - method-call LiteralRule::bytes() line 191
- new StringLiteral line 196
- method-call LiteralRule::decode() line 196
- method-call LiteralRule::escapes() line 196
- method-call LiteralRule::introducer() line 198
- static-call ImplementationGap::production() line 199
Answers the character set the introducer at the first position names.
Parameters
$form | Form |
Returns
Test cases 1
Called from 3
- method-call SqlSemantics\Platform\MySql\Lowering\Leaf\LiteralRule::constant() packages/sql-semantics-mysql/src/Lowering/Leaf/LiteralRule.php:155
- method-call SqlSemantics\Platform\MySql\Lowering\Leaf\LiteralRule::constant() packages/sql-semantics-mysql/src/Lowering/Leaf/LiteralRule.php:156
- method-call SqlSemantics\Platform\MySql\Lowering\Leaf\LiteralRule::string() packages/sql-semantics-mysql/src/Lowering/Leaf/LiteralRule.php:198
Calls 4
- new Name line 208
- method-call Introducers::charset() line 208
- new Introducers line 208
- method-call Form::token() line 208
public function decode(string $token): stringDecodes a quoted string token under the escape setting of the profile.
Parameters
$token | string |
Returns
stringTest cases 1
Called from 5
- method-call SqlSemantics\Platform\MySql\Lowering\Leaf\LiteralRule::literal() packages/sql-semantics-mysql/src/Lowering/Leaf/LiteralRule.php:131
- method-call SqlSemantics\Platform\MySql\Lowering\Leaf\LiteralRule::string() packages/sql-semantics-mysql/src/Lowering/Leaf/LiteralRule.php:196
- method-call SqlSemantics\Platform\MySql\Lowering\Leaf\LiteralRule::string() packages/sql-semantics-mysql/src/Lowering/Leaf/LiteralRule.php:197
- method-call SqlSemantics\Platform\MySql\Lowering\Leaf\LiteralRule::string() packages/sql-semantics-mysql/src/Lowering/Leaf/LiteralRule.php:198
- method-call SqlSemantics\Platform\MySql\Lowering\Leaf\LiteralRule::bytes() packages/sql-semantics-mysql/src/Lowering/Leaf/LiteralRule.php:234
Calls 2
- method-call Strings::decode() line 216
- new Strings line 216
public function bytes(Node $string): stringAnswers the decoded bytes of a string rule without recording a leaf.
Parameters
$string | Node |
Returns
stringThrows
ImplementationGap When the production has no ruleTest cases 1
Called from 2
Calls 4
- class-const LiteralRule::STRING_FORWARD() line 227
- class-const LiteralRule::STRINGS() line 230
- static-call ImplementationGap::production() line 231
- method-call LiteralRule::decode() line 234
Lowers a string at a position that is not an expression.
Parameters
$string | Node |
Returns
Throws
ImplementationGap When the production has no ruleTest cases 1
Called from 1
Calls 6
- class-const LiteralRule::RADIX_TEXT() line 245
- new Text line 247
- method-call RadixSpelling::digits() line 247
- new RadixSpelling line 247
- method-call LiteralRule::escapes() line 247
- method-call LiteralRule::bytes() line 250
Lowers a comma-separated list of strings.
Parameters
$list | Node |
Returns
list<Text>Throws
ImplementationGap When a production has no ruleTest cases 1
Calls 5
- function-call
in_arrayline 262 - static-call ImplementationGap::production() line 263
- method-call Lists::items() line 266
- new Lists line 266
- method-call LiteralRule::text() line 267
Lowers a parameter marker.
Parameters
$marker | Node |
Returns
Throws
ImplementationGap When the production has no ruleCalls 2
- static-call ImplementationGap::production() line 282
- new Parameter line 285
Private surface 7§
Implementation details, listed for orientation only.
private const FORWARD = ['literal: text_literal' => true, 'literal: NUM_literal' => true, 'literal: tem…private const NUMBERS = ['NUM_literal: NUM' => true, 'NUM_literal: LONG_NUM' => true, 'NUM_literal: ULO…private const TEMPORAL = ['temporal_literal: DATE_SYM TEXT_STRING' => \SqlSemantics\Platform\MySql\State…private const STRINGS = ['TEXT_STRING_sys: TEXT_STRING' => true, 'TEXT_STRING_literal: TEXT_STRING' => …private const STRING_FORWARD = ['TEXT_STRING_sys_nonewline: TEXT_STRING_sys' => true, 'TEXT_STRING_hash: TEXT_…private const RADIX_TEXT = ['TEXT_STRING_hash: HEX_NUM' => \SqlSemantics\Platform\MySql\Statement\Literal\…private Lowering $loweringTest cases 8§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 8
LiteralRuleTest::testBytesDecodesAStringRuleWithoutRecordingALeafcallsLiteralRuleTest::testConstantLowersIntroducedRadixLiteralsAndSignedNumberscallsLiteralRuleTest::testDecodeFollowsTheEscapeSettingOfTheProfilecallsLiteralRuleTest::testEscapesFollowsTheProfilecallsLiteralRuleTest::testIntroducerNamesTheCharacterSetInLowerCasecallsLiteralRuleTest::testNumberLowersAnUnsignedNumbercallsLiteralRuleTest::testTextLowersStringsAtPositionsThatAreNotExpressionscallsLiteralRuleTest::testTextsFlattensAStringListcalls