final class QuotedScanner
Restricted visibility: declared "@visibility root". Code outside that scope must not name this declaration.

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§

public function scan(Scan $scan): Lexeme|null

Reads the quoted token at the cursor, if one starts there.

Parameters

$scanScanThe tokenization in progress

Returns

Lexeme|null The lexeme, or null when no quoted token starts here

Throws

LexicalException When the token never closes or a quoted identifier is empty
Test cases 2
Called from 1
Calls 6
public function string(
    Scan $scan,
    string $name,
    int $start,
    bool $escapes,
    bool $doubling = true,
): Lexeme

Reads a string whose opening quote is at the cursor, with any continuations.

Parameters

$scanScanThe tokenization in progress, positioned on the opening quote
$namestringTerminal the string stands for
$startintOffset the lexeme began at, before any prefix
$escapesboolWhether a backslash escapes the next character
$doublingboolWhether a doubled quote stands for a quote inside the string

Returns

Lexeme The lexeme

Throws

LexicalException When the string never closes
Test cases 2
Called from 5
Calls 3
public function body(Scan $scan, int $start, bool $escapes, bool $doubling): void

Consumes the body of a string up to and including its closing quote.

Parameters

$scanScanThe tokenization in progress, positioned after the opening quote
$startintOffset the lexeme began at, for the error
$escapesboolWhether a backslash escapes the next character
$doublingboolWhether a doubled quote stands for a quote inside the string

Throws

LexicalException When the string never closes
Test cases 1
Called from 1
Calls 1
public function identifier(Scan $scan, string $name, int $start): Lexeme

Reads a double-quoted identifier.

Parameters

$scanScanThe tokenization in progress, positioned on the opening quote
$namestringTerminal the identifier stands for
$startintOffset the lexeme began at, before any prefix

Returns

Lexeme The lexeme

Throws

LexicalException When the identifier never closes or is empty
Test cases 3
Called from 2
Calls 3
public function dollarQuoted(Scan $scan): Lexeme|null

Reads a dollar-quoted string, if one starts at the cursor.

Parameters

$scanScanThe tokenization in progress

Returns

Lexeme|null The lexeme, or null when no dollar-quoted string starts here

Throws

LexicalException When the string never closes
Test cases 2
Called from 1
Calls 4

Test cases 12§

Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.

Dedicated tests 10
Other tests reaching this symbol 2

Relations§

Instantiated in 1
Method calls 1
Type declarations 1