classGrammarCompiler
final class GrammarCompiler
Restricted visibility: declared "@visibility root". Code outside that scope must not name this declaration.
Compiles a Grammar from a BisonAst.
Transforms the supplied Bison AST into productions and symbols without selecting a database dialect or interpreting its scanner actions.
Methods§
Compile a BisonAst into a Grammar.
Parameters
$ast | BisonAst |
Returns
Throws
UnknownSymbolException When a production names a symbol the grammar never declaresTest cases 16
GrammarCompilerTest::testCompilecovers and callsGrammarCompilerTest::testCompileDiscardsActionAndPrecedencecovers and callsGrammarCompilerTest::testCompileDistinguishesTerminalsAndNonTerminalscovers and callsGrammarCompilerTest::testCompileIgnoresNonTokenDeclarationscovers and callsGrammarCompilerTest::testCompileIgnoresPrologueAndEpiloguecovers and callsGrammarCompilerTest::testCompileMergesSameNameRulescovers and callsGrammarCompilerTest::testCompileMergesSameNameRulesPreservesBisonStructurecovers and callsGrammarCompilerTest::testCompileMultipleAlternativescovers and callsGrammarCompilerTest::testCompilePreservesBisonStructurecovers and callsGrammarCompilerTest::testCompileThrowsOnUnknownSymbolcovers and callsGrammarCompilerTest::testCompileThrowsOnUnknownSymbolPreservesBisonStructurecovers and callsGrammarCompilerTest::testCompileUsesStartSymbolFromAstcovers and callsGrammarCompilerTest::testCompileWithEmptyDeclarationsAndSingleRulecovers and callsGrammarCompilerTest::testCompileWithEmptyProductioncovers and callsGrammarCompilerTest::testCompileWithMultipleAlternativescovers and callsGrammarCompilerTest::testCompileWithMultipleDistinctRulescovers and calls
Calls 9
- method-call GrammarCompiler::declarations() line 43
- class-const BisonSymbolForm::CharLiteral() line 57
- new Terminal line 58
- new NonTerminal line 60
- new UnknownSymbolException line 64
- new Production line 68
- function-call
array_mergeline 72 - new ProductionRule line 76
- new Grammar line 82
public function declarations(BisonAst $ast): array<string, BisonTokenDefinition>Indexes declared terminal tokens by name before compiling productions.
Parameters
$ast | BisonAst |
Returns
array<string, BisonTokenDefinition>Test cases 17
GrammarCompilerTest::testCompilecoversGrammarCompilerTest::testCompileDiscardsActionAndPrecedencecoversGrammarCompilerTest::testCompileDistinguishesTerminalsAndNonTerminalscoversGrammarCompilerTest::testCompileIgnoresNonTokenDeclarationscoversGrammarCompilerTest::testCompileIgnoresPrologueAndEpiloguecoversGrammarCompilerTest::testCompileMergesSameNameRulescoversGrammarCompilerTest::testCompileMergesSameNameRulesPreservesBisonStructurecoversGrammarCompilerTest::testCompileMultipleAlternativescoversGrammarCompilerTest::testCompilePreservesBisonStructurecoversGrammarCompilerTest::testCompileThrowsOnUnknownSymbolcoversGrammarCompilerTest::testCompileThrowsOnUnknownSymbolPreservesBisonStructurecoversGrammarCompilerTest::testCompileUsesStartSymbolFromAstcoversGrammarCompilerTest::testCompileWithEmptyDeclarationsAndSingleRulecoversGrammarCompilerTest::testCompileWithEmptyProductioncoversGrammarCompilerTest::testCompileWithMultipleAlternativescoversGrammarCompilerTest::testCompileWithMultipleDistinctRulescoversGrammarCompilerTest::testDeclarationsIndexesTokensAndIgnoresStartDeclarationscovers and calls
Test cases 17§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 17
GrammarCompilerTest::testCompilecovers and callsGrammarCompilerTest::testCompileDiscardsActionAndPrecedencecovers and callsGrammarCompilerTest::testCompileDistinguishesTerminalsAndNonTerminalscovers and callsGrammarCompilerTest::testCompileIgnoresNonTokenDeclarationscovers and callsGrammarCompilerTest::testCompileIgnoresPrologueAndEpiloguecovers and callsGrammarCompilerTest::testCompileMergesSameNameRulescovers and callsGrammarCompilerTest::testCompileMergesSameNameRulesPreservesBisonStructurecovers and callsGrammarCompilerTest::testCompileMultipleAlternativescovers and callsGrammarCompilerTest::testCompilePreservesBisonStructurecovers and callsGrammarCompilerTest::testCompileThrowsOnUnknownSymbolcovers and callsGrammarCompilerTest::testCompileThrowsOnUnknownSymbolPreservesBisonStructurecovers and callsGrammarCompilerTest::testCompileUsesStartSymbolFromAstcovers and callsGrammarCompilerTest::testCompileWithEmptyDeclarationsAndSingleRulecovers and callsGrammarCompilerTest::testCompileWithEmptyProductioncovers and callsGrammarCompilerTest::testCompileWithMultipleAlternativescovers and callsGrammarCompilerTest::testCompileWithMultipleDistinctRulescovers and callsGrammarCompilerTest::testDeclarationsIndexesTokensAndIgnoresStartDeclarationscovers and calls