22 lines
412 B
C
Raw Normal View History

2023-11-10 13:42:53 +01:00
#ifndef INTERPRETER_H
#define INTERPRETER_H
2023-11-10 17:35:33 +01:00
#include <variant>
2023-11-15 13:40:37 +01:00
#include <string>
#include <stdexcept>
2023-11-10 17:35:33 +01:00
using namespace std;
2023-11-10 13:42:53 +01:00
2023-11-10 17:35:33 +01:00
using EvalResult = variant<int, monostate>;
2023-11-15 13:40:37 +01:00
class RuntimeError : public runtime_error {
public:
explicit RuntimeError(const string& message)
: runtime_error(message) {}
};
2023-11-10 17:35:33 +01:00
/*
Evaluates the AST, returning the latest calulated value
*/
EvalResult eval(Node &ast);
2023-11-10 13:42:53 +01:00
#endif