classBisonRuleReader
final class BisonRuleReader
Restricted visibility: declared "@visibility root". Code outside that scope must not name this declaration.
Reads the rules section of a Bison grammar.
Recognizes a rule by its identifier and following colon. Tokens outside that pattern are skipped so reading can resume at the next rule boundary.
Methods§
public function __construct(BisonAlternativeReader|null $alternatives = null)Parameters
$alternatives | BisonAlternativeReader|null | Reads the right-hand side of each rule |
Test cases 7
BisonRuleReaderTest::testReadAllFindsNoRulesInAnEmptySectioncoversBisonRuleReaderTest::testReadAllKeepsTheRulesInTheOrderTheyWereDeclaredcoversBisonRuleReaderTest::testReadAllSkipsWhatDoesNotOpenARulecoversBisonRuleReaderTest::testReadAllStopsAtTheSectionSeparatorcoversBisonRuleReaderTest::testReadConsumesTheNameItRejectedSoTheScanCanAdvancecoversBisonRuleReaderTest::testReadFindsNoRuleWhenNoColonFollowsTheNamecoversBisonRuleReaderTest::testReadTakesTheRuleNameAndItsAlternativescovers
Calls 1
public function readAll(BisonTokenStream $stream): list<BisonRuleNode>Reads every rule up to the end of the section.
Parameters
$stream | BisonTokenStream | Stream positioned at the start of the rules section |
Returns
list<BisonRuleNode> The rules, in the order they were declaredTest cases 4
BisonRuleReaderTest::testReadAllFindsNoRulesInAnEmptySectioncovers and callsBisonRuleReaderTest::testReadAllKeepsTheRulesInTheOrderTheyWereDeclaredcovers and callsBisonRuleReaderTest::testReadAllSkipsWhatDoesNotOpenARulecovers and callsBisonRuleReaderTest::testReadAllStopsAtTheSectionSeparatorcovers and calls
Called from 1
Calls 6
- method-call BisonTokenStream::peek() line 43
- class-const BisonLexeme::Eof() line 43
- class-const BisonLexeme::PercentPercent() line 44
- method-call BisonTokenStream::next() line 45
- class-const BisonLexeme::Identifier() line 49
- method-call BisonRuleReader::read() line 54
public function read(BisonTokenStream $stream): BisonRuleNode|nullReads one rule and its alternatives.
Parameters
$stream | BisonTokenStream | Stream positioned on a candidate rule name |
Returns
BisonRuleNode|null The rule, or null when the identifier did not open oneTest cases 6
BisonRuleReaderTest::testReadAllKeepsTheRulesInTheOrderTheyWereDeclaredcoversBisonRuleReaderTest::testReadAllSkipsWhatDoesNotOpenARulecoversBisonRuleReaderTest::testReadAllStopsAtTheSectionSeparatorcoversBisonRuleReaderTest::testReadConsumesTheNameItRejectedSoTheScanCanAdvancecovers and callsBisonRuleReaderTest::testReadFindsNoRuleWhenNoColonFollowsTheNamecovers and callsBisonRuleReaderTest::testReadTakesTheRuleNameAndItsAlternativescovers and calls
Called from 1
Calls 6
- method-call BisonTokenStream::peekN() line 72
- class-const BisonLexeme::Colon() line 72
- method-call BisonTokenStream::next() line 73
- method-call BisonTokenStream::nextString() line 78
- new BisonRuleNode line 81
- method-call BisonAlternativeReader::readAll() line 81
Private surface 1§
Implementation details, listed for orientation only.
private BisonAlternativeReader $alternativesTest cases 8§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 7
BisonRuleReaderTest::testReadAllFindsNoRulesInAnEmptySectioncovers and callsBisonRuleReaderTest::testReadAllKeepsTheRulesInTheOrderTheyWereDeclaredcovers and callsBisonRuleReaderTest::testReadAllSkipsWhatDoesNotOpenARulecovers and callsBisonRuleReaderTest::testReadAllStopsAtTheSectionSeparatorcovers and callsBisonRuleReaderTest::testReadConsumesTheNameItRejectedSoTheScanCanAdvancecovers and callsBisonRuleReaderTest::testReadFindsNoRuleWhenNoColonFollowsTheNamecovers and callsBisonRuleReaderTest::testReadTakesTheRuleNameAndItsAlternativescovers and calls
Other tests reaching this symbol 1
BisonParserTestcalls