CONSUMED_WHITESPACE
CONSUMED_WHITESPACE
Usage: $parser = new StringParser('Some "string to be" parsed', TRUE); // TRUE means that you want to ignore whitespace
while($data = $parser->consume()) { echo "Got: '$data'. Type is '".$parser->type."'\n"; // TYPE is one of the StringParser::CONSUMED*-constants or NULL }
Peeking on the next token:
$peek = $parser->consume();
$parser->push($peek); // Adds $data to the beginning of the string and will be returned again
The parser will generally work on any type of string, and will split it by whitespace, quoted strings, single words, integers and floats. For example:
123.456.789 will be returned as first "123.456" of type FLOAT, then "." of type SYMBOLS then 789 of type INTEGER.