Beispiel #1
0
 /**
  * Generates a new syntax error.
  *
  * @param string $expected Expected string.
  * @param array $token Optional token.
  * @throws AnnotationException
  */
 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);
 }