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

Reads a GNU Bison or Yacc grammar file into an AST.

A grammar file has three sections in a fixed order — declarations, rules, epilogue — so parsing is a sequence of three reads rather than a decision. Each section knows its own end, which is what lets this class say what a grammar file is without also saying how any part of it is spelled.

A file with no rules is refused. Unknown declarations are retained as source text so later passes can preserve constructs outside the AST model.

Methods§

public function __construct(
    BisonPreambleReader|null $preamble = null,
    BisonRuleReader|null $rules = null,
    BisonStartSymbol|null $startSymbol = null,
)

Parameters

$preambleBisonPreambleReader|nullReads the prologue and declarations
$rulesBisonRuleReader|nullReads the production rules
$startSymbolBisonStartSymbol|nullDecides which rule a derivation begins from
Test cases 76
Calls 3
public function parse(string $input): BisonAst

Reads grammar source text into an AST.

Parameters

$inputstringBison grammar text

Returns

BisonAst The grammar the text describes

Throws

GrammarParseException When the text yields no production rules
Test cases 76
Called from 1
Calls 7
public function parseFile(string $path): BisonAst

Reads a grammar file from disk.

Parameters

$pathstringPath to a Bison grammar file

Returns

BisonAst The grammar the file describes

Throws

GrammarParseException When the file cannot be read, or yields no production rules
Test cases 2
Calls 4

Private surface 3§

Implementation details, listed for orientation only.

private BisonPreambleReader $preamble
private BisonRuleReader $rules
private BisonStartSymbol $startSymbol

Test cases 77§

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

Dedicated tests 77