public throwError ( string $msg = "parse error", [type] $count = null ) : void | ||
$msg | string | [description] |
$count | [type] | |
return | void |
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}");
}
}
/** * Uses the current value of $this->count to show line and line number * * @param type $msg X * * @return void */ protected function throwError($msg = null) { if ($this->sourceLoc >= 0) { $this->sourceParser->throwError($msg, $this->sourceLoc); } throw new exception($msg); }