classIdentifierScanner
final class IdentifierScanner
implements BisonScanner
Restricted visibility: declared "@visibility root". Code outside that scope must not name this declaration.
Consumes a symbol name.
Rule names and token names share one spelling in Bison: which of the two a name refers to is decided by the parser from where it appears, not by the lexer. Digits and dots may follow the first character but may not open the name, which is what keeps a number from being read as an identifier.
Methods§
public function handles(string $character): boolReports whether a symbol name can start here.
Parameters
$character | string | A single character; never the empty string |
Returns
bool True for a letter or an underscoreTest cases 2
IdentifierScannerTest::testHandlesClaimsALetterOrUnderscorecovers and callsIdentifierScannerTest::testHandlesRejectsADigitcovers and calls
Calls 1
- function-call
preg_matchline 31
public function scan(SourceCursor $cursor): BisonTokenConsumes the name.
Parameters
$cursor | SourceCursor | Cursor positioned on the first character |
Returns
BisonToken The symbol nameTest cases 2
IdentifierScannerTest::testScanAllowsDigitsAndDotsAfterTheFirstCharactercovers and callsIdentifierScannerTest::testScanCarriesTheNameSpellingcovers and calls
Calls 5
- method-call SourceCursor::offset() line 44
- method-call SourceCursor::takeWhile() line 45
- function-call
preg_matchline 46 - new BisonToken line 49
- class-const BisonLexeme::Identifier() line 49
Test cases 23§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 4
IdentifierScannerTest::testHandlesClaimsALetterOrUnderscorecovers and callsIdentifierScannerTest::testHandlesRejectsADigitcovers and callsIdentifierScannerTest::testScanAllowsDigitsAndDotsAfterTheFirstCharactercovers and callsIdentifierScannerTest::testScanCarriesTheNameSpellingcovers and calls
Other tests reaching this symbol 19
BisonParserTestcallsBisonPreambleReaderTestcallsBisonDirectiveReaderChainTestcallsDefineDirectiveReaderTestcallsExpectDirectiveReaderTestcallsParamDirectiveReaderTestcallsPrecedenceDirectiveReaderTestcallsStartDirectiveReaderTestcallsTokenDirectiveReaderTestcallsTypeDirectiveReaderTestcallsUnknownDirectiveReaderTestcallsBisonLexerTest::testScanRejectsWhatTheGivenChainDoesNotCovercallsBisonLexerTest::testScanUsesTheChainItWasGivencallsBisonScannerChainTest::providerClaimedCharactercallsBisonScannerChainTest::testScannerForReturnsTheFirstScannerThatClaimsTheCharactercallsBisonScannerTest::providerScannercallsBisonTokenStreamTestcallsBisonAlternativeReaderTestcallsBisonRuleReaderTestcalls