-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathinterpreter.h
More file actions
56 lines (48 loc) · 2.6 KB
/
Copy pathinterpreter.h
File metadata and controls
56 lines (48 loc) · 2.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/* interpreter.h - Interpreter visitor */
#ifndef INTERPRETER_H
#define INTERPRETER_H
#include "visitor.h"
#include "ast.h"
/* Interpreter visitor - executes the AST */
typedef struct
{
Visitor base; /* Inherit from Visitor */
Scope *current_scope; /* Current execution scope */
ReturnValue return_value; /* Function return value */
bool should_break; /* Break flag for loops/switch */
bool should_return; /* Return flag for functions */
} Interpreter;
/* Create and destroy interpreter */
Interpreter *interpreter_new(void);
void interpreter_free(Interpreter *interpreter);
/* Main interpretation function */
void interpret(ASTNode *root, Interpreter *interp);
/* Visitor method implementations for expressions (return values) */
void *interpreter_visit_int_literal(Visitor *self, ASTNode *node);
void *interpreter_visit_float_literal(Visitor *self, ASTNode *node);
void *interpreter_visit_double_literal(Visitor *self, ASTNode *node);
void *interpreter_visit_char_literal(Visitor *self, ASTNode *node);
void *interpreter_visit_short_literal(Visitor *self, ASTNode *node);
void *interpreter_visit_boolean_literal(Visitor *self, ASTNode *node);
void *interpreter_visit_string_literal(Visitor *self, ASTNode *node);
void *interpreter_visit_identifier(Visitor *self, ASTNode *node);
void *interpreter_visit_binary_operation(Visitor *self, ASTNode *node);
void *interpreter_visit_unary_operation(Visitor *self, ASTNode *node);
void *interpreter_visit_array_access(Visitor *self, ASTNode *node);
void *interpreter_visit_function_call(Visitor *self, ASTNode *node);
void *interpreter_visit_sizeof(Visitor *self, ASTNode *node);
/* Visitor method implementations for statements */
void interpreter_visit_declaration(Visitor *self, ASTNode *node);
void interpreter_visit_assignment(Visitor *self, ASTNode *node);
void interpreter_visit_if_statement(Visitor *self, ASTNode *node);
void interpreter_visit_for_statement(Visitor *self, ASTNode *node);
void interpreter_visit_while_statement(Visitor *self, ASTNode *node);
void interpreter_visit_do_while_statement(Visitor *self, ASTNode *node);
void interpreter_visit_switch_statement(Visitor *self, ASTNode *node);
void interpreter_visit_break_statement(Visitor *self, ASTNode *node);
void interpreter_visit_return_statement(Visitor *self, ASTNode *node);
void interpreter_visit_function_definition(Visitor *self, ASTNode *node);
void interpreter_visit_statement_list(Visitor *self, ASTNode *node);
void interpreter_visit_print_statement(Visitor *self, ASTNode *node);
void interpreter_visit_error_statement(Visitor *self, ASTNode *node);
#endif /* INTERPRETER_H */