final class TokenGenerator

Derives grammar terminals without choosing spellings or pruning unsupported lexemes.

Properties§

public ?ScopedGeneration $lastScope = null

Lexical scopes belonging only to the latest derivation.

Methods§

public function __construct(
    private Grammar $grammar,
    private Generator $faker,
    private Closure(string): bool $nonOutput,
)

Fixes grammar and production choices; marker metadata affects emptiness, never handler availability.

Parameters

$grammarGrammar
$fakerGenerator
$nonOutputClosure(string): bool
Calls 2
public function generate(
    string $root,
    GenerationPlan<bool> $plan,
    Closure(int, non-empty-list<Production>): ?int|null $choose = null,
): TerminalSequence
public function derive(
    string $root,
    GenerationPlan<bool> $plan,
    Closure(int, non-empty-list<Production>): ?int|null $choose = null,
): TerminalSequence

Runs the shared derivation engine on the selected grammar.

Parameters

$rootstring
$planGenerationPlan<bool>
$chooseClosure(int, non-empty-list<Production>): ?int|null

Throws

GenerationException When the grammar cannot complete the plan
LogicException When derivation failed to retain its trace
Test cases 1
Called from 1
Calls 3

Private surface 9§

Implementation details, listed for orientation only.

private TerminationAnalyzer $termination
private CompletionCosts $completion
private array<string, RulePlan> $plannedRules = []
private ?string $plannedRoot = null
private ?PreparedGrammar $prepared = null
private ?self $planned = null
private Grammar $grammar
private Generator $faker
private Closure(string): bool $nonOutput

Test cases 23§

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

Dedicated tests 6
Other tests reaching this symbol 17

Relations§

Instantiated in 2
Method calls 2
Type declarations 2