final class PlanBuilder

Compiles choices through the production generation pipeline into immutable instructions.

Methods§

public function __construct(
    private Grammar $grammar,
    private LexicalGrammar $lexical,
    private ?TokenRewriter $rewriter = null,
    private Closure(string|null): string|null $startSymbol = null,
)

Parameters

$grammarGrammar
$lexicalLexicalGrammar
$rewriter?TokenRewriter
$startSymbolClosure(string|null): string|nullResolves explicit release aliases
Calls 3
public function build<T of bool>(
    GenerationPlan<T> $constraints,
    int $budget,
    Closure(int, non-empty-list<Production>): ?int $productionChoice,
    Closure(int): ?int $lexicalChoice,
): GenerationPlan<T>

Freezes original production ordinals and every rewritten terminal's complete candidate.

Parameters

$constraintsGenerationPlan<T>
$budgetint
$productionChoiceClosure(int, non-empty-list<Production>): ?int
$lexicalChoiceClosure(int): ?int

Returns

Throws

GenerationException When the grammar cannot complete the plan within the budget
LexicalException When a terminal has no compatible realization
Test cases 7
Called from 2
Calls 11

Private surface 5§

Implementation details, listed for orientation only.

private TokenGenerator $tokens
private Grammar $grammar
private LexicalGrammar $lexical
private ?TokenRewriter $rewriter = null
private Closure(string|null): string|null $startSymbol = null

Test cases 22§

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

Dedicated tests 12
Other tests reaching this symbol 10

Relations§

Instantiated in 1
Method calls 4
Type declarations 6