classGrammarFile
final class GrammarFile
Public API: explicitly declared with
@visibility public.A whole grammar file: rules and declarations in the order written.
Lemon has no sections; a declaration may appear anywhere, and precedence declarations rank tokens by the order they are written in, so the order is kept.
$file = (new \LemonParser\Parser())->parse("%left PLUS MINUS.\nexpr ::= expr PLUS expr.\n%name Calc\n");
[count($file->items), count($file->rules()), count($file->declarations())] // => [3, 1, 2]Properties§
public list<Rule|Declaration> $itemsMethods§
public function __construct(public list<Rule|Declaration> $items)Parameters
$items | list<Rule|Declaration> | Everything in the file, in order |
public function rules(): list<Rule>public function declarations(): list<Declaration>Test cases 9§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 2
Other tests reaching this symbol 7
GrammarContextcallsTreeDumpercallsLemonGrammarCompilerTestcallsLemonGrammarReaderTestcallsParserTestcallsPrinterTest::testPrintcallsGrammarReaderTestcalls
Relations§
Instantiated in 1
Method calls 2
Type declarations 4
- type LemonParser\Parser packages/lemon-parser/src/Parser.php:58
- type LemonParser\Printer\Printer packages/lemon-parser/src/Printer/Printer.php:42
- type LemonParser\Syntax\GrammarReader packages/lemon-parser/src/Syntax/GrammarReader.php:45
- type SqlFaker\Compiler\Lemon\LemonGrammarCompiler packages/sql-faker/src/Compiler/Lemon/LemonGrammarCompiler.php:118