classQuotedScanner
final class QuotedScanner
Reads PostgreSQL's quoted tokens: strings in their six spellings and quoted identifiers.
Two quoted strings separated by whitespace that holds a newline are one string, as the standard requires. A string with escapes, E'...', lets a backslash escape the next character; the others double a quote to write it. A bit string, a hexadecimal string, a Unicode string and a dollar-quoted string each have a spelling of their own.
Constants§
public const CONTINUATION = '(?:[ \t\f\v]|--[^\n\r]*)*[\n\r](?:[ \t\n\r\f\v]+|--[^\n\r]*[\n\r])*\''Whitespace with a newline in it, followed by the quote that continues a string.
Methods§
Reads the quoted token at the cursor, if one starts there.
Parameters
$scan | Scan | The tokenization in progress |
Returns
Lexeme|null The lexeme, or null when no quoted token starts hereThrows
LexicalException When the token never closes or a quoted identifier is emptyTest cases 2
Called from 1
Calls 6
- method-call QuotedScanner::string() line 43
- method-call QuotedScanner::identifier() line 46
- function-call
strtoupperline 51 - function-call
str_ends_withline 52 - method-call Scan::lexeme() line 66
- method-call QuotedScanner::dollarQuoted() line 69
public function string(
Scan $scan,
string $name,
int $start,
bool $escapes,
bool $doubling = true,
): LexemeReads a string whose opening quote is at the cursor, with any continuations.
Parameters
$scan | Scan | The tokenization in progress, positioned on the opening quote |
$name | string | Terminal the string stands for |
$start | int | Offset the lexeme began at, before any prefix |
$escapes | bool | Whether a backslash escapes the next character |
$doubling | bool | Whether a doubled quote stands for a quote inside the string |
Returns
Lexeme The lexemeThrows
LexicalException When the string never closesTest cases 2
Called from 5
- method-call SqlParser\PostgreSql\Lexer\QuotedScanner::scan() packages/sql-parser/src/PostgreSql/Lexer/QuotedScanner.php:43
- method-call SqlParser\PostgreSql\Lexer\QuotedScanner::scan() packages/sql-parser/src/PostgreSql/Lexer/QuotedScanner.php:57
- method-call SqlParser\PostgreSql\Lexer\QuotedScanner::scan() packages/sql-parser/src/PostgreSql/Lexer/QuotedScanner.php:58
- method-call SqlParser\PostgreSql\Lexer\QuotedScanner::scan() packages/sql-parser/src/PostgreSql/Lexer/QuotedScanner.php:59
- method-call SqlParser\PostgreSql\Lexer\QuotedScanner::scan() packages/sql-parser/src/PostgreSql/Lexer/QuotedScanner.php:60
Calls 3
- method-call QuotedScanner::body() line 90
- class-const QuotedScanner::CONTINUATION() line 91
- method-call Scan::lexeme() line 92
public function body(Scan $scan, int $start, bool $escapes, bool $doubling): voidConsumes the body of a string up to and including its closing quote.
Parameters
$scan | Scan | The tokenization in progress, positioned after the opening quote |
$start | int | Offset the lexeme began at, for the error |
$escapes | bool | Whether a backslash escapes the next character |
$doubling | bool | Whether a doubled quote stands for a quote inside the string |
Throws
LexicalException When the string never closesTest cases 1
Called from 1
Calls 1
- static-call LexicalException::unterminated() line 125
Reads a double-quoted identifier.
Parameters
$scan | Scan | The tokenization in progress, positioned on the opening quote |
$name | string | Terminal the identifier stands for |
$start | int | Offset the lexeme began at, before any prefix |
Returns
Lexeme The lexemeThrows
LexicalException When the identifier never closes or is emptyTest cases 3
Called from 2
Calls 3
- static-call LexicalException::unterminated() line 144
- static-call LexicalException::unexpectedCharacter() line 147
- method-call Scan::lexeme() line 150
Reads a dollar-quoted string, if one starts at the cursor.
Parameters
$scan | Scan | The tokenization in progress |
Returns
Lexeme|null The lexeme, or null when no dollar-quoted string starts hereThrows
LexicalException When the string never closesTest cases 2
Called from 1
Calls 4
- function-call
strposline 170 - static-call LexicalException::unterminated() line 172
- function-call
strlenline 174 - method-call Scan::lexeme() line 176
Test cases 12§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 10
QuotedScannerTest::testBodycallsQuotedScannerTest::testDollarQuotedcallsQuotedScannerTest::testDollarQuotedRejectsAnUnterminatedStringcallsQuotedScannerTest::testIdentifiercallsQuotedScannerTest::testIdentifierRejectsAnEmptyIdentifiercallsQuotedScannerTest::testIdentifierRejectsAnUnterminatedIdentifiercallsQuotedScannerTest::testScanReadsEverySpellingOfAStringcallsQuotedScannerTest::testScanReadsTheNationalPrefixAsAKeywordcallsQuotedScannerTest::testStringcallsQuotedScannerTest::testStringRejectsAnUnterminatedStringcalls
Other tests reaching this symbol 2
PostgreSqlLexerTestcallsPostgreSqlParserTestcalls