mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-21 12:00:18 +00:00
43 lines
912 B
C++
43 lines
912 B
C++
#pragma once
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
#include <stdexcept>
|
|
#include <stdarg.h>
|
|
|
|
#include "parser.h"
|
|
|
|
class NeedMoreLines : public std::exception {
|
|
public:
|
|
NeedMoreLines(bool isClassDef) : isClassDef(isClassDef) {}
|
|
bool isClassDef;
|
|
};
|
|
|
|
class SyntaxError : public std::exception {
|
|
private:
|
|
_Str _what;
|
|
|
|
public:
|
|
char message[100];
|
|
_Str path;
|
|
int lineno;
|
|
|
|
SyntaxError(const _Str& path, Token tk, const char* msg, ...) {
|
|
va_list args;
|
|
va_start(args, msg);
|
|
vsnprintf(message, 100, msg, args);
|
|
va_end(args);
|
|
|
|
this->path = path;
|
|
lineno = tk.line;
|
|
|
|
_StrStream ss;
|
|
ss << " File '" << path << "', line " << std::to_string(lineno) << std::endl;
|
|
ss << _Str("SyntaxError: ") << message;
|
|
_what = ss.str();
|
|
}
|
|
|
|
const char* what() const noexcept override {
|
|
return _what.str().c_str();
|
|
}
|
|
}; |