Documentation

TokenStream
in package

Represents a token stream.

Tags
author

Fabien Potencier fabien@symfony.com

Table of Contents

$current  : mixed
$source  : mixed
$tokens  : mixed
__construct()  : mixed
__toString()  : mixed
expect()  : Token
Tests a token and returns it or throws a syntax error.
getCurrent()  : Token
injectTokens()  : mixed
isEOF()  : bool
Checks if end of stream was reached.
look()  : Token
Looks at the next token.
next()  : Token
Sets the pointer to the next token and returns the old one.
nextIf()  : Token|null
Tests a token, sets the pointer to the next one and returns it or throws a syntax error.
test()  : bool
Tests the current token.

Properties

Methods

__construct()

public __construct(array<string|int, mixed> $tokens[, Source $source = null ]) : mixed
Parameters
$tokens : array<string|int, mixed>
$source : Source = null
Return values
mixed

__toString()

public __toString() : mixed
Return values
mixed

expect()

Tests a token and returns it or throws a syntax error.

public expect(mixed $type[, mixed $value = null ][, string $message = null ]) : Token
Parameters
$type : mixed
$value : mixed = null
$message : string = null
Return values
Token

injectTokens()

public injectTokens(array<string|int, mixed> $tokens) : mixed
Parameters
$tokens : array<string|int, mixed>
Return values
mixed

isEOF()

Checks if end of stream was reached.

public isEOF() : bool
Return values
bool

look()

Looks at the next token.

public look([int $number = 1 ]) : Token
Parameters
$number : int = 1
Return values
Token

next()

Sets the pointer to the next token and returns the old one.

public next() : Token
Return values
Token

nextIf()

Tests a token, sets the pointer to the next one and returns it or throws a syntax error.

public nextIf(mixed $primary[, mixed $secondary = null ]) : Token|null
Parameters
$primary : mixed
$secondary : mixed = null
Return values
Token|null

The next token if the condition is true, null otherwise

test()

Tests the current token.

public test(mixed $primary[, mixed $secondary = null ]) : bool
Parameters
$primary : mixed
$secondary : mixed = null
Return values
bool

Search results