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

Derives terminals, rewrites structural constraints, and realizes lexemes once. Dialect definitions supply the syntax and boundary rules; no completed SQL is retried or repaired.

Properties§

public ?TerminalSequence $lastSequence = null

The latest terminal sequence retains both the original grammar choices and their rewrites.

public ?ResolvedOutput $lastOutput = null

Selected lexical candidates and resolved boundary rules from the latest generation.

Methods§

public function __construct(
    private Grammar $grammar,
    private Generator $faker,
    private LexicalGrammar $lexicalGrammar,
    private ?TokenRewriter $rewriter = null,
    private Closure(string|null): string|null $startSymbol = null,
    private ?GrammarCoverage $coverage = null,
    ?Grammar $original = null,
)

Binds grammar, lexical definitions and structural rules before generation starts.

Parameters

$grammarGrammar
$fakerGenerator
$lexicalGrammarLexicalGrammar
$rewriter?TokenRewriter
$startSymbolClosure(string|null): string|nullResolves explicitly requested release aliases
$coverage?GrammarCoverage
$original?Grammar
Test cases 1090
Calls 3
public function generate<TRequiresNonEmpty of bool>(GenerationPlan<TRequiresNonEmpty> $plan): (TRequiresNonEmpty is true ? non-empty-string : string)

Generates once through the declared stages; candidate absence remains an error.

Parameters

$planGenerationPlan<TRequiresNonEmpty>

Returns

(TRequiresNonEmpty is true ? non-empty-string : string)

Throws

GenerationException When the grammar or plan cannot produce the requested output
LexicalException When no applicable lexical realization exists
Test cases 1104
Called from 3
Calls 11
public function realize(string $root, GenerationPlan<bool> $plan): string

Derives and realizes once, retaining source selection independently of transformed output.

Parameters

$rootstring
$planGenerationPlan<bool>

Returns

string

Throws

GenerationException When derivation cannot complete
LexicalException When a terminal has no compatible realization
Test cases 1011
Called from 1
Calls 6

Private surface 7§

Implementation details, listed for orientation only.

private ?TokenGenerator $tokens = null
private Grammar $grammar
private Generator $faker
private LexicalGrammar $lexicalGrammar
private ?TokenRewriter $rewriter = null
private Closure(string|null): string|null $startSymbol = null
private ?GrammarCoverage $coverage = null

Test cases 1107§

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

Dedicated tests 17
Other tests reaching this symbol 1090

Relations§

Instantiated in 3
Method calls 6
Type declarations 6