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

Computes minimum expansion costs separately for empty and non-empty output.

Methods§

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

Computes the least fixed point once for a grammar and its declared non-output markers.

Parameters

$grammarGrammar
$nonOutputClosure(string): boolIdentifies declared non-output parser markers
Calls 4
public function rule(string $name, bool $nonEmpty): int

Returns the minimum total expansions from a rule.

Parameters

$namestring
$nonEmptybool

Returns

int
Test cases 1
Calls 1
public function sequence(list<Symbol> $symbols): array{int, int}
public function affordable(
    list<Production> $alternatives,
    list<Symbol> $remainder,
    bool $nonEmpty,
    int $budget,
): list<Production>

Applies the candidate policy shared by token generation and planning.

Parameters

$alternativeslist<Production>
$remainderlist<Symbol>
$nonEmptybool
$budgetint

Returns

Test cases 1
Called from 1
Calls 3

Private surface 3§

Implementation details, listed for orientation only.

private array<string, array{int, int}> $costs
private array<string, array{int, int}> $terminalCosts = []
private Closure(string): bool $nonOutput

Test cases 56§

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

Dedicated tests 7
Other tests reaching this symbol 49

Relations§

Instantiated in 2
Static calls 4
Method calls 12
Type declarations 7