final class Cursor
Restricted visibility: declared "@visibility root". Code outside that scope must not name this declaration.

Reads a grammar file byte by byte, keeping the line and column.

Properties§

public string $source

Methods§

public function __construct(public string $source)

Parameters

$sourcestringThe whole file
public function offset(): int

Answers the current byte offset.

Returns

int Offset from the start of the file
Test cases 4
public function take(int $length): string

Consumes a number of bytes and answers them, counting the lines they hold.

Parameters

$lengthintHow many bytes to consume

Returns

string The consumed bytes
Test cases 14
Called from 16
Calls 4
public function match(string $pattern): string|null

Consumes what a pattern matches at the current position.

Parameters

$patternstringRegular expression without anchors or delimiters

Returns

string|null The matched text, or null when nothing matches here
Test cases 1
Called from 17
Calls 4
public function lookingAt(string $pattern): bool

Reports whether a pattern matches at the current position, without consuming it.

Parameters

$patternstringRegular expression without anchors or delimiters

Returns

bool True when it matches here
Test cases 1
Called from 1
Calls 2
public function takeUntil(string $needle): string|null

Consumes everything up to and including a delimiter.

Parameters

$needlestringText that ends the run

Returns

string|null The consumed text without the delimiter, or null when the file ends first
Test cases 1
Called from 1
Calls 3

Private surface 3§

Implementation details, listed for orientation only.

private int $offset = 0
private int $line = 1
private int $column = 1

Test cases 53§

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

Dedicated tests 9
Other tests reaching this symbol 44

Relations§

Instantiated in 1
Method calls 65
Type declarations 12