classTokenDirectiveReader
final class TokenDirectiveReader
implements BisonDirectiveReader
Restricted visibility: declared "@visibility root". Code outside that scope must not name this declaration.
Reads %token, which names the terminals the scanner may hand the parser.
Each terminal is a name that may be followed by an explicit token code and by a quoted alias, in that order and both optional, so the entries have to be read one at a time rather than collected as a flat list of names.
Methods§
public function __construct(BisonDeclarationBoundary|null $boundary = null)Parameters
$boundary | BisonDeclarationBoundary|null | Decides where the declaration ends |
Test cases 10
TokenDirectiveReaderTest::testHandlesClaimsOnlyTheTokenDirectivecoversTokenDirectiveReaderTest::testReadReportsNoTypeTagWhenNoneIsWrittencoversTokenDirectiveReaderTest::testReadStopsAtTheNextDirectivecoversTokenDirectiveReaderTest::testReadTakesAnEmptyDeclarationAsNoTerminalscoversTokenDirectiveReaderTest::testReadTakesEveryTerminalNamedcoversTokenDirectiveReaderTest::testReadTakesTheOptionalTypeTagcoversTokenDirectiveReaderTest::testReadTerminalTakesACodeAndAnAliasTogethercoversTokenDirectiveReaderTest::testReadTerminalTakesTheAliascoversTokenDirectiveReaderTest::testReadTerminalTakesTheExplicitTokenCodecoversTokenDirectiveReaderTest::testReadTerminalTakesTheNameAlonecovers
Calls 1
public function handles(string $directive): boolReports whether the directive is %token.
Parameters
$directive | string | Directive name including its percent sign |
Returns
bool True for "%token"Test cases 1
TokenDirectiveReaderTest::testHandlesClaimsOnlyTheTokenDirectivecovers and calls
public function read(BisonTokenStream $stream, string $directive): BisonDeclarationConsumes the optional type tag and every terminal that follows it.
Parameters
$stream | BisonTokenStream | Stream positioned just after the directive name |
$directive | string | Directive name including its percent sign |
Returns
BisonDeclaration The declaration, with no terminals when none followedTest cases 5
TokenDirectiveReaderTest::testReadReportsNoTypeTagWhenNoneIsWrittencovers and callsTokenDirectiveReaderTest::testReadStopsAtTheNextDirectivecovers and callsTokenDirectiveReaderTest::testReadTakesAnEmptyDeclarationAsNoTerminalscovers and callsTokenDirectiveReaderTest::testReadTakesEveryTerminalNamedcovers and callsTokenDirectiveReaderTest::testReadTakesTheOptionalTypeTagcovers and calls
Calls 8
- method-call BisonTokenStream::nextIf() line 62
- class-const BisonLexeme::TypeTag() line 62
- method-call BisonDeclarationBoundary::continuesWith() line 66
- method-call BisonTokenStream::peek() line 66
- class-const BisonLexeme::Identifier() line 67
- method-call BisonTokenStream::next() line 68
- method-call TokenDirectiveReader::readTerminal() line 72
- new BisonTokenDeclaration line 75
public function readTerminal(BisonTokenStream $stream): BisonTokenDefinitionConsumes one terminal together with the code and alias it may carry.
Parameters
$stream | BisonTokenStream | Stream positioned on the terminal's name |
Returns
BisonTokenDefinition The terminal, with null for whatever it omittedTest cases 8
TokenDirectiveReaderTest::testReadReportsNoTypeTagWhenNoneIsWrittencoversTokenDirectiveReaderTest::testReadStopsAtTheNextDirectivecoversTokenDirectiveReaderTest::testReadTakesEveryTerminalNamedcoversTokenDirectiveReaderTest::testReadTakesTheOptionalTypeTagcoversTokenDirectiveReaderTest::testReadTerminalTakesACodeAndAnAliasTogethercovers and callsTokenDirectiveReaderTest::testReadTerminalTakesTheAliascovers and callsTokenDirectiveReaderTest::testReadTerminalTakesTheExplicitTokenCodecovers and callsTokenDirectiveReaderTest::testReadTerminalTakesTheNameAlonecovers and calls
Called from 1
Calls 5
- new BisonTokenDefinition line 87
- method-call BisonTokenStream::nextString() line 88
- method-call BisonTokenStream::nextIf() line 89
- class-const BisonLexeme::Number() line 89
- class-const BisonLexeme::StringLiteral() line 90
Private surface 1§
Implementation details, listed for orientation only.
private BisonDeclarationBoundary $boundaryTest cases 14§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 10
TokenDirectiveReaderTest::testHandlesClaimsOnlyTheTokenDirectivecovers and callsTokenDirectiveReaderTest::testReadReportsNoTypeTagWhenNoneIsWrittencovers and callsTokenDirectiveReaderTest::testReadStopsAtTheNextDirectivecovers and callsTokenDirectiveReaderTest::testReadTakesAnEmptyDeclarationAsNoTerminalscovers and callsTokenDirectiveReaderTest::testReadTakesEveryTerminalNamedcovers and callsTokenDirectiveReaderTest::testReadTakesTheOptionalTypeTagcovers and callsTokenDirectiveReaderTest::testReadTerminalTakesACodeAndAnAliasTogethercovers and callsTokenDirectiveReaderTest::testReadTerminalTakesTheAliascovers and callsTokenDirectiveReaderTest::testReadTerminalTakesTheExplicitTokenCodecovers and callsTokenDirectiveReaderTest::testReadTerminalTakesTheNameAlonecovers and calls