34 lines
1.0 KiB
C++
34 lines
1.0 KiB
C++
#ifndef AST_INTERPRETER_HH
|
|
#define AST_INTERPRETER_HH
|
|
|
|
#include "expr.hh"
|
|
#include "stmt.hh"
|
|
#include "environment.hh"
|
|
#include "../tokenizer.hh"
|
|
#include <vector>
|
|
|
|
struct AstInterpreter {
|
|
void interpret(const std::vector<Stmt> &statements);
|
|
|
|
private:
|
|
void execute(const Stmt &stmt);
|
|
void execute_expression_statement(const Stmt &stmt);
|
|
void execute_print_statement(const Stmt &stmt);
|
|
void execute_var_statement(const Stmt &stmt);
|
|
void execute_block_statement(const std::vector<Stmt> &statements, Environment environment);
|
|
|
|
Object evaluate(const Expr &expr);
|
|
Object evaluate_binary_expression(const Expr &expr);
|
|
Object evaluate_grouping_expression(const Expr &expr);
|
|
Object evaluate_literal_expression(const Expr &expr);
|
|
Object evaluate_unary_expression(const Expr &expr);
|
|
Object evaluate_variable_expression(const Expr &expr);
|
|
Object evaluate_assignment_expression(const Expr &expr);
|
|
bool is_truthy(const Object &object);
|
|
bool is_equal(const Object &left, const Object &right);
|
|
|
|
Environment environment{};
|
|
};
|
|
|
|
#endif
|