final class TokenStream

internal  
 

Methods

__construct(array $tokens)

No description

int
getPos()

No description

void
seek(int $position)

No description

array
getTokens()

No description

bool
isNext(int|string ...$types)

Skips comments and whitespace, then checks whether the next token matches one of the given types.

Token|null
consume(int|string ...$types)

Consumes and returns the next token if it matches one of the given types, or null otherwise.

string
getIndentation()

Returns the whitespace indentation of the token at the current position, i.e. the whitespace token immediately following a newline (or at the start).

void
error(string|null $message = null, int|null $pos = null)

No description

Details

at line 19
__construct(array $tokens)

No description

Parameters

array $tokens

at line 26
int getPos()

No description

Return Value

int

at line 32
void seek(int $position)

No description

Parameters

int $position

Return Value

void

at line 39
array getTokens()

No description

Return Value

array

at line 49
bool isNext(int|string ...$types)

Skips comments and whitespace, then checks whether the next token matches one of the given types.

With no arguments, checks whether any token remains.

Parameters

int|string ...$types

Return Value

bool

at line 65
Token|null consume(int|string ...$types)

Consumes and returns the next token if it matches one of the given types, or null otherwise.

With no arguments, consumes any next token.

Parameters

int|string ...$types

Return Value

Token|null

at line 77
string getIndentation()

Returns the whitespace indentation of the token at the current position, i.e. the whitespace token immediately following a newline (or at the start).

Return Value

string

at line 87
void error(string|null $message = null, int|null $pos = null)

No description

Parameters

string|null $message
int|null $pos

Return Value

void