classGrammarParseException
final class GrammarParseException
extends RuntimeException
Reports that grammar source text could not be turned into a grammar.
Bison and Lemon grammars are read from files that ship with the server they describe, so a grammar that declares tokens but no rules, or that ends before its rules section, is a property of the input rather than a defect in the parser. Callers that load grammars at runtime are expected to handle this.
Methods§
public static function noRulesParsed(string $dialect): selfReports grammar source that yielded no production rules.
Parameters
$dialect | string | Grammar flavour that was being read, e.g. "Bison" |
Returns
self Exception naming the grammar flavourTest cases 2
GrammarParseExceptionTest::testNoRulesParsedNamesTheBisonGrammarcovers and callsGrammarParseExceptionTest::testNoRulesParsedNamesTheLemonGrammarcovers and calls
Called from 2
Calls 1
- new
selfline 31
public static function unreadableSource(string $path): selfReports a grammar file that could not be read from disk.
Parameters
$path | string | Path that was asked for |
Returns
self Exception naming the pathTest cases 1
Called from 2
Calls 1
- new
selfline 43
public static function unexpectedCharacter(string $character, int $offset): selfReports a character that starts no lexeme of the grammar language.
Parameters
$character | string | The character that was reached |
$offset | int | Where in the source it sits |
Returns
self Exception naming the character and its positionTest cases 1
Called from 1
Calls 1
- new
selfline 56
public static function danglingSlash(int $offset): selfReports a slash that opens neither comment form.
Parameters
$offset | int | Where the slash sits |
Returns
self Exception naming the positionTest cases 1
GrammarParseExceptionTest::testDanglingSlashNamesWhereTheSlashSitscovers and calls
Called from 1
Calls 1
- new
selfline 68
public static function namelessDirective(int $offset): selfReports a percent sign with no directive name after it.
Parameters
$offset | int | Where the percent sign sits |
Returns
self Exception naming the positionTest cases 1
Called from 1
Calls 1
- new
selfline 80
public static function unterminatedTypeTag(int $offset): selfReports a semantic type tag that is never closed.
Parameters
$offset | int | Where the tag opens |
Returns
self Exception naming the position the tag opened atTest cases 1
Called from 1
Calls 1
- new
selfline 92
Test cases 33§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 7
GrammarParseExceptionTest::testDanglingSlashNamesWhereTheSlashSitscovers and callsGrammarParseExceptionTest::testNamelessDirectiveNamesWhereThePercentSignSitscovers and callsGrammarParseExceptionTest::testNoRulesParsedNamesTheBisonGrammarcovers and callsGrammarParseExceptionTest::testNoRulesParsedNamesTheLemonGrammarcovers and callsGrammarParseExceptionTest::testUnexpectedCharacterNamesTheCharacterAndWhereItSitscovers and callsGrammarParseExceptionTest::testUnreadableSourceNamesThePathThatWasAskedForcovers and callsGrammarParseExceptionTest::testUnterminatedTypeTagNamesWhereTheTagOpenedcovers and calls
Other tests reaching this symbol 26
BisonParserTest::testParseDeclarationsSectionEndsAtEofcallsBisonParserTest::testParseNoRulesThrowsExceptioncallsBisonPreambleReaderTestcallsBisonDirectiveReaderChainTestcallsDefineDirectiveReaderTestcallsExpectDirectiveReaderTestcallsParamDirectiveReaderTestcallsPrecedenceDirectiveReaderTestcallsStartDirectiveReaderTestcallsTokenDirectiveReaderTestcallsTypeDirectiveReaderTestcallsUnknownDirectiveReaderTestcallsActionScannerTestcallsBisonLexerTest::testScanRejectsWhatTheGivenChainDoesNotCovercallsBisonLexerTest::testScanReportsACharacterNoScannerClaimscallsBisonScannerChainTestcallsBisonTokenStreamTest::testNextThrowsForEmptyDirectivecallsBisonTokenStreamTest::testNextThrowsForUnexpectedCharactercallsBisonTokenStreamTest::testNextThrowsForUnexpectedSlashcallsBisonTokenStreamTest::testNextThrowsForUnterminatedTypeTagcallsBisonTriviaTest::testSkipFromReportsASlashThatOpensNoCommentcallsDirectiveScannerTest::testScanDirectiveNameReportsAPercentSignWithoutANamecallsTypeTagScannerTest::testScanReportsAnUnclosedTagRatherThanSwallowingTheFilecallsBisonAlternativeReaderTestcallsBisonRuleReaderTestcallsLemonParserTest::testParseThrowsOnNoRulescalls
Relations§
Static calls 8
- static-call SqlFaker\Compiler\Bison\BisonParser::parse() packages/sql-faker/src/Compiler/Bison/BisonParser.php:69
- static-call SqlFaker\Compiler\Bison\BisonParser::parseFile() packages/sql-faker/src/Compiler/Bison/BisonParser.php:93
- static-call SqlFaker\Compiler\Bison\BisonParser::parseFile() packages/sql-faker/src/Compiler/Bison/BisonParser.php:98
- static-call SqlFaker\Compiler\Bison\Lexer\BisonLexer::scan() packages/sql-faker/src/Compiler/Bison/Lexer/BisonLexer.php:65
- static-call SqlFaker\Compiler\Bison\Lexer\BisonTrivia::skipFrom() packages/sql-faker/src/Compiler/Bison/Lexer/BisonTrivia.php:43
- static-call SqlFaker\Compiler\Bison\Lexer\DirectiveScanner::scanDirectiveName() packages/sql-faker/src/Compiler/Bison/Lexer/DirectiveScanner.php:105
- static-call SqlFaker\Compiler\Bison\Lexer\TypeTagScanner::scan() packages/sql-faker/src/Compiler/Bison/Lexer/TypeTagScanner.php:52
- static-call SqlFaker\Compiler\Lemon\LemonParser::parse() packages/sql-faker/src/Compiler/Lemon/LemonParser.php:66