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

Answers what it still costs to finish a rule or a production.

A derivation has to stop, and to stop it has to know which way out is shortest. Two measures of "shortest" matter: how many tokens will be written, which decides how long the SQL gets, and how many rules will be expanded, which decides whether the walk fits in its step budget. Both are asked of the same grammar, so both are answered here.

Methods§

public function __construct(
    Grammar $grammar,
    callable(string): bool|null $terminalSupported = null,
)

Parameters

$grammarGrammarGrammar whose rules are being costed
$terminalSupportedcallable(string): bool|nullAnswers whether a terminal can be written at all, or null when every terminal can
Calls 2
public function isProductionViable(Production $production): bool

Reports whether a production can be finished at all.

A production whose shortest completion is unbounded contains a rule that can only expand into itself, so a walk that took it would never arrive at terminals.

Parameters

$productionProductionProduction to judge

Returns

bool True when some derivation of it ends in terminals
Test cases 3
Called from 1
Calls 1

Private surface 2§

Implementation details, listed for orientation only.

private TerminationCost $lengths
private TerminationCost $steps

Test cases 55§

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

Dedicated tests 15
Other tests reaching this symbol 40

Relations§

Instantiated in 2
Method calls 6
Type declarations 2