classNumberScanner
final class NumberScanner
Restricted visibility: declared "@visibility root". Code outside that scope must not name this declaration.
Reads PostgreSQL's numeric literals and positional parameters.
An integer that fits in 32 bits is ICONST and any other number is FCONST, whatever its base. A digit followed by a letter, and a parameter followed by one, are the trailing junk the scanner rejects.
Methods§
Reads the number or parameter at the cursor, if one starts there.
Parameters
$scan | Scan | The tokenization in progress |
Returns
Lexeme|null The lexeme, or null when no number starts hereThrows
LexicalException When the literal is malformed or followed by junkTest cases 4
Called from 1
Calls 6
- method-call NumberScanner::rejectJunk() line 36
- method-call Scan::lexeme() line 38
- static-call NumberScanner::fitsInt32() line 44
- static-call LexicalException::unexpectedCharacter() line 47
- function-call
preg_matchline 60 - function-call
str_containsline 60
public function rejectJunk(Scan $scan, int $start): voidRejects an identifier character right after a literal.
Parameters
$scan | Scan | The tokenization in progress, positioned after the literal |
$start | int | Offset the literal began at |
Throws
LexicalException When junk followsTest cases 1
Called from 3
- method-call SqlParser\PostgreSql\Lexer\NumberScanner::scan() packages/sql-parser/src/PostgreSql/Lexer/NumberScanner.php:36
- method-call SqlParser\PostgreSql\Lexer\NumberScanner::scan() packages/sql-parser/src/PostgreSql/Lexer/NumberScanner.php:42
- method-call SqlParser\PostgreSql\Lexer\NumberScanner::scan() packages/sql-parser/src/PostgreSql/Lexer/NumberScanner.php:59
Calls 2
- static-call Scan::startsIdentifier() line 75
- static-call LexicalException::unexpectedCharacter() line 76
public static function fitsInt32(string $literal): boolReports whether an integer literal, in any base, fits in a signed 32-bit integer.
Parameters
$literal | string | The literal as written, underscores included |
Returns
bool True when it fitsTest cases 1
Called from 2
Test cases 8§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 6
Other tests reaching this symbol 2
PostgreSqlLexerTestcallsPostgreSqlParserTestcalls