class FileInputStream extends StringInputStream implements InputStream (View source)

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

currentLine()

Returns the current line that the tokenizer is at.

getCurrentLine()

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.

getColumnOffset()

string current()

Get the current character.

Return Value

string The current character.

next()

Advance the pointer.

This is part of the Iterator interface.

rewind()

Rewind to the start of the string.

bool valid()

Is the current pointer location valid.

Return Value

bool Is the current pointer location valid.

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.

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.

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.

unconsume( int $howMany = 1)

Unconsume characters.

Parameters

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

peek()

Look ahead without moving cursor.

key()