2025-11-23 18:34:30 +11:00
|
|
|
#ifndef INTERPRETER_H
|
|
|
|
|
#define INTERPRETER_H
|
2025-11-23 19:18:10 +11:00
|
|
|
#define MAX_ID_LEN 64
|
2025-11-23 18:34:30 +11:00
|
|
|
|
|
|
|
|
#include "types.h"
|
|
|
|
|
#include "parser.h"
|
|
|
|
|
#include "include/uthash.h"
|
|
|
|
|
|
|
|
|
|
typedef enum GroundRuntimeError {
|
2025-12-06 11:50:42 +11:00
|
|
|
ARG_TYPE_MISMATCH, TOO_FEW_ARGS, TOO_MANY_ARGS, UNKNOWN_LABEL, UNKNOWN_VARIABLE, LIST_ERROR, STRING_ERROR, MATH_ERROR, RETURN_TYPE_MISMATCH, FIXME
|
2025-11-23 18:34:30 +11:00
|
|
|
} GroundRuntimeError;
|
|
|
|
|
|
2025-12-08 11:08:08 +11:00
|
|
|
typedef enum GroundDebugInstructionType {
|
2025-12-08 15:06:29 +11:00
|
|
|
DUMP, INSPECT, EVAL, CONTINUE, EXIT, STEP, VIEW, HELP, UNKNOWN
|
2025-12-08 11:08:08 +11:00
|
|
|
} GroundDebugInstructionType;
|
|
|
|
|
|
2025-11-23 18:34:30 +11:00
|
|
|
typedef struct GroundLabel {
|
2025-11-23 19:18:10 +11:00
|
|
|
char id[MAX_ID_LEN];
|
|
|
|
|
int lineNum;
|
|
|
|
|
UT_hash_handle hh;
|
2025-11-23 18:34:30 +11:00
|
|
|
} GroundLabel;
|
|
|
|
|
|
2025-11-23 19:59:22 +11:00
|
|
|
typedef struct GroundVariable {
|
|
|
|
|
char id[MAX_ID_LEN];
|
|
|
|
|
GroundValue value;
|
|
|
|
|
UT_hash_handle hh;
|
|
|
|
|
} GroundVariable;
|
|
|
|
|
|
|
|
|
|
typedef struct GroundScope {
|
|
|
|
|
GroundLabel** labels;
|
|
|
|
|
GroundVariable** variables;
|
|
|
|
|
} GroundScope;
|
|
|
|
|
|
2025-12-08 11:08:08 +11:00
|
|
|
typedef struct GroundDebugInstruction {
|
|
|
|
|
GroundDebugInstructionType type;
|
|
|
|
|
char* arg;
|
|
|
|
|
} GroundDebugInstruction;
|
|
|
|
|
|
2025-12-02 09:00:21 +11:00
|
|
|
GroundValue interpretGroundProgram(GroundProgram* in, GroundScope* inScope);
|
|
|
|
|
GroundValue interpretGroundInstruction(GroundInstruction inst, GroundScope* scope);
|
2025-11-24 10:15:53 +11:00
|
|
|
|
|
|
|
|
|
2025-11-23 18:34:30 +11:00
|
|
|
#endif
|