classDefineDirectiveReader
final class DefineDirectiveReader
implements BisonDirectiveReader
Restricted visibility: declared "@visibility root". Code outside that scope must not name this declaration.
Reads %define, which sets a named option of the generated parser.
The value is optional: %define api.pure is a flag, while %define api.prefix "yy" carries a setting. A name on its own is therefore not an error, and the value is only taken when something that can be one follows.
Methods§
public function handles(string $directive): boolReports whether the directive is %define.
Parameters
$directive | string | Directive name including its percent sign |
Returns
bool True for "%define"Test cases 1
DefineDirectiveReaderTest::testHandlesClaimsOnlyTheDefineDirectivecovers and calls
public function read(BisonTokenStream $stream, string $directive): BisonDeclaration|nullConsumes the option name and, when present, its value.
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 option name followsTest cases 5
DefineDirectiveReaderTest::testReadDeclaresNothingWhenNoNameFollowscovers and callsDefineDirectiveReaderTest::testReadStopsBeforeTheNextDirectivecovers and callsDefineDirectiveReaderTest::testReadTakesANameWithoutAValueAsAFlagcovers and callsDefineDirectiveReaderTest::testReadTakesANumericValuecovers and callsDefineDirectiveReaderTest::testReadTakesAQuotedValuecovers and calls
Calls 5
- method-call BisonTokenStream::nextIf() line 51
- class-const BisonLexeme::Identifier() line 51
- class-const BisonLexeme::StringLiteral() line 58
- class-const BisonLexeme::Number() line 59
- new BisonDefineDeclaration line 62
Test cases 10§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 6
DefineDirectiveReaderTest::testHandlesClaimsOnlyTheDefineDirectivecovers and callsDefineDirectiveReaderTest::testReadDeclaresNothingWhenNoNameFollowscovers and callsDefineDirectiveReaderTest::testReadStopsBeforeTheNextDirectivecovers and callsDefineDirectiveReaderTest::testReadTakesANameWithoutAValueAsAFlagcovers and callsDefineDirectiveReaderTest::testReadTakesANumericValuecovers and callsDefineDirectiveReaderTest::testReadTakesAQuotedValuecovers and calls