classPunctuationScanner
final class PunctuationScanner
implements BisonScanner
Restricted visibility: declared "@visibility root". Code outside that scope must not name this declaration.
Consumes a single punctuation character.
Three of these carry grammatical weight — a colon opens a rule's alternatives, a pipe separates them and a semicolon closes the rule — so each gets a lexeme of its own. The rest appear only inside directive arguments, where the parser needs the character but not a distinct lexeme for it, and they are reported as the character they are.
Methods§
public function handles(string $character): boolReports whether the character is punctuation the grammar language uses.
Parameters
$character | string | A single character; never the empty string |
Returns
bool True for a punctuation characterTest cases 11
PunctuationScannerTest::testHandlesRejectsCharactersItDoesNotOwncovers and callsPunctuationScannerTest::testScanReadsEachPunctuationCharacterAsItsOwnLexemecallsPunctuationScannerTest::testScanReadsEachPunctuationCharacterAsItsOwnLexeme#close bracketcoversPunctuationScannerTest::testScanReadsEachPunctuationCharacterAsItsOwnLexeme#close parencoversPunctuationScannerTest::testScanReadsEachPunctuationCharacterAsItsOwnLexeme#colon opens the alternativescoversPunctuationScannerTest::testScanReadsEachPunctuationCharacterAsItsOwnLexeme#commacoversPunctuationScannerTest::testScanReadsEachPunctuationCharacterAsItsOwnLexeme#equalscoversPunctuationScannerTest::testScanReadsEachPunctuationCharacterAsItsOwnLexeme#open bracketcoversPunctuationScannerTest::testScanReadsEachPunctuationCharacterAsItsOwnLexeme#open parencoversPunctuationScannerTest::testScanReadsEachPunctuationCharacterAsItsOwnLexeme#pipe separates alternativescoversPunctuationScannerTest::testScanReadsEachPunctuationCharacterAsItsOwnLexeme#semicolon closes the rulecovers
Calls 1
- function-call
str_containsline 32
public function scan(SourceCursor $cursor): BisonTokenConsumes the character.
Parameters
$cursor | SourceCursor | Cursor positioned on the punctuation |
Returns
BisonToken The punctuation as its own lexeme, or as a character literalTest cases 10
PunctuationScannerTest::testScanReadsEachPunctuationCharacterAsItsOwnLexemecallsPunctuationScannerTest::testScanReadsEachPunctuationCharacterAsItsOwnLexeme#close bracketcoversPunctuationScannerTest::testScanReadsEachPunctuationCharacterAsItsOwnLexeme#close parencoversPunctuationScannerTest::testScanReadsEachPunctuationCharacterAsItsOwnLexeme#colon opens the alternativescoversPunctuationScannerTest::testScanReadsEachPunctuationCharacterAsItsOwnLexeme#commacoversPunctuationScannerTest::testScanReadsEachPunctuationCharacterAsItsOwnLexeme#equalscoversPunctuationScannerTest::testScanReadsEachPunctuationCharacterAsItsOwnLexeme#open bracketcoversPunctuationScannerTest::testScanReadsEachPunctuationCharacterAsItsOwnLexeme#open parencoversPunctuationScannerTest::testScanReadsEachPunctuationCharacterAsItsOwnLexeme#pipe separates alternativescoversPunctuationScannerTest::testScanReadsEachPunctuationCharacterAsItsOwnLexeme#semicolon closes the rulecovers
Calls 8
- method-call SourceCursor::offset() line 45
- method-call SourceCursor::current() line 46
- method-call SourceCursor::advance() line 47
- class-const BisonLexeme::Colon() line 50
- class-const BisonLexeme::Semicolon() line 51
- class-const BisonLexeme::Pipe() line 52
- class-const BisonLexeme::CharLiteral() line 53
- new BisonToken line 56
Test cases 28§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 11
PunctuationScannerTest::testHandlesRejectsCharactersItDoesNotOwncovers and callsPunctuationScannerTest::testScanReadsEachPunctuationCharacterAsItsOwnLexemecallsPunctuationScannerTest::testScanReadsEachPunctuationCharacterAsItsOwnLexeme#close bracketcoversPunctuationScannerTest::testScanReadsEachPunctuationCharacterAsItsOwnLexeme#close parencoversPunctuationScannerTest::testScanReadsEachPunctuationCharacterAsItsOwnLexeme#colon opens the alternativescoversPunctuationScannerTest::testScanReadsEachPunctuationCharacterAsItsOwnLexeme#commacoversPunctuationScannerTest::testScanReadsEachPunctuationCharacterAsItsOwnLexeme#equalscoversPunctuationScannerTest::testScanReadsEachPunctuationCharacterAsItsOwnLexeme#open bracketcoversPunctuationScannerTest::testScanReadsEachPunctuationCharacterAsItsOwnLexeme#open parencoversPunctuationScannerTest::testScanReadsEachPunctuationCharacterAsItsOwnLexeme#pipe separates alternativescoversPunctuationScannerTest::testScanReadsEachPunctuationCharacterAsItsOwnLexeme#semicolon closes the rulecovers
Other tests reaching this symbol 17
BisonParserTestcallsBisonPreambleReaderTestcallsBisonDirectiveReaderChainTestcallsDefineDirectiveReaderTestcallsExpectDirectiveReaderTestcallsParamDirectiveReaderTestcallsPrecedenceDirectiveReaderTestcallsStartDirectiveReaderTestcallsTokenDirectiveReaderTestcallsTypeDirectiveReaderTestcallsUnknownDirectiveReaderTestcallsBisonLexerTestcallsBisonScannerChainTest::providerClaimedCharactercallsBisonScannerTest::providerScannercallsBisonTokenStreamTestcallsBisonAlternativeReaderTestcallsBisonRuleReaderTestcalls