function next_pos($needle, $callback = true)
{
$this->token_start = $this->pos;
if ($this->pos < $this->size && ($p = stripos($this->doc, $needle, $this->pos + 1)) !== false) {
$len = $p - $this->pos - 1;
if ($len > 0) {
$str = substr($this->doc, $this->pos + 1, $len);
if (($l = strrpos($str, "\n")) !== false) {
++$this->line_pos[0];
$this->line_pos[1] = $l + $this->pos + 1;
$len -= $l;
if ($len > 0) {
$str = substr($str, 0, -$len);
$this->line_pos[0] += substr_count($str, "\n");
}
}
}
$this->pos = $p;
if ($callback && isset($this->char_map[$this->doc[$this->pos]])) {
if (is_string($this->char_map[$this->doc[$this->pos]])) {
return $this->token = $this->{$this->char_map[$this->doc[$this->pos]]}();
} else {
return $this->token = $this->char_map[$this->doc[$this->pos]];
}
} else {
return $this->token = self::TOK_UNKNOWN;
}
} else {
$this->pos = $this->size;
return $this->token = self::TOK_NULL;
}
}