Generates a new syntax error.
string $expected Expected string.:
array $token Optional token.:
private function syntaxError($expected, $token = null) {
if ($token === null) {
$token = $this->lexer->lookahead;
}
$message = "Expected {$expected}, got ";
if ($this->lexer->lookahead === null) {
$message .= 'end of string';
}
else {
$message .= "'{$token['value']}' at position {$token['position']}";
}
if (strlen($this->context)) {
$message .= ' in ' . $this->context;
}
$message .= '.';
throw AnnotationException::syntaxError($message);
}