diff --git a/src/analysis.cpp b/src/analysis.cpp new file mode 100644 index 0000000..e69de29 diff --git a/src/include/analysis.h b/src/include/analysis.h new file mode 100644 index 0000000..bbaea2d --- /dev/null +++ b/src/include/analysis.h @@ -0,0 +1,6 @@ +#ifndef ANALYSIS_H +#define ANALYSIS_H + + + +#endif \ No newline at end of file diff --git a/src/include/interpreter.h b/src/include/interpreter.h index 0db1691..0a119cd 100644 --- a/src/include/interpreter.h +++ b/src/include/interpreter.h @@ -7,14 +7,6 @@ #include "memory.h" using namespace std; -class RuntimeError : public runtime_error { -public: - explicit RuntimeError(const string& message, CodePosition pos) - : runtime_error(message), pos(pos) {} - - const CodePosition pos; -}; - /* Evaluates the AST, returning the latest calulated value */ diff --git a/src/include/parser.h b/src/include/parser.h index b6dd1f3..3711e50 100644 --- a/src/include/parser.h +++ b/src/include/parser.h @@ -16,14 +16,6 @@ class ParseException : public std::exception { } }; -class SyntaxError : public runtime_error { -public: - explicit SyntaxError(const string& message, CodePosition pos) - : runtime_error(message), pos(pos) {} - - const CodePosition pos; -}; - /** * Parse a list of tokens and return the associated AST */ diff --git a/src/include/tokenize.h b/src/include/tokenize.h index 145a0d8..55bc8a9 100644 --- a/src/include/tokenize.h +++ b/src/include/tokenize.h @@ -7,14 +7,6 @@ #include "types.h" using namespace std; -class TokenError : public runtime_error { -public: - explicit TokenError(const string& message, CodePosition pos) - : runtime_error(message), pos(pos) {} - - const CodePosition pos; -}; - /* Parses a string into a vector of tokens */ diff --git a/src/include/types.h b/src/include/types.h index 4049630..53a2d7c 100644 --- a/src/include/types.h +++ b/src/include/types.h @@ -170,4 +170,31 @@ struct Scope { ScopeType type; }; +/** + * Errors +*/ +class SyntaxError : public runtime_error { +public: + explicit SyntaxError(const string& message, CodePosition pos) + : runtime_error(message), pos(pos) {} + + const CodePosition pos; +}; + +class TypeError : public runtime_error { +public: + explicit TypeError(const string& message, CodePosition pos) + : runtime_error(message), pos(pos) {} + + const CodePosition pos; +}; + +class RuntimeError : public runtime_error { +public: + explicit RuntimeError(const string& message, CodePosition pos) + : runtime_error(message), pos(pos) {} + + const CodePosition pos; +}; + #endif \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index b39b9b5..8b6b540 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -46,10 +46,6 @@ int main(int argc, char* argv[]) { cout << get(res) << endl; } - } catch (const TokenError& e) { - pretty_print_error(input, e.pos); - cout << BOLD RED "Token Error: " RESET << e.what() << endl; - } catch (const SyntaxError& e) { pretty_print_error(input, e.pos); cout << BOLD RED "Syntax Error: " RESET << e.what() << endl; diff --git a/src/tokenize.cpp b/src/tokenize.cpp index 9323f8a..a7b93c8 100644 --- a/src/tokenize.cpp +++ b/src/tokenize.cpp @@ -231,7 +231,7 @@ vector tokenize(vector input, int initial_line) { continue; } - throw TokenError("Unknown token", pos); + throw SyntaxError("Unknown token", pos); } }