class FileInputStream extends StringInputStream implements InputStream

The FileInputStream loads a file to be parsed.

So right now we read files into strings and then process the string. We chose to do this largely for the sake of expediency of development, and also because we could optimize toward processing arbitrarily large chunks of the input. But in the future, we'd really like to rewrite this class to efficiently handle lower level stream reads (and thus efficiently handle large documents).

Properties

$errors Parse errors. from StringInputStream

Methods

__construct($data, $encoding = 'UTF-8', $debug = '')

Load a file input stream.

currentLine()

Returns the current line that the tokenizer is at.

getCurrentLine()

No description

int
columnOffset()

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

getColumnOffset()

No description

string
current()

Get the current character.

next()

Advance the pointer.

rewind()

Rewind to the start of the string.

bool
valid()

Is the current pointer location valid.

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 characters.

peek()

Look ahead without moving cursor.

key()

No description

Details

at line line 25
__construct($data, $encoding = 'UTF-8', $debug = '')

Load a file input stream.

Parameters

$data
$encoding
$debug

in StringInputStream at line line 112
currentLine()

Returns the current line that the tokenizer is at.

in StringInputStream at line line 127
getCurrentLine()

in StringInputStream at line line 139
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.

in StringInputStream at line line 170
getColumnOffset()

in StringInputStream at line line 180
string current()

Get the current character.

Return Value

string The current character.

in StringInputStream at line line 189
next()

Advance the pointer.

This is part of the Iterator interface.

in StringInputStream at line line 197
rewind()

Rewind to the start of the string.

in StringInputStream at line line 207
bool valid()

Is the current pointer location valid.

Return Value

bool Is the current pointer location valid.

in StringInputStream at line line 227
remainingChars()

Get all characters until EOF.

This reads to the end of the file, and sets the read marker at the end of the file.

in StringInputStream at line line 254
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.

in StringInputStream at line line 285
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.

in StringInputStream at line line 308
unconsume( int $howMany = 1)

Unconsume characters.

Parameters

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

in StringInputStream at line line 318
peek()

Look ahead without moving cursor.

in StringInputStream at line line 327
key()