classNumberScanner
final class NumberScanner
implements BisonScanner
Restricted visibility: declared "@visibility root". Code outside that scope must not name this declaration.
Consumes a decimal number.
Numbers appear in a grammar as explicit token codes and as the counts of %expect, so the value is carried as an integer rather than as the digits that spelled it.
Methods§
public function handles(string $character): boolReports whether a number can start here.
Parameters
$character | string | A single character; never the empty string |
Returns
bool True for a decimal digitTest cases 1
NumberScannerTest::testHandlesClaimsOnlyADigitcovers and calls
Calls 1
- function-call
ctype_digitline 30
public function scan(SourceCursor $cursor): BisonTokenConsumes the run of digits.
Parameters
$cursor | SourceCursor | Cursor positioned on the first digit |
Returns
BisonToken The number as an integer valueTest cases 3
NumberScannerTest::testScanCarriesTheValueAsAnIntegercovers and callsNumberScannerTest::testScanReadsLeadingZeroescovers and callsNumberScannerTest::testScanStopsAtTheFirstNonDigitcovers and calls
Calls 5
- method-call SourceCursor::offset() line 43
- method-call SourceCursor::takeWhile() line 44
- function-call
ctype_digitline 44 - new BisonToken line 46
- class-const BisonLexeme::Number() line 46
Test cases 22§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 4
NumberScannerTest::testHandlesClaimsOnlyADigitcovers and callsNumberScannerTest::testScanCarriesTheValueAsAnIntegercovers and callsNumberScannerTest::testScanReadsLeadingZeroescovers and callsNumberScannerTest::testScanStopsAtTheFirstNonDigitcovers and calls
Other tests reaching this symbol 18
BisonParserTestcallsBisonPreambleReaderTestcallsBisonDirectiveReaderChainTestcallsDefineDirectiveReaderTestcallsExpectDirectiveReaderTestcallsParamDirectiveReaderTestcallsPrecedenceDirectiveReaderTestcallsStartDirectiveReaderTestcallsTokenDirectiveReaderTestcallsTypeDirectiveReaderTestcallsUnknownDirectiveReaderTestcallsBisonLexerTestcallsBisonScannerChainTest::providerClaimedCharactercallsBisonScannerChainTest::testScannerForReturnsTheFirstScannerThatClaimsTheCharactercallsBisonScannerTest::providerScannercallsBisonTokenStreamTestcallsBisonAlternativeReaderTestcallsBisonRuleReaderTestcalls