public function throwError($msg = "parse error", $count = null)
{
$count = is_null($count) ? $this->count : $count;
$line = $this->line + substr_count(substr($this->buffer, 0, $count), "\n");
if (!empty($this->sourceName)) {
$loc = "{$this->sourceName} on line {$line}";
} else {
$loc = "line: {$line}";
}
// TODO this depends on $this->count
if ($this->peek("(.*?)(\n|\$)", $m, $count)) {
throw new exception("{$msg}: failed at `{$m['1']}` {$loc}");
} else {
throw new exception("{$msg}: {$loc}");
}
}