interfaceLexicalGrammar
interface LexicalGrammar
Generates lexical values and realizes grammar terminals using fixed dialect definitions. Output validity is checked against the target database; tokenizer identity is not a success condition.
Methods§
public function generate(GenerationPlan<bool> $plan): non-empty-stringWrites the one lexeme a lexical generation plan asks for.
Parameters
$plan | GenerationPlan<bool> | Plan naming the lexeme kind and its bounds |
Returns
non-empty-string The lexemeTest cases 1
Called from 1
public function version(): stringNames the server version this grammar generates for.
Returns
string Exact release identifier supplied by the dialect implementationTest cases 1
public function isNonOutput(string $terminal): boolIdentifies non-output parser markers for derivation budgets, independently of handler availability.
Parameters
$terminal | string |
Returns
boolCalled from 3
- method-call SqlFaker\Generation\Choice\PlanBuilder::__construct() packages/sql-faker/src/Generation/Choice/PlanBuilder.php:37
- method-call SqlFaker\Generation\Choice\PlanBuilder::__construct() packages/sql-faker/src/Generation/Choice/PlanBuilder.php:38
- method-call SqlFaker\Generation\SqlGenerator::realize() packages/sql-faker/src/Generation/SqlGenerator.php:109
public function realize(list<string> $terminals, GenerationPlan<bool>|null $plan = null): stringResolves lexical candidates and their boundary constraints into SQL.
Parameters
$terminals | list<string> | Terminals to write, in order |
$plan | GenerationPlan<bool>|null | Plan that may pin exact lexemes for some terminals |
Returns
string SQL assembled from resolved lexical candidatesThrows
LexicalException When no compatible lexical candidate is availableTest cases 1
public function realizeSequence(
TerminalSequence $sequence,
GenerationPlan<bool>|null $plan = null,
): stringRealizes terminal occurrences using their grammar context, without requiring tokenizer identity.
Parameters
$sequence | TerminalSequence | |
$plan | GenerationPlan<bool>|null |
Returns
stringThrows
LexicalException When no applicable realization existspublic function resolveSequence(
TerminalSequence $sequence,
GenerationPlan<bool>|null $plan,
Closure(int): int $choose,
Closure(positive-int): ?int|null $valueChoice = null,
): ResolvedOutputResolves and exposes complete choices through the same lexical pipeline used to generate SQL.
Parameters
$sequence | TerminalSequence | |
$plan | GenerationPlan<bool>|null | |
$choose | Closure(int): int | |
$valueChoice | Closure(positive-int): ?int|null | Constructive values selected only while compiling a plan |
Returns
Throws
LexicalException When no applicable realization existsTest cases 34§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 3
Other tests reaching this symbol 31
BytePlanCompilerTest::testCompileMapsTheHeaderIntoTheAllowedExpansionRangecallsBytePlanCompilerTest::testCompileResolvesChoicesIntoInspectableReusableInstructionscallsBytePlanCompilerTest::testCompileSeparatesProductionChoicesFromLexemesAndCompletesAnOddInputcallsPlanBuilderTest::testBuildPreservesEmptyMarkerCandidatesWithoutLosingNonEmptyCompletioncallsPlanBuilderTest::testBuildPreservesRepeatedProductionAndLexemeConstraintscallsPlanBuilderTest::testBuildPropagatesMissingCandidateFailuresWithoutRetryingcallsPlanBuilderTest::testBuildReportsAnUnknownRequestedRulecallsPlanBuilderTest::testBuildReservesAllPendingSiblingsAndRetainsTheOriginalOrdinalcallsPlanBuilderTest::testBuildUsesTheSameContextualRewriteAndPinsItsCompleteCandidatecallsPlanBuilderTest::testMinimumExpansionsIncludesTheConstrainedDescendantBeforeDrawingTheBudgetcallsPlanBuilderTest::testMinimumExpansionsIncludesTheSelectedRootAlternativeBeforeAllocatingInputBudgetcallsPlanBuilderTest::testMinimumExpansionsKeepsTheNonEmptyRequirementSeparateFromNullabilitycallsPlanBuilderTest::testMinimumExpansionsRetainsNonEmptyCostsAndTheUnreachableSentinelForRootPatternscallsPlanBuilderTest::testRootResolvesOnlyAnExplicitReleaseAliascallsSqlGeneratorTest::testGenerateAllowsEmptyOutputWhenThePlanAllowsItcallsSqlGeneratorTest::testGenerateClearsPreviousGrammarTraceBeforeALexicalPlancallsSqlGeneratorTest::testGenerateClosesCoverageAfterARejectedEmptyLexicalResultcallsSqlGeneratorTest::testGenerateKeepsRewrittenSourcesReachedWithoutCreditingTheirOutputcallsSqlGeneratorTest::testGenerateLexicalPlansBypassGrammarDerivationcallsSqlGeneratorTest::testGeneratePreservesTheFirstLexicalFailureWithoutRetryingcallsSqlGeneratorTest::testGenerateRecordsACompleteCoverageObservationcallsSqlGeneratorTest::testGenerateRejectsUnexpectedEmptyOutputWithoutRetryingcallsSqlGeneratorTest::testGenerateReplacesGrammarCoverageWithTheLatestLexicalTracecallsSqlGeneratorTest::testGenerateReportsOnlyTheLatestRewrittenDerivationcallsSqlGeneratorTest::testGenerateReusesCompletionAnalysisAcrossDifferentPlanscallsSqlGeneratorTest::testGenerateUsesExplicitRulesAndSuppliedParserSemanticscallsSqlGeneratorTest::testGenerateUsesTheGrammarEntryPointWithoutDialectKnowledgecallsSqlGeneratorTest::testGenerateUsesTheSuppliedVersionSpecificRuleResolvercallsSqlGeneratorTest::testPlannerBindsTheSameGrammarEntryAndFreezesEveryChoicecallsSqlGeneratorTest::testRealizeOffersTheWholeZeroBasedCandidateRangecallsSqlGeneratorTest::testRealizeRetainsTheActualTerminalAndLexicalTracecalls
Relations§
Implemented by 3
Method calls 8
- method-call SqlFaker\Generation\Choice\PlanBuilder::__construct() packages/sql-faker/src/Generation/Choice/PlanBuilder.php:37
- method-call SqlFaker\Generation\Choice\PlanBuilder::__construct() packages/sql-faker/src/Generation/Choice/PlanBuilder.php:38
- method-call SqlFaker\Generation\Choice\PlanBuilder::build() packages/sql-faker/src/Generation/Choice/PlanBuilder.php:83
- method-call SqlFaker\Generation\SqlGenerator::__construct() packages/sql-faker/src/Generation/SqlGenerator.php:58
- method-call SqlFaker\Generation\SqlGenerator::generate() packages/sql-faker/src/Generation/SqlGenerator.php:87
- method-call SqlFaker\Generation\SqlGenerator::generate() packages/sql-faker/src/Generation/SqlGenerator.php:89
- method-call SqlFaker\Generation\SqlGenerator::realize() packages/sql-faker/src/Generation/SqlGenerator.php:109
- method-call SqlFaker\Generation\SqlGenerator::realize() packages/sql-faker/src/Generation/SqlGenerator.php:112
Type declarations 5
- type SqlFaker\Generation\Choice\PlanBuilder packages/sql-faker/src/Generation/Choice/PlanBuilder.php:33
- type SqlFaker\Generation\SqlGenerator packages/sql-faker/src/Generation/SqlGenerator.php:52
- type SqlFaker\MySql\Generation\GenerationContext packages/sql-faker/src/MySql/Generation/GenerationContext.php:31
- type SqlFaker\PostgreSql\Generation\GenerationContext packages/sql-faker/src/PostgreSql/Generation/GenerationContext.php:31
- type SqlFaker\Sqlite\Generation\GenerationContext packages/sql-faker/src/Sqlite/Generation/GenerationContext.php:31