classNumerals
final class Numerals
Reads the exact value of a PostgreSQL numeric constant token without floating point.
Rule: PG-LEX-NUMBER-001. Scope: the ICONST and FCONST terminals. A constant written as an integer, in decimal, hexadecimal (0x), octal (0o) or binary (0b) digits with optional underscores between digits, is the integer it denotes whatever its size. The scanner makes it an ICONST holding that integer when it fits 32 bits (process_integer_literal in scan.l); otherwise, and for every constant written with a decimal point or an exponent, it makes an FCONST that holds the written text itself (a T_Float node keeps the string), because the parser does not yet know the type the value is read as. Commands such as SET, storage parameters and trigger arguments receive that text verbatim, so 1e2 and 100. are different values there. Source: https://www.postgresql.org/docs/17/sql-syntax-lexical.html#SQL-SYNTAX-CONSTANTS-NUMERIC, process_integer_literal and the {numeric}, {real} rules of src/backend/parser/scan.l of PostgreSQL 17. Termination: one pass over the digits per conversion step. Status: Implemented.
Methods§
public function integral(string $text): boolTells whether a numeric token is written as an integer.
Parameters
$text | string |
Returns
boolTest cases 1
Called from 1
Calls 1
- function-call
preg_matchline 34
public function decimal(string $text): stringAnswers the canonical decimal digits of a constant written as an integer.
Parameters
$text | string |
Returns
stringTest cases 1
Called from 6
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Leaf\Literals::integer() packages/sql-semantics-postgres/src/Lowering/Leaf/Literals.php:101
- method-call SqlSemantics\Platform\PostgreSql\Rules\Access\ObjectIdentifiers::unsigned() packages/sql-semantics-postgres/src/Rules/Access/ObjectIdentifiers.php:87
- method-call SqlSemantics\Platform\PostgreSql\Rules\Access\ObjectIdentifiers::unsigned() packages/sql-semantics-postgres/src/Rules/Access/ObjectIdentifiers.php:88
- method-call SqlSemantics\Platform\PostgreSql\Rules\LeafKeys::key() packages/sql-semantics-postgres/src/Rules/LeafKeys.php:69
- method-call SqlSemantics\Platform\PostgreSql\Rules\Lexical\Numerals::integer() packages/sql-semantics-postgres/src/Rules/Lexical/Numerals.php:72
- method-call SqlSemantics\Platform\PostgreSql\Rules\Lexical\Numerals::kept() packages/sql-semantics-postgres/src/Rules/Lexical/Numerals.php:85
public function integer(string $text): ?stringAnswers the canonical decimal digits of the integer a constant written as an integer denotes, or null for one with a point or an exponent.
Parameters
$text | string |
Returns
?stringTest cases 1
Called from 2
- method-call SqlSemantics\Platform\PostgreSql\Rules\Expression\Typing\PrefixTyping::negative() packages/sql-semantics-postgres/src/Rules/Expression/Typing/PrefixTyping.php:63
- method-call SqlSemantics\Platform\PostgreSql\Statement\Literal\Constant::builtin() packages/sql-semantics-postgres/src/Statement/Literal/Constant.php:59
Calls 2
- method-call Numerals::integral() line 72
- method-call Numerals::decimal() line 72
public function kept(string $text): boolTells whether a text is one constant the scanner reads as an FCONST and keeps as written.
That is a decimal number with a point, an exponent or both, or an integer spelling whose value does not fit 32 bits.
Parameters
$text | string |
Returns
boolTest cases 1
Called from 1
Calls 3
- function-call
preg_matchline 84 - method-call Numerals::within() line 85
- method-call Numerals::decimal() line 85
public function canonical(string $digits): stringStrips leading zeros from decimal digits; no digits denote zero.
Parameters
$digits | string |
Returns
stringTest cases 1
Called from 6
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Leaf\Literals::parameter() packages/sql-semantics-postgres/src/Lowering/Leaf/Literals.php:167
- method-call SqlSemantics\Platform\PostgreSql\Rules\Access\ObjectIdentifiers::unsigned() packages/sql-semantics-postgres/src/Rules/Access/ObjectIdentifiers.php:89
- method-call SqlSemantics\Platform\PostgreSql\Rules\LeafKeys::key() packages/sql-semantics-postgres/src/Rules/LeafKeys.php:71
- method-call SqlSemantics\Platform\PostgreSql\Rules\Lexical\Numerals::decimal() packages/sql-semantics-postgres/src/Rules/Lexical/Numerals.php:45
- method-call SqlSemantics\Platform\PostgreSql\Rules\Lexical\Numerals::decimal() packages/sql-semantics-postgres/src/Rules/Lexical/Numerals.php:64
- method-call SqlSemantics\Platform\PostgreSql\Statement\Literal\Constant::integerValue() packages/sql-semantics-postgres/src/Statement/Literal/Constant.php:78
Calls 1
- function-call
ltrimline 96
public function within(string $digits, string $limit): boolTells whether canonical decimal digits denote a value not above a canonical limit.
Parameters
$digits | string | |
$limit | string |
Returns
boolTest cases 1
Called from 8
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Leaf\Literals::parameter() packages/sql-semantics-postgres/src/Lowering/Leaf/Literals.php:168
- method-call SqlSemantics\Platform\PostgreSql\Rules\Access\ObjectIdentifiers::problem() packages/sql-semantics-postgres/src/Rules/Access/ObjectIdentifiers.php:76
- method-call SqlSemantics\Platform\PostgreSql\Rules\Expression\Typing\PrefixTyping::negative() packages/sql-semantics-postgres/src/Rules/Expression/Typing/PrefixTyping.php:67
- method-call SqlSemantics\Platform\PostgreSql\Rules\Expression\Typing\PrefixTyping::negative() packages/sql-semantics-postgres/src/Rules/Expression/Typing/PrefixTyping.php:71
- method-call SqlSemantics\Platform\PostgreSql\Rules\Lexical\Numerals::kept() packages/sql-semantics-postgres/src/Rules/Lexical/Numerals.php:85
- method-call SqlSemantics\Platform\PostgreSql\Statement\Invocation\Syntax\ValueFunction::deriveScalar() packages/sql-semantics-postgres/src/Statement/Invocation/Syntax/ValueFunction.php:83
- method-call SqlSemantics\Platform\PostgreSql\Statement\Literal\Constant::builtin() packages/sql-semantics-postgres/src/Statement/Literal/Constant.php:61
- method-call SqlSemantics\Platform\PostgreSql\Statement\Literal\IntegerConstant::__construct() packages/sql-semantics-postgres/src/Statement/Literal/IntegerConstant.php:40
Test cases 6§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 6
NumeralsTest::testCanonicalStripsLeadingZeroscallsNumeralsTest::testDecimalConvertsEveryBaseExactlycallsNumeralsTest::testIntegerReadsOnlyIntegerSpellingscallsNumeralsTest::testIntegralTellsIntegerSpellingsFromNumericOnescallsNumeralsTest::testKeptTellsTheTextsTheScannerKeepsAsFconstcallsNumeralsTest::testWithinComparesCanonicalDigitscalls
Relations§
Instantiated in 13
- new SqlSemantics\Platform\PostgreSql\Lowering\Leaf\Literals::integer() packages/sql-semantics-postgres/src/Lowering/Leaf/Literals.php:101
- new SqlSemantics\Platform\PostgreSql\Lowering\Leaf\Literals::parameter() packages/sql-semantics-postgres/src/Lowering/Leaf/Literals.php:166
- new SqlSemantics\Platform\PostgreSql\Rules\Access\ObjectIdentifiers::problem() packages/sql-semantics-postgres/src/Rules/Access/ObjectIdentifiers.php:76
- new SqlSemantics\Platform\PostgreSql\Rules\Access\ObjectIdentifiers::unsigned() packages/sql-semantics-postgres/src/Rules/Access/ObjectIdentifiers.php:84
- new SqlSemantics\Platform\PostgreSql\Rules\Expression\Typing\PrefixTyping::negative() packages/sql-semantics-postgres/src/Rules/Expression/Typing/PrefixTyping.php:62
- new SqlSemantics\Platform\PostgreSql\Rules\LeafKeys::key() packages/sql-semantics-postgres/src/Rules/LeafKeys.php:69
- new SqlSemantics\Platform\PostgreSql\Rules\LeafKeys::key() packages/sql-semantics-postgres/src/Rules/LeafKeys.php:71
- new SqlSemantics\Platform\PostgreSql\Statement\Invocation\Syntax\ValueFunction::deriveScalar() packages/sql-semantics-postgres/src/Statement/Invocation/Syntax/ValueFunction.php:83
- new SqlSemantics\Platform\PostgreSql\Statement\Literal\Constant::builtin() packages/sql-semantics-postgres/src/Statement/Literal/Constant.php:59
- new SqlSemantics\Platform\PostgreSql\Statement\Literal\Constant::builtin() packages/sql-semantics-postgres/src/Statement/Literal/Constant.php:61
- new SqlSemantics\Platform\PostgreSql\Statement\Literal\Constant::integerValue() packages/sql-semantics-postgres/src/Statement/Literal/Constant.php:78
- new SqlSemantics\Platform\PostgreSql\Statement\Literal\IntegerConstant::__construct() packages/sql-semantics-postgres/src/Statement/Literal/IntegerConstant.php:40
- new SqlSemantics\Platform\PostgreSql\Statement\Literal\NumericConstant::__construct() packages/sql-semantics-postgres/src/Statement/Literal/NumericConstant.php:44
Method calls 18
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Leaf\Literals::integer() packages/sql-semantics-postgres/src/Lowering/Leaf/Literals.php:101
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Leaf\Literals::parameter() packages/sql-semantics-postgres/src/Lowering/Leaf/Literals.php:167
- method-call SqlSemantics\Platform\PostgreSql\Lowering\Leaf\Literals::parameter() packages/sql-semantics-postgres/src/Lowering/Leaf/Literals.php:168
- method-call SqlSemantics\Platform\PostgreSql\Rules\Access\ObjectIdentifiers::problem() packages/sql-semantics-postgres/src/Rules/Access/ObjectIdentifiers.php:76
- method-call SqlSemantics\Platform\PostgreSql\Rules\Access\ObjectIdentifiers::unsigned() packages/sql-semantics-postgres/src/Rules/Access/ObjectIdentifiers.php:87
- method-call SqlSemantics\Platform\PostgreSql\Rules\Access\ObjectIdentifiers::unsigned() packages/sql-semantics-postgres/src/Rules/Access/ObjectIdentifiers.php:88
- method-call SqlSemantics\Platform\PostgreSql\Rules\Access\ObjectIdentifiers::unsigned() packages/sql-semantics-postgres/src/Rules/Access/ObjectIdentifiers.php:89
- method-call SqlSemantics\Platform\PostgreSql\Rules\Expression\Typing\PrefixTyping::negative() packages/sql-semantics-postgres/src/Rules/Expression/Typing/PrefixTyping.php:63
- method-call SqlSemantics\Platform\PostgreSql\Rules\Expression\Typing\PrefixTyping::negative() packages/sql-semantics-postgres/src/Rules/Expression/Typing/PrefixTyping.php:67
- method-call SqlSemantics\Platform\PostgreSql\Rules\Expression\Typing\PrefixTyping::negative() packages/sql-semantics-postgres/src/Rules/Expression/Typing/PrefixTyping.php:71
- method-call SqlSemantics\Platform\PostgreSql\Rules\LeafKeys::key() packages/sql-semantics-postgres/src/Rules/LeafKeys.php:69
- method-call SqlSemantics\Platform\PostgreSql\Rules\LeafKeys::key() packages/sql-semantics-postgres/src/Rules/LeafKeys.php:71
- method-call SqlSemantics\Platform\PostgreSql\Statement\Invocation\Syntax\ValueFunction::deriveScalar() packages/sql-semantics-postgres/src/Statement/Invocation/Syntax/ValueFunction.php:83
- method-call SqlSemantics\Platform\PostgreSql\Statement\Literal\Constant::builtin() packages/sql-semantics-postgres/src/Statement/Literal/Constant.php:59
- method-call SqlSemantics\Platform\PostgreSql\Statement\Literal\Constant::builtin() packages/sql-semantics-postgres/src/Statement/Literal/Constant.php:61
- method-call SqlSemantics\Platform\PostgreSql\Statement\Literal\Constant::integerValue() packages/sql-semantics-postgres/src/Statement/Literal/Constant.php:78
- method-call SqlSemantics\Platform\PostgreSql\Statement\Literal\IntegerConstant::__construct() packages/sql-semantics-postgres/src/Statement/Literal/IntegerConstant.php:40
- method-call SqlSemantics\Platform\PostgreSql\Statement\Literal\NumericConstant::__construct() packages/sql-semantics-postgres/src/Statement/Literal/NumericConstant.php:44