final class Location
Public API: explicitly declared with @visibility public.

A position in a grammar file, counted from one.

Lemon reports line numbers; the column is added so that a tool can point at the exact character. Lines blanked by the preprocessor keep their newlines, so positions in the tree are positions in the original file.

Reading where a rule beginsdoctest
$file = (new \LemonParser\Parser())->parse("%token_prefix TK_\nexpr ::= expr PLUS expr.\n");
    (string) $file->rules()[0]->location // => "2:1"

Properties§

public int $line
public int $column

Methods§

public function __construct(public int $line, public int $column)

Parameters

$lineintLine number, counted from one
$columnintColumn number, counted from one
public function __toString(): string

Writes the position as line:column.

Returns

string The position

Test cases 89§

Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.

Dedicated tests 1
Other tests reaching this symbol 88

Relations§

Instantiated in 3
Type declarations 38