TokenStream
final class TokenStream
TokenStream loads tokens from $source iterator on-demand, and places them in a buffer to provide access to any previous token by index.
Methods
Tells whether the token at current position is of given kind.
Gets the token at $offset from the current position.
Consumes the current token (if is of given kind) or throws exception on end.
Consumes the current token of given kind or returns null.
Sets the input cursor to the position.
Returns the cursor position.
No description
Details
at line 26
__construct(Iterator $source)
No description
at line 35
bool
is(int|string ...$kind)
Tells whether the token at current position is of given kind.
at line 44
Token|null
peek(int $offset = 0)
Gets the token at $offset from the current position.
at line 65
Token
consume(int|string ...$kind)
Consumes the current token (if is of given kind) or throws exception on end.
at line 81
Token|null
tryConsume(int|string ...$kind)
Consumes the current token of given kind or returns null.
at line 96
void
seek(int $index)
Sets the input cursor to the position.
at line 108
int
getIndex()
Returns the cursor position.
at line 118
void
throwUnexpectedException(array $expected = [], string $addendum = '', string $excerpt = '')
No description