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

Represents a formal grammar for SQL generation.

A formal grammar G = (N, Sigma, P, S) where:

  • N: Set of non-terminal symbols (keys of ruleMap)
  • Sigma: Set of terminal symbols (implicitly defined by Symbol types)
  • P: Set of production rules (ruleMap)
  • S: Start symbol (startSymbol)

Properties§

public string $startSymbol
public array<string, ProductionRule> $ruleMap

Methods§

public function __construct(
    public string $startSymbol,
    public array<string, ProductionRule> $ruleMap,
)

Parameters

$startSymbolstringThe grammar's start symbol
$ruleMaparray<string, ProductionRule>Non-terminal name => ProductionRule

Throws

InvalidArgumentException When a rule is filed under a name other than its own left-hand side
Test cases 1131
Calls 1
  • new InvalidArgumentException line 35
public static function loadFromFile(string $path): self

Load a pre-compiled grammar from a file path.

Parameters

$pathstring

Returns

self

Throws

RuntimeException When the compiled grammar is missing, empty, or is not a grammar
Test cases 1093
Called from 3
Calls 4
public function identified(): self

Assigns original ordinals before any dialect adapter filters alternatives.

Returns

self
Test cases 1137
Calls 3

Test cases 1284§

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 1277

Relations§

Instantiated in 3
Static calls 3
Type declarations 35