classToken
final class Token
Restricted visibility: declared "@visibility root". Code outside that scope must not name this declaration.
One token of a grammar file.
The text is what the token stands for: a string or code without its delimiters, a compound token without its | or /. The raw spelling is what was written, for error messages.
Properties§
public TokenKind $kindpublic string $textpublic Location $locationpublic string $rawMethods§
public function is(TokenKind $kind): boolReports whether the token is of a given kind.
Parameters
$kind | TokenKind | Kind to compare with |
Returns
bool True when the kinds matchTest cases 1
TokenTest::testIscalls
public function isPunctuation(string $character): boolReports whether the token is a given punctuation character.
Parameters
$character | string | The character |
Returns
bool True for that characterTest cases 1
Calls 1
- class-const TokenKind::Punctuation() line 55
public function isUpperWord(): boolReports whether the token is a word starting with an upper-case letter.
Returns
bool True for a terminal nameTest cases 1
Calls 2
- class-const TokenKind::Word() line 65
- function-call
ctype_upperline 65
public function isLowerWord(): boolReports whether the token is a word starting with a lower-case letter.
Returns
bool True for a nonterminal nameTest cases 1
Calls 2
- class-const TokenKind::Word() line 75
- function-call
ctype_lowerline 75
public function isAlphaWord(): boolReports whether the token is a word starting with a letter.
Returns
bool True for a symbol nameTest cases 1
Calls 2
- class-const TokenKind::Word() line 85
- function-call
ctype_alphaline 85
Test cases 23§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 5
Other tests reaching this symbol 18
LemonGrammarCompilerTestcallsLemonGrammarReaderTestcallsParserTestcallsScannerTest::testScancallsDeclarationReaderTest::testArgumentcallsDeclarationReaderTest::testArgumentRejectsPunctuationcallsGrammarReaderTest::testCodecallsGrammarReaderTest::testCodeRejectsAMissingRulecallsGrammarReaderTest::testCodeRejectsASecondBlockcallsRuleReaderTest::testAliascallsRuleReaderTest::testAliasRejectsABadNamecallsRuleReaderTest::testAliasRejectsAMissingClosercallsRuleReaderTest::testCompoundcallsRuleReaderTest::testCompoundRejectsANonterminalcallsSymbolListReaderTest::testUntilPeriodcallsTokenStreamTest::testEofcallsTokenStreamTest::testNextcallsTokenStreamTest::testPeekcalls
Relations§
Instantiated in 7
- new LemonParser\Scanner\Scanner::scan() packages/lemon-parser/src/Scanner/Scanner.php:42
- new LemonParser\Scanner\Scanner::next() packages/lemon-parser/src/Scanner/Scanner.php:91
- new LemonParser\Scanner\Scanner::next() packages/lemon-parser/src/Scanner/Scanner.php:96
- new LemonParser\Scanner\Scanner::next() packages/lemon-parser/src/Scanner/Scanner.php:100
- new LemonParser\Scanner\Scanner::next() packages/lemon-parser/src/Scanner/Scanner.php:103
- new LemonParser\Scanner\Scanner::next() packages/lemon-parser/src/Scanner/Scanner.php:107
- new LemonParser\Scanner\Scanner::next() packages/lemon-parser/src/Scanner/Scanner.php:111
Type declarations 9
- type LemonParser\Scanner\Scanner packages/lemon-parser/src/Scanner/Scanner.php:80
- type LemonParser\Syntax\DeclarationReader packages/lemon-parser/src/Syntax/DeclarationReader.php:88
- type LemonParser\Syntax\GrammarReader packages/lemon-parser/src/Syntax/GrammarReader.php:86
- type LemonParser\Syntax\RuleReader packages/lemon-parser/src/Syntax/RuleReader.php:32
- type LemonParser\Syntax\RuleReader packages/lemon-parser/src/Syntax/RuleReader.php:70
- type LemonParser\Syntax\RuleReader packages/lemon-parser/src/Syntax/RuleReader.php:105
- type LemonParser\Syntax\RuleReader packages/lemon-parser/src/Syntax/RuleReader.php:126
- type LemonParser\Syntax\TokenStream packages/lemon-parser/src/Syntax/TokenStream.php:31
- type LemonParser\Syntax\TokenStream packages/lemon-parser/src/Syntax/TokenStream.php:41