classLemonDirectives
final class LemonDirectives
Restricted visibility: declared "@visibility root". Code outside that scope must not name this declaration.
Reads the tokens a Lemon grammar declares before any rule is written.
Lemon declares its tokens in several places: outright with %token, in passing while giving them a precedence, as a fallback, as a named class of tokens that stand for one another, and as the single wildcard token. Each form says the same thing — this name is a token — so all of them are read together and told to the symbol table.
Methods§
public function declareInto(string $input, LemonSymbols $symbols): voidTells the symbol table about every token the directives name.
Parameters
$input | string | Contents of the grammar file |
$symbols | LemonSymbols | Symbol table to record them in |
Test cases 5
LemonDirectivesTest::testDeclareIntoReadsAClassAndTheTokensItStandsForcovers and callsLemonDirectivesTest::testDeclareIntoReadsTheTokensNamedAsAFallbackcovers and callsLemonDirectivesTest::testDeclareIntoReadsTheTokensNamedOutrightcovers and callsLemonDirectivesTest::testDeclareIntoReadsTheTokensNamedWhileGivingThemAPrecedencecovers and callsLemonDirectivesTest::testDeclareIntoReadsTheWildcardTokencovers and calls
Called from 1
Calls 6
- function-call
preg_match_allline 35 - method-call LemonSymbols::declareTokensOn() line 37
- function-call
countline 43 - method-call LemonSymbols::declareRule() line 45
- function-call
preg_matchline 50 - method-call LemonSymbols::declareToken() line 51
public function tokenClasses(string $input): array<string, list<string>>Exposes each declared token class as its complete set of alternatives.
Parameters
$input | string |
Returns
array<string, list<string>>Test cases 2
Called from 1
Test cases 7§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 6
LemonDirectivesTest::testDeclareIntoReadsAClassAndTheTokensItStandsForcovers and callsLemonDirectivesTest::testDeclareIntoReadsTheTokensNamedAsAFallbackcovers and callsLemonDirectivesTest::testDeclareIntoReadsTheTokensNamedOutrightcovers and callsLemonDirectivesTest::testDeclareIntoReadsTheTokensNamedWhileGivingThemAPrecedencecovers and callsLemonDirectivesTest::testDeclareIntoReadsTheWildcardTokencovers and callsLemonDirectivesTest::testTokenClassesRetainsEveryAlternativeAcrossLinescovers and calls
Other tests reaching this symbol 1
LemonParserTestcalls