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.

Reading rules and declarationsdoctest
$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> $items

Methods§

public function __construct(public list<Rule|Declaration> $items)

Parameters

$itemslist<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

Relations§

Instantiated in 1
Method calls 2
Type declarations 4