classReverseLexemeGenerator
final class ReverseLexemeGenerator
Chooses complete compatible candidates while traversing terminals from right to left.
Methods§
public function __construct(
private LexemeGenerator $lexemes,
private CandidateResolver $resolver,
private string $version,
private string $dialect = 'SQL',
)Binds the candidate definitions, boundary resolver and exact release for diagnostics.
Parameters
$lexemes | LexemeGenerator | |
$resolver | CandidateResolver | |
$version | string | |
$dialect | string |
Test cases 9
ReverseLexemeGeneratorTest::testConflictingCandidateIsNotSelectedOrAllowedToAlterAnotherCandidatecoversReverseLexemeGeneratorTest::testGenerateCompoundOutputRemainsInOrderAndEofAddsNoBoundarycoversReverseLexemeGeneratorTest::testGenerateRespectsTheOrderOfRepeatedPlannedOccurrencesAfterRenamingcoversReverseLexemeGeneratorTest::testGenerateRetainsAPlannedSpellingWhenAContextualRewriteRenamesItsTerminalcoversReverseLexemeGeneratorTest::testMatchesRequestComparesTheWholeCompoundSpellingcoversReverseLexemeGeneratorTest::testMissingHandlerFailsAtTheActualTerminalcoversReverseLexemeGeneratorTest::testSelectCanChooseTheLastOfSeveralCompatibleCandidatescoversReverseLexemeGeneratorTest::testSelectRejectsAnOutOfRangeDecisioncoversReverseLexemeGeneratorTest::testSelectReportsCandidateAndBoundarySourcesWhenAllCandidatesConflictcovers
public function generate(
TerminalSequence $sequence,
GenerationPlan<bool>|null $plan,
Closure(int): int $choose,
Closure(positive-int): ?int|null $valueChoice = null,
): ResolvedOutputParameters
$sequence | TerminalSequence | |
$plan | GenerationPlan<bool>|null | |
$choose | Closure(int): int | Chooses once after each applicable candidate set has been evaluated |
$valueChoice | Closure(positive-int): ?int|null | Explicit plan-time value decisions |
Returns
Throws
LexicalException When a candidate is missing, incompatible or unstableTest cases 33
BytePlanCompilerTest::testCompileMapsTheHeaderIntoTheAllowedExpansionRangecallsBytePlanCompilerTest::testCompileResolvesChoicesIntoInspectableReusableInstructionscallsBytePlanCompilerTest::testCompileSeparatesProductionChoicesFromLexemesAndCompletesAnOddInputcallsPlanBuilderTest::testBuildPreservesEmptyMarkerCandidatesWithoutLosingNonEmptyCompletioncallsPlanBuilderTest::testBuildPreservesRepeatedProductionAndLexemeConstraintscallsPlanBuilderTest::testBuildReservesAllPendingSiblingsAndRetainsTheOriginalOrdinalcallsPlanBuilderTest::testBuildUsesTheSameContextualRewriteAndPinsItsCompleteCandidatecallsPlanBuilderTest::testMinimumExpansionsIncludesTheConstrainedDescendantBeforeDrawingTheBudgetcallsPlanBuilderTest::testMinimumExpansionsIncludesTheSelectedRootAlternativeBeforeAllocatingInputBudgetcallsGrammarCoverageTest::testRecordOutputExposesCandidateAndBoundaryDecisionscallsBoundaryCompletionTest::testAcceptsOnlyCandidatesWhosePendingLeftBoundaryHasACompletioncallsBoundaryCompletionTest::testAcceptsUsesTheSampledLeftValueInsteadOfAnUnrelatedDefaultWitnesscallsReverseLexemeGeneratorTest::testConflictingCandidateIsNotSelectedOrAllowedToAlterAnotherCandidatecovers and callsReverseLexemeGeneratorTest::testGenerateCompoundOutputRemainsInOrderAndEofAddsNoBoundarycovers and callsReverseLexemeGeneratorTest::testGenerateRespectsTheOrderOfRepeatedPlannedOccurrencesAfterRenamingcovers and callsReverseLexemeGeneratorTest::testGenerateRetainsAPlannedSpellingWhenAContextualRewriteRenamesItsTerminalcovers and callsReverseLexemeGeneratorTest::testMissingHandlerFailsAtTheActualTerminalcovers and callsReverseLexemeGeneratorTest::testSelectCanChooseTheLastOfSeveralCompatibleCandidatescovers and callsReverseLexemeGeneratorTest::testSelectReportsCandidateAndBoundarySourcesWhenAllCandidatesConflictcovers and callsSqlGeneratorTest::testGenerateAllowsEmptyOutputWhenThePlanAllowsItcallsSqlGeneratorTest::testGenerateClearsPreviousGrammarTraceBeforeALexicalPlancallsSqlGeneratorTest::testGenerateKeepsRewrittenSourcesReachedWithoutCreditingTheirOutputcallsSqlGeneratorTest::testGenerateRecordsACompleteCoverageObservationcallsSqlGeneratorTest::testGenerateRejectsUnexpectedEmptyOutputWithoutRetryingcallsSqlGeneratorTest::testGenerateReplacesGrammarCoverageWithTheLatestLexicalTracecallsSqlGeneratorTest::testGenerateReportsOnlyTheLatestRewrittenDerivationcallsSqlGeneratorTest::testGenerateReusesCompletionAnalysisAcrossDifferentPlanscallsSqlGeneratorTest::testGenerateUsesExplicitRulesAndSuppliedParserSemanticscallsSqlGeneratorTest::testGenerateUsesTheGrammarEntryPointWithoutDialectKnowledgecallsSqlGeneratorTest::testGenerateUsesTheSuppliedVersionSpecificRuleResolvercallsSqlGeneratorTest::testPlannerBindsTheSameGrammarEntryAndFreezesEveryChoicecallsSqlGeneratorTest::testRealizeOffersTheWholeZeroBasedCandidateRangecallsSqlGeneratorTest::testRealizeRetainsTheActualTerminalAndLexicalTracecalls
Called from 3
- method-call SqlFaker\MySql\Generation\LexicalGrammar::resolveSequence() packages/sql-faker/src/MySql/Generation/LexicalGrammar.php:126
- method-call SqlFaker\PostgreSql\Generation\LexicalGrammar::resolveSequence() packages/sql-faker/src/PostgreSql/Generation/LexicalGrammar.php:141
- method-call SqlFaker\Sqlite\Generation\LexicalGrammar::resolveSequence() packages/sql-faker/src/Sqlite/Generation/LexicalGrammar.php:121
Calls 10
- new ValueChoices line 58
- new BoundaryCompletion line 59
- new ResolvedOutput line 60
- function-call
countline 61 - method-call ReverseLexemeGenerator::select() line 62
- new LexemeInput line 63
- method-call BoundaryCompletion::accepts() line 66
- class-const SpacingConstraint::EITHER() line 69
- new LexicalException line 70
- function-call
implodeline 70
public function select(
LexemeInput $input,
Closure(int): int $choose,
?string $key = null,
Closure(ResolvedOutput): bool|null $canComplete = null,
): ResolvedOutputParameters
$input | LexemeInput | |
$choose | Closure(int): int | |
$key | ?string | |
$canComplete | Closure(ResolvedOutput): bool|null | Checks outstanding left-boundary obligations |
Returns
Throws
LexicalException When a candidate is missing, incompatible or unstableTest cases 8
ReverseLexemeGeneratorTest::testConflictingCandidateIsNotSelectedOrAllowedToAlterAnotherCandidatecoversReverseLexemeGeneratorTest::testGenerateCompoundOutputRemainsInOrderAndEofAddsNoBoundarycoversReverseLexemeGeneratorTest::testGenerateRespectsTheOrderOfRepeatedPlannedOccurrencesAfterRenamingcoversReverseLexemeGeneratorTest::testGenerateRetainsAPlannedSpellingWhenAContextualRewriteRenamesItsTerminalcoversReverseLexemeGeneratorTest::testMissingHandlerFailsAtTheActualTerminalcoversReverseLexemeGeneratorTest::testSelectCanChooseTheLastOfSeveralCompatibleCandidatescoversReverseLexemeGeneratorTest::testSelectRejectsAnOutOfRangeDecisioncovers and callsReverseLexemeGeneratorTest::testSelectReportsCandidateAndBoundarySourcesWhenAllCandidatesConflictcovers
Called from 1
Calls 8
- method-call LexemeGenerator::generate() line 82
- static-call LexicalException::unsupportedTerminal() line 84
- method-call LexemeInput::terminal() line 84
- method-call ReverseLexemeGenerator::matchesRequest() line 90
- method-call CandidateResolver::resolve() line 93
- function-call
implodeline 95 - new LexicalException line 105
- new ResolvedOutput line 119
public function matchesRequest(
LexemeSequence $candidate,
LexemeInput $input,
?string $key = null,
): boolCompares a requested spelling with the candidate's complete output, before boundary selection.
Parameters
$candidate | LexemeSequence | |
$input | LexemeInput | |
$key | ?string |
Returns
boolTest cases 8
ReverseLexemeGeneratorTest::testConflictingCandidateIsNotSelectedOrAllowedToAlterAnotherCandidatecoversReverseLexemeGeneratorTest::testGenerateCompoundOutputRemainsInOrderAndEofAddsNoBoundarycoversReverseLexemeGeneratorTest::testGenerateRespectsTheOrderOfRepeatedPlannedOccurrencesAfterRenamingcoversReverseLexemeGeneratorTest::testGenerateRetainsAPlannedSpellingWhenAContextualRewriteRenamesItsTerminalcoversReverseLexemeGeneratorTest::testMatchesRequestComparesTheWholeCompoundSpellingcovers and callsReverseLexemeGeneratorTest::testSelectCanChooseTheLastOfSeveralCompatibleCandidatescoversReverseLexemeGeneratorTest::testSelectRejectsAnOutOfRangeDecisioncoversReverseLexemeGeneratorTest::testSelectReportsCandidateAndBoundarySourcesWhenAllCandidatesConflictcovers
Called from 2
Calls 3
- method-call LexemeSequence::key() line 130
- function-call
implodeline 131 - function-call
array_mapline 131
Private surface 4§
Implementation details, listed for orientation only.
private LexemeGenerator $lexemesprivate CandidateResolver $resolverprivate string $versionprivate string $dialect = 'SQL'Test cases 58§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 9
ReverseLexemeGeneratorTest::testConflictingCandidateIsNotSelectedOrAllowedToAlterAnotherCandidatecovers and callsReverseLexemeGeneratorTest::testGenerateCompoundOutputRemainsInOrderAndEofAddsNoBoundarycovers and callsReverseLexemeGeneratorTest::testGenerateRespectsTheOrderOfRepeatedPlannedOccurrencesAfterRenamingcovers and callsReverseLexemeGeneratorTest::testGenerateRetainsAPlannedSpellingWhenAContextualRewriteRenamesItsTerminalcovers and callsReverseLexemeGeneratorTest::testMatchesRequestComparesTheWholeCompoundSpellingcovers and callsReverseLexemeGeneratorTest::testMissingHandlerFailsAtTheActualTerminalcovers and callsReverseLexemeGeneratorTest::testSelectCanChooseTheLastOfSeveralCompatibleCandidatescovers and callsReverseLexemeGeneratorTest::testSelectRejectsAnOutOfRangeDecisioncovers and callsReverseLexemeGeneratorTest::testSelectReportsCandidateAndBoundarySourcesWhenAllCandidatesConflictcovers and calls
Other tests reaching this symbol 49
BytePlanCompilerTest::testCompileMapsTheHeaderIntoTheAllowedExpansionRangecallsBytePlanCompilerTest::testCompileResolvesChoicesIntoInspectableReusableInstructionscallsBytePlanCompilerTest::testCompileSeparatesProductionChoicesFromLexemesAndCompletesAnOddInputcallsPlanBuilderTest::testBuildPreservesEmptyMarkerCandidatesWithoutLosingNonEmptyCompletioncallsPlanBuilderTest::testBuildPreservesRepeatedProductionAndLexemeConstraintscallsPlanBuilderTest::testBuildReservesAllPendingSiblingsAndRetainsTheOriginalOrdinalcallsPlanBuilderTest::testBuildUsesTheSameContextualRewriteAndPinsItsCompleteCandidatecallsPlanBuilderTest::testMinimumExpansionsIncludesTheConstrainedDescendantBeforeDrawingTheBudgetcallsPlanBuilderTest::testMinimumExpansionsIncludesTheSelectedRootAlternativeBeforeAllocatingInputBudgetcallsGrammarCoverageTest::testRecordOutputExposesCandidateAndBoundaryDecisionscallsDerivationTraceTestcallsTokenGeneratorTestcallsLexicalExceptionTestcallsLexemeSequenceTestcallsBoundaryCompletionTest::testAcceptsOnlyCandidatesWhosePendingLeftBoundaryHasACompletioncallsBoundaryCompletionTest::testAcceptsUsesTheSampledLeftValueInsteadOfAnUnrelatedDefaultWitnesscallsCandidateResolverTestcallsSqlGeneratorTest::testGenerateAllowsEmptyOutputWhenThePlanAllowsItcallsSqlGeneratorTest::testGenerateClearsPreviousGrammarTraceBeforeALexicalPlancallsSqlGeneratorTest::testGenerateKeepsRewrittenSourcesReachedWithoutCreditingTheirOutputcallsSqlGeneratorTest::testGenerateRecordsACompleteCoverageObservationcallsSqlGeneratorTest::testGenerateRejectsUnexpectedEmptyOutputWithoutRetryingcallsSqlGeneratorTest::testGenerateReplacesGrammarCoverageWithTheLatestLexicalTracecallsSqlGeneratorTest::testGenerateReportsOnlyTheLatestRewrittenDerivationcallsSqlGeneratorTest::testGenerateReusesCompletionAnalysisAcrossDifferentPlanscallsSqlGeneratorTest::testGenerateUsesExplicitRulesAndSuppliedParserSemanticscallsSqlGeneratorTest::testGenerateUsesTheGrammarEntryPointWithoutDialectKnowledgecallsSqlGeneratorTest::testGenerateUsesTheSuppliedVersionSpecificRuleResolvercallsSqlGeneratorTest::testPlannerBindsTheSameGrammarEntryAndFreezesEveryChoicecallsSqlGeneratorTest::testRealizeOffersTheWholeZeroBasedCandidateRangecallsSqlGeneratorTest::testRealizeRetainsTheActualTerminalAndLexicalTracecallsTerminalSequenceTestcallsGenerationContextTestcallsCharsetValueLexemeGeneratorTestcallsDefinitionFactoryTestcallsLexicalDefinitionTestcallsLexicalGrammarTestcallsMySqlProviderTestcallsGenerationContextTestcallsDefinitionFactoryTestcallsLexicalDefinitionTestcallsLexicalGrammarTestcallsPostgreSqlProviderTestcallsSqlGeneratorFactoryTestcallsGenerationContextTestcallsDefinitionFactoryTestcallsLexicalDefinitionTestcallsLexicalGrammarTestcallsSqliteProviderTestcalls
Relations§
Instantiated in 3
- new SqlFaker\MySql\Generation\Lexeme\LexicalDefinition::__construct() packages/sql-faker/src/MySql/Generation/Lexeme/LexicalDefinition.php:38
- new SqlFaker\PostgreSql\Generation\Lexeme\LexicalDefinition::__construct() packages/sql-faker/src/PostgreSql/Generation/Lexeme/LexicalDefinition.php:34
- new SqlFaker\Sqlite\Generation\Lexeme\LexicalDefinition::__construct() packages/sql-faker/src/Sqlite/Generation/Lexeme/LexicalDefinition.php:32
Method calls 3
- method-call SqlFaker\MySql\Generation\LexicalGrammar::resolveSequence() packages/sql-faker/src/MySql/Generation/LexicalGrammar.php:126
- method-call SqlFaker\PostgreSql\Generation\LexicalGrammar::resolveSequence() packages/sql-faker/src/PostgreSql/Generation/LexicalGrammar.php:141
- method-call SqlFaker\Sqlite\Generation\LexicalGrammar::resolveSequence() packages/sql-faker/src/Sqlite/Generation/LexicalGrammar.php:121
Type declarations 6
- type SqlFaker\MySql\Generation\Lexeme\LexicalDefinition packages/sql-faker/src/MySql/Generation/Lexeme/LexicalDefinition.php:20
- type SqlFaker\MySql\Generation\LexicalGrammar packages/sql-faker/src/MySql/Generation/LexicalGrammar.php:37
- type SqlFaker\PostgreSql\Generation\Lexeme\LexicalDefinition packages/sql-faker/src/PostgreSql/Generation/Lexeme/LexicalDefinition.php:20
- type SqlFaker\PostgreSql\Generation\LexicalGrammar packages/sql-faker/src/PostgreSql/Generation/LexicalGrammar.php:38
- type SqlFaker\Sqlite\Generation\Lexeme\LexicalDefinition packages/sql-faker/src/Sqlite/Generation/Lexeme/LexicalDefinition.php:20
- type SqlFaker\Sqlite\Generation\LexicalGrammar packages/sql-faker/src/Sqlite/Generation/LexicalGrammar.php:42