class Scanner (View source)

The scanner.

This scans over an input stream.

Constants

CHARS_HEX

CHARS_ALNUM

CHARS_ALPHA

Properties

$debug

Methods

__construct( InputStream $input)

Create a new Scanner.

int
position()

Get the current position.

string
peek()

Take a peek at the next character in the data.

string
next()

Get the next character.

string
current()

Get the current character.

consume($count = 1)

Silently consume N chars.

unconsume( int $howMany = 1)

Unconsume some of the data.

string
getHex()

Get the next group of that contains hex characters.

string
getAsciiAlpha()

Get the next group of characters that are ASCII Alpha characters.

string
getAsciiAlphaNum()

Get the next group of characters that are ASCII Alpha characters and numbers.

string
getNumeric()

Get the next group of numbers.

whitespace()

Consume whitespace.

int
currentLine()

Returns the current line that is being consumed.

charsUntil($mask)

Read chars until something in the mask is encountered.

charsWhile($mask)

Read chars as long as the mask matches.

int
columnOffset()

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

int
remainingChars()

Get all characters until EOF.

Details

at line line 29
__construct( InputStream $input)

Create a new Scanner.

Parameters

InputStream $input An InputStream to be scanned.

at line line 39
int position()

Get the current position.

Return Value

int The current intiger byte position.

at line line 49
string peek()

Take a peek at the next character in the data.

Return Value

string The next character.

at line line 61
string next()

Get the next character.

Note: This advances the pointer.

Return Value

string The next character.

at line line 80
string current()

Get the current character.

Note, this does not advance the pointer.

Return Value

string The current character.

at line line 92
consume($count = 1)

Silently consume N chars.

Parameters

$count

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

Unconsume some of the data.

This moves the data pointer backwards.

Parameters

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

at line line 119
string getHex()

Get the next group of that contains hex characters.

Note, along with getting the characters the pointer in the data will be moved as well.

Return Value

string The next group that is hex characters.

at line line 132
string getAsciiAlpha()

Get the next group of characters that are ASCII Alpha characters.

Note, along with getting the characters the pointer in the data will be moved as well.

Return Value

string The next group of ASCII alpha characters.

at line line 145
string getAsciiAlphaNum()

Get the next group of characters that are ASCII Alpha characters and numbers.

Note, along with getting the characters the pointer in the data will be moved as well.

Return Value

string The next group of ASCII alpha characters and numbers.

at line line 158
string getNumeric()

Get the next group of numbers.

Note, along with getting the characters the pointer in the data will be moved as well.

Return Value

string The next group of numbers.

at line line 168
whitespace()

Consume whitespace.

Whitespace in HTML5 is: formfeed, tab, newline, space.

at line line 178
int currentLine()

Returns the current line that is being consumed.

Return Value

int The current line number.

at line line 186
charsUntil($mask)

Read chars until something in the mask is encountered.

Parameters

$mask

at line line 194
charsWhile($mask)

Read chars as long as the mask matches.

Parameters

$mask

at line line 206
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 218
int remainingChars()

Get all characters until EOF.

This consumes characters until the EOF.

Return Value

int The number of characters remaining.