classTypeDirectiveReader
final class TypeDirectiveReader
implements BisonDirectiveReader
Restricted visibility: declared "@visibility root". Code outside that scope must not name this declaration.
Reads %type, which gives rules the semantic type their values carry.
The type tag is what the directive exists for, so a %type without one declares nothing and is reported as absent rather than as an empty list.
Methods§
public function __construct(BisonDeclarationBoundary|null $boundary = null)Parameters
$boundary | BisonDeclarationBoundary|null | Decides where the declaration ends |
Test cases 5
TypeDirectiveReaderTest::testHandlesClaimsOnlyTheTypeDirectivecoversTypeDirectiveReaderTest::testReadDeclaresNothingWithoutATypeTagcoversTypeDirectiveReaderTest::testReadSkipsWhatIsNotARuleNamecoversTypeDirectiveReaderTest::testReadStopsAtTheNextDirectivecoversTypeDirectiveReaderTest::testReadTakesTheTypeTagAndTheRulesItAppliesTocovers
Calls 1
public function handles(string $directive): boolReports whether the directive is %type.
Parameters
$directive | string | Directive name including its percent sign |
Returns
bool True for "%type"Test cases 1
TypeDirectiveReaderTest::testHandlesClaimsOnlyTheTypeDirectivecovers and calls
public function read(BisonTokenStream $stream, string $directive): BisonDeclaration|nullConsumes the type tag and the rule names it applies to.
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 type tag followsTest cases 4
TypeDirectiveReaderTest::testReadDeclaresNothingWithoutATypeTagcovers and callsTypeDirectiveReaderTest::testReadSkipsWhatIsNotARuleNamecovers and callsTypeDirectiveReaderTest::testReadStopsAtTheNextDirectivecovers and callsTypeDirectiveReaderTest::testReadTakesTheTypeTagAndTheRulesItAppliesTocovers and calls
Calls 7
- method-call BisonTokenStream::nextIf() line 60
- class-const BisonLexeme::TypeTag() line 60
- method-call BisonDeclarationBoundary::continuesWith() line 67
- method-call BisonTokenStream::peek() line 67
- class-const BisonLexeme::Identifier() line 68
- method-call BisonTokenStream::next() line 70
- new BisonTypeDeclaration line 77
Private surface 1§
Implementation details, listed for orientation only.
private BisonDeclarationBoundary $boundaryTest cases 9§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 5
TypeDirectiveReaderTest::testHandlesClaimsOnlyTheTypeDirectivecovers and callsTypeDirectiveReaderTest::testReadDeclaresNothingWithoutATypeTagcovers and callsTypeDirectiveReaderTest::testReadSkipsWhatIsNotARuleNamecovers and callsTypeDirectiveReaderTest::testReadStopsAtTheNextDirectivecovers and callsTypeDirectiveReaderTest::testReadTakesTheTypeTagAndTheRulesItAppliesTocovers and calls