class Stream

Stream of tokens.

Properties

Token[] $tokens
int $position
array $ignored

Methods

__construct(array $tokens)

No description

Token|null
currentToken()

Returns current token.

string|null
currentValue()

Returns current token value.

Token|null
nextToken(int|string ...$args)

Returns next token.

string|null
nextValue(int|string ...$args)

Returns next token value.

array
nextAll(int|string ...$args)

Returns all next tokens.

array
nextUntil(int|string ...$args)

Returns all next tokens until it sees a given token type or value.

consumeToken(int|string ...$args)

Returns next token or throws exception.

string
consumeValue(int|string ...$args)

Returns next token value or throws exception.

string
joinAll(int|string ...$args)

Returns concatenation of all next token values.

string
joinUntil(int|string ...$args)

Returns concatenation of all next tokens until it sees a given token type or value.

bool
isCurrent(int|string ...$args)

Checks the current token.

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

Checks the next token existence.

bool
isPrev(int|string ...$args)

Checks the previous token existence.

reset()

No description

void
next()

Moves cursor to next token.

mixed
scan(array $wanted, bool $onlyFirst, bool $advance, bool $strings = false, bool $until = false, bool $prev = false)

Looks for (first) (not) wanted tokens.

Details

at line 31
__construct(array $tokens)

No description

Parameters

array $tokens

at line 40
Token|null currentToken()

Returns current token.

Return Value

Token|null

at line 49
string|null currentValue()

Returns current token value.

Return Value

string|null

at line 59
Token|null nextToken(int|string ...$args)

Returns next token.

Parameters

int|string ...$args

desired token type or value

Return Value

Token|null

at line 69
string|null nextValue(int|string ...$args)

Returns next token value.

Parameters

int|string ...$args

desired token type or value

Return Value

string|null

at line 80
array nextAll(int|string ...$args)

Returns all next tokens.

Parameters

int|string ...$args

desired token type or value

Return Value

array

at line 91
array nextUntil(int|string ...$args)

Returns all next tokens until it sees a given token type or value.

Parameters

int|string ...$args

token type or value to stop before (required)

Return Value

array

at line 102
Token consumeToken(int|string ...$args)

Returns next token or throws exception.

Parameters

int|string ...$args

desired token type or value

Return Value

Token

Exceptions

Exception

at line 132
string consumeValue(int|string ...$args)

Returns next token value or throws exception.

Parameters

int|string ...$args

desired token type or value

Return Value

string

Exceptions

Exception

at line 142
string joinAll(int|string ...$args)

Returns concatenation of all next token values.

Parameters

int|string ...$args

token type or value to be joined

Return Value

string

at line 152
string joinUntil(int|string ...$args)

Returns concatenation of all next tokens until it sees a given token type or value.

Parameters

int|string ...$args

token type or value to stop before (required)

Return Value

string

at line 162
bool isCurrent(int|string ...$args)

Checks the current token.

Parameters

int|string ...$args

token type or value

Return Value

bool

at line 173
bool isNext(int|string ...$args)

Checks the next token existence.

Parameters

int|string ...$args

token type or value

Return Value

bool

at line 183
bool isPrev(int|string ...$args)

Checks the previous token existence.

Parameters

int|string ...$args

token type or value

Return Value

bool

at line 192
Stream reset()

No description

Return Value

Stream

at line 202
protected void next()

Moves cursor to next token.

Return Value

void

at line 212
protected mixed scan(array $wanted, bool $onlyFirst, bool $advance, bool $strings = false, bool $until = false, bool $prev = false)

Looks for (first) (not) wanted tokens.

Parameters

array $wanted
bool $onlyFirst
bool $advance
bool $strings
bool $until
bool $prev

Return Value

mixed