classBisonDirectiveReaderChain
final class BisonDirectiveReaderChain
Restricted visibility: declared "@visibility root". Code outside that scope must not name this declaration.
Routes a directive to the reader that knows its arguments.
The order matters here in a way it does not for the lexer's scanners: the reader for unknown directives accepts everything, so it has to be consulted last. Keeping that in one place is what lets every other reader answer only for itself.
Methods§
public function __construct(private list<BisonDirectiveReader> $readers)Parameters
$readers | list<BisonDirectiveReader> | Readers in the order they are consulted |
Test cases 12
BisonDirectiveReaderChainTest::testForBisonGrammarConsultsTheUnknownReaderLastcoversBisonDirectiveReaderChainTest::testReadDeclaresNothingWhenNoReaderClaimsTheDirectivecoversBisonDirectiveReaderChainTest::testReadFallsBackToTheUnknownReaderRatherThanDroppingADirectivecoversBisonDirectiveReaderChainTest::testReadRoutesEachDirectiveToTheReaderThatKnowsIt#anything elsecoversBisonDirectiveReaderChainTest::testReadRoutesEachDirectiveToTheReaderThatKnowsIt#definecoversBisonDirectiveReaderChainTest::testReadRoutesEachDirectiveToTheReaderThatKnowsIt#expectcoversBisonDirectiveReaderChainTest::testReadRoutesEachDirectiveToTheReaderThatKnowsIt#leftcoversBisonDirectiveReaderChainTest::testReadRoutesEachDirectiveToTheReaderThatKnowsIt#parse-paramcoversBisonDirectiveReaderChainTest::testReadRoutesEachDirectiveToTheReaderThatKnowsIt#rightcoversBisonDirectiveReaderChainTest::testReadRoutesEachDirectiveToTheReaderThatKnowsIt#startcoversBisonDirectiveReaderChainTest::testReadRoutesEachDirectiveToTheReaderThatKnowsIt#tokencoversBisonDirectiveReaderChainTest::testReadRoutesEachDirectiveToTheReaderThatKnowsIt#typecovers
public static function forBisonGrammar(): selfBuilds the chain covering the directives this parser models.
Returns
self A chain ending in the reader that accepts anything left overTest cases 12
BisonDirectiveReaderChainTest::testForBisonGrammarConsultsTheUnknownReaderLastcovers and callsBisonDirectiveReaderChainTest::testReadFallsBackToTheUnknownReaderRatherThanDroppingADirectivecovers and callsBisonDirectiveReaderChainTest::testReadRoutesEachDirectiveToTheReaderThatKnowsItcallsBisonDirectiveReaderChainTest::testReadRoutesEachDirectiveToTheReaderThatKnowsIt#anything elsecoversBisonDirectiveReaderChainTest::testReadRoutesEachDirectiveToTheReaderThatKnowsIt#definecoversBisonDirectiveReaderChainTest::testReadRoutesEachDirectiveToTheReaderThatKnowsIt#expectcoversBisonDirectiveReaderChainTest::testReadRoutesEachDirectiveToTheReaderThatKnowsIt#leftcoversBisonDirectiveReaderChainTest::testReadRoutesEachDirectiveToTheReaderThatKnowsIt#parse-paramcoversBisonDirectiveReaderChainTest::testReadRoutesEachDirectiveToTheReaderThatKnowsIt#rightcoversBisonDirectiveReaderChainTest::testReadRoutesEachDirectiveToTheReaderThatKnowsIt#startcoversBisonDirectiveReaderChainTest::testReadRoutesEachDirectiveToTheReaderThatKnowsIt#tokencoversBisonDirectiveReaderChainTest::testReadRoutesEachDirectiveToTheReaderThatKnowsIt#typecovers
Called from 1
Calls 10
- new BisonDeclarationBoundary line 36
- new
selfline 38 - new StartDirectiveReader line 39
- new TokenDirectiveReader line 40
- new TypeDirectiveReader line 41
- new PrecedenceDirectiveReader line 42
- new ParamDirectiveReader line 43
- new ExpectDirectiveReader line 44
- new DefineDirectiveReader line 45
- new UnknownDirectiveReader line 46
public function read(BisonTokenStream $stream, string $directive): BisonDeclaration|nullConsumes one declaration's arguments with the reader that claims it.
Parameters
$stream | BisonTokenStream | Stream positioned just after the directive name |
$directive | string | Directive name including its percent sign |
Returns
BisonDeclaration|null The declaration, or null when no reader claimed it
or the arguments were not the expected shapeTest cases 12
BisonDirectiveReaderChainTest::testForBisonGrammarConsultsTheUnknownReaderLastcoversBisonDirectiveReaderChainTest::testReadDeclaresNothingWhenNoReaderClaimsTheDirectivecovers and callsBisonDirectiveReaderChainTest::testReadFallsBackToTheUnknownReaderRatherThanDroppingADirectivecoversBisonDirectiveReaderChainTest::testReadRoutesEachDirectiveToTheReaderThatKnowsIt#anything elsecoversBisonDirectiveReaderChainTest::testReadRoutesEachDirectiveToTheReaderThatKnowsIt#definecoversBisonDirectiveReaderChainTest::testReadRoutesEachDirectiveToTheReaderThatKnowsIt#expectcoversBisonDirectiveReaderChainTest::testReadRoutesEachDirectiveToTheReaderThatKnowsIt#leftcoversBisonDirectiveReaderChainTest::testReadRoutesEachDirectiveToTheReaderThatKnowsIt#parse-paramcoversBisonDirectiveReaderChainTest::testReadRoutesEachDirectiveToTheReaderThatKnowsIt#rightcoversBisonDirectiveReaderChainTest::testReadRoutesEachDirectiveToTheReaderThatKnowsIt#startcoversBisonDirectiveReaderChainTest::testReadRoutesEachDirectiveToTheReaderThatKnowsIt#tokencoversBisonDirectiveReaderChainTest::testReadRoutesEachDirectiveToTheReaderThatKnowsIt#typecovers
Private surface 1§
Implementation details, listed for orientation only.
private list<BisonDirectiveReader> $readersTest cases 15§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 13
BisonDirectiveReaderChainTest::testForBisonGrammarConsultsTheUnknownReaderLastcovers and callsBisonDirectiveReaderChainTest::testReadDeclaresNothingWhenNoReaderClaimsTheDirectivecovers and callsBisonDirectiveReaderChainTest::testReadFallsBackToTheUnknownReaderRatherThanDroppingADirectivecovers and callsBisonDirectiveReaderChainTest::testReadRoutesEachDirectiveToTheReaderThatKnowsItcallsBisonDirectiveReaderChainTest::testReadRoutesEachDirectiveToTheReaderThatKnowsIt#anything elsecoversBisonDirectiveReaderChainTest::testReadRoutesEachDirectiveToTheReaderThatKnowsIt#definecoversBisonDirectiveReaderChainTest::testReadRoutesEachDirectiveToTheReaderThatKnowsIt#expectcoversBisonDirectiveReaderChainTest::testReadRoutesEachDirectiveToTheReaderThatKnowsIt#leftcoversBisonDirectiveReaderChainTest::testReadRoutesEachDirectiveToTheReaderThatKnowsIt#parse-paramcoversBisonDirectiveReaderChainTest::testReadRoutesEachDirectiveToTheReaderThatKnowsIt#rightcoversBisonDirectiveReaderChainTest::testReadRoutesEachDirectiveToTheReaderThatKnowsIt#startcoversBisonDirectiveReaderChainTest::testReadRoutesEachDirectiveToTheReaderThatKnowsIt#tokencoversBisonDirectiveReaderChainTest::testReadRoutesEachDirectiveToTheReaderThatKnowsIt#typecovers