Documentation

InputStream extends Iterator

Interface for stream readers.

since 2.4, to remove in 3.0. Use a string in the scanner instead.

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

Currently provided InputStream implementations include FileInputStream and StringInputStream.

Table of Contents

Methods

charsUntil()  : mixed
Read to a particular match (or until $max bytes are consumed).
charsWhile()  : mixed
Returns the string so long as $bytes matches.
columnOffset()  : int
Returns the current column of the current line that the tokenizer is at.
currentLine()  : mixed
Returns the current line that is being consumed.
peek()  : mixed
Retrieve the next character without advancing the pointer.
remainingChars()  : mixed
Get all characters until EOF.
unconsume()  : mixed
Unconsume one character.

Methods

charsUntil()

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

public charsUntil(string $bytes[, int $max = null ]) : mixed

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
$bytes : string

Bytes to match.

$max : int = null

Maximum number of bytes to scan.

Tags
see
strcspn
Return values
mixed

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

charsWhile()

Returns the string so long as $bytes matches.

public charsWhile(string $bytes[, int $max = null ]) : mixed

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

Parameters
$bytes : string

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.

$max : int = null

The max number of chars to read.

Tags
see
strspn

columnOffset()

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

public columnOffset() : int

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

Tags
TODO

Move this to the scanner.

Return values
int

The column number.

currentLine()

Returns the current line that is being consumed.

public currentLine() : mixed

TODO: Move this to the scanner.

peek()

Retrieve the next character without advancing the pointer.

public peek() : mixed

remainingChars()

Get all characters until EOF.

public remainingChars() : mixed

This consumes characters until the EOF.

unconsume()

Unconsume one character.

public unconsume([int $howMany = 1 ]) : mixed
Parameters
$howMany : int = 1

The number of characters to move the pointer back.


        
On this page

Search results