/** * @param string $expected * @param array $token * * @throws InvalidValueException */ protected function syntaxError($expected = '', $token = null) { if ($token === null) { $token = $this->lexer->lookahead; } $tokenPos = isset($token['position']) ? $token['position'] : '-1'; $message = 'line 0, col ' . $tokenPos . ': Error: '; $message .= $expected !== '' ? 'Expected ' . $expected . ', got ' : 'Unexpected '; $message .= $this->lexer->lookahead === null ? 'end of string.' : '"' . $token['value'] . '"'; throw InvalidValueException::syntaxError($message, $this->input); }