#ifndef INTERPRETER_H
#define INTERPRETER_H

#include <variant>
#include <string>
#include <stdexcept>
using namespace std;

#include "tokenize.h"

using EvalResult = variant<monostate, int, double>;

struct MemoryEntry {
    EvalResult value { };
    bool assigned { false };
    Type type;
};

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
*/
EvalResult eval(Node &ast);

void _debug_flush_memory(void);

#endif