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

SQLite lexical generation using source-based candidate and boundary definitions. Tokenization is exposed separately for diagnostics and does not decide generation success.

Constants§

public const STRICT_TABLE_OPTION = 'STRICT_TABLE_OPTION'

The table option that makes a table reject values of the wrong type.

Methods§

public function __construct(
    private Generator $faker,
    private string $profileVersion,
    KeywordIndex|null $index = null,
)

Parameters

$fakerGeneratorSource of the choices realization makes
$profileVersionstringExact release to generate for, e.g. "sqlite-3.47.2"
$indexKeywordIndex|nullInverts the profile's terminal-to-spelling map

Throws

RuntimeException When the exact release has no declaration
Test cases 326
Calls 5
public function version(): string

Names the release this grammar generates for.

Returns

string Profile version, e.g. "sqlite-3.47.2"
Test cases 1
public function isNonOutput(string $terminal): bool

SQLite's grammar terminals all emit text; its implicit EOF is outside the terminal sequence.

Parameters

$terminalstring

Returns

bool
Test cases 270
public function realize(list<string> $terminals, GenerationPlan<bool>|null $plan = null): string

Realizes a terminal sequence using the same candidate and spacing pipeline as grammar generation.

Parameters

$terminalslist<string>
$planGenerationPlan<bool>|null

Returns

string

Throws

LexicalException When a requested realization is unavailable
Test cases 26
Calls 2
public function realizeSequence(
    TerminalSequence $sequence,
    GenerationPlan<bool>|null $plan = null,
): string

Resolves candidates and boundaries before serialization; tokenization remains a diagnostic API.

Parameters

$sequenceTerminalSequence
$planGenerationPlan<bool>|null

Returns

string

Throws

LexicalException When the selected terminals have no applicable realization
Test cases 24
Called from 1
Calls 4
public function resolveSequence(
    TerminalSequence $sequence,
    GenerationPlan<bool>|null $plan,
    Closure(int): int $choose,
    Closure(positive-int): ?int|null $valueChoice = null,
): ResolvedOutput

Exposes the resolved choices to a plan compiler without interpreting its input.

Parameters

$sequenceTerminalSequence
$planGenerationPlan<bool>|null
$chooseClosure(int): int
$valueChoiceClosure(positive-int): ?int|nullConstructive values selected only while compiling a plan

Throws

LexicalException When no compatible candidate exists
Test cases 295
Called from 1
Calls 1
public function tokenize(string $sql): list<string>

Reads SQL text into the tokens SQLite's own lexer would produce.

Parameters

$sqlstringText to read

Returns

list<string> Parser token names, in order

Throws

LexicalException When the text holds something the lexer cannot read
Test cases 253
Calls 1
public function generateQuotedIdentifier(
    int $minLength = 1,
    int $maxLength = 128,
): non-empty-string
public function generateStringLiteral(
    int $minLength = 1,
    int $maxLength = 255,
): non-empty-string
public function generateIntegerLiteral(int $min = 1, int $max = PHP_INT_MAX): non-empty-string
public function generateDecimalLiteral(int $precision = 15, int $scale = 2): non-empty-string

Private surface 5§

Implementation details, listed for orientation only.

private LiteralGenerator $strings
private ReverseLexemeGenerator $pipeline
private SqliteTokenizer $tokenizer
private Generator $faker
private string $profileVersion

Test cases 346§

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

Dedicated tests 53
Other tests reaching this symbol 293

Relations§

Instantiated in 1