interface InputStream implements Iterator (View source)

Interface for stream readers.

The parser only reads from streams. Various input sources can write an adapater to this InputStream.

Currently provided InputStream implementations include FileInputStream and StringInputStream.

Methods

currentLine()

Returns the current line that is being consumed.

int
columnOffset()

Returns the current column of the current line that the tokenizer is at.

remainingChars()

Get all characters until EOF.

mixed
charsUntil( string $bytes, int $max = null)

Read to a particular match (or until $max bytes are consumed).

charsWhile( string $bytes, int $max = null)

Returns the string so long as $bytes matches.

unconsume( int $howMany = 1)

Unconsume one character.

peek()

Retrieve the next character without advancing the pointer.

Details

at line line 21
currentLine()

Returns the current line that is being consumed.

TODO: Move this to the scanner.

at line line 32
int columnOffset()

Returns the current column of the current line that the tokenizer is at.

Newlines are column 0. The first char after a newline is column 1.

Return Value

int The column number.

at line line 39
remainingChars()

Get all characters until EOF.

This consumes characters until the EOF.

at line line 57
mixed charsUntil( string $bytes, int $max = null)

Read to a particular match (or until $max bytes are consumed).

This operates on byte sequences, not characters.

Matches as far as possible until we reach a certain set of bytes and returns the matched substring.

Parameters

string $bytes Bytes to match.
int $max Maximum number of bytes to scan.

Return Value

mixed Index or false if no match is found. You should use strong equality when checking the result, since index could be 0.

See also

strcspn

at line line 73
charsWhile( string $bytes, int $max = null)

Returns the string so long as $bytes matches.

Matches as far as possible with a certain set of bytes and returns the matched substring.

Parameters

string $bytes A mask of bytes to match. If ANY byte in this mask matches the current char, the pointer advances and the char is part of the substring.
int $max The max number of chars to read.

See also

strspn

at line line 81
unconsume( int $howMany = 1)

Unconsume one character.

Parameters

int $howMany The number of characters to move the pointer back.

at line line 86
peek()

Retrieve the next character without advancing the pointer.