final class SqlSymbolProfile

How one dialect spells what is written plainly.

Which characters may spell an identifier, how far a number runs, what nests, what brackets, and what ends a statement or separates a list are all asked here, because they are the shapes a scanner tells apart without knowing what any of them mean.

Methods§

public function __construct(
    private string $numericLiteralPattern,
    private string $identifierStartPattern,
    private string $identifierPartPattern,
    array{string, string}|null $bracketPair,
    array{string, string} $nestingPair,
    private string $statementDelimiter,
    private string $listDelimiter,
    private LexicalPattern $patterns = new \ZtdQuery\Sql\LexicalPattern(),
)

Parameters

$numericLiteralPatternstringPattern a number is written as
$identifierStartPatternstringPattern the first character of an identifier matches
$identifierPartPatternstringPattern every later character of an identifier matches
$bracketPairarray{string, string}|nullOpening and closing bracket, or null where the dialect has none
$nestingPairarray{string, string}Opening and closing delimiter that nest
$statementDelimiterstringSingle character that ends a statement
$listDelimiterstringSingle character that separates list items
$patternsLexicalPatternReads a regular expression against a position

Throws

InvalidDefinitionException When a pattern is unreadable, a delimiter is empty, or a single-character delimiter is not one character
Test cases 9
Calls 4
public function numberLengthAt(string $sql, int $offset): int

Answers how long the number starting here is.

Parameters

$sqlstringStatement being scanned
$offsetintPosition to look at

Returns

int Its length, or zero when no number starts there
Test cases 1
Called from 1
Calls 2
public function isIdentifierStart(string $character): bool

Reports whether an identifier may begin with this character.

Parameters

$characterstringCharacter to test

Returns

bool True when it may
Test cases 1
Called from 1
Calls 1
public function isIdentifierPart(string $character): bool
public function isBracketOpening(string $character): bool

Reports whether this character opens a bracket.

Parameters

$characterstringCharacter to test

Returns

bool True when it does, and false where the dialect brackets nothing
Test cases 1
Called from 1
public function isBracketClosing(string $character): bool

Reports whether this character closes a bracket.

Parameters

$characterstringCharacter to test

Returns

bool True when it does, and false where the dialect brackets nothing
Test cases 1
Called from 1
public function isNestingOpening(string $character): bool

Reports whether this character opens a nesting.

Parameters

$characterstringCharacter to test

Returns

bool True when it does
Test cases 1
Called from 1
public function isNestingClosing(string $character): bool

Reports whether this character closes a nesting.

Parameters

$characterstringCharacter to test

Returns

bool True when it does
Test cases 1
Called from 1
public function isStatementDelimiter(string $symbol): bool

Reports whether this symbol ends a statement.

Parameters

$symbolstringSymbol to test

Returns

bool True when it does
Test cases 1
Called from 1
public function listDelimiter(): string

Answers the character that separates list items.

Returns

string The separator
Test cases 1
Called from 1

Private surface 8§

Implementation details, listed for orientation only.

private array{non-empty-string, non-empty-string}|null $bracketPair
private array{non-empty-string, non-empty-string} $nestingPair
private string $numericLiteralPattern
private string $identifierStartPattern
private string $identifierPartPattern
private string $statementDelimiter
private string $listDelimiter
private LexicalPattern $patterns = new \ZtdQuery\Sql\LexicalPattern()

Test cases 21§

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

Dedicated tests 9
Other tests reaching this symbol 12

Relations§

Instantiated in 1
Method calls 10
Type declarations 2