1
0
forked from ground/ground-old
This repository has been archived on 2026-03-16. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
ground_old_fork/src/interpreter.h
2025-12-08 11:08:08 +11:00

44 lines
1.1 KiB
C

#ifndef INTERPRETER_H
#define INTERPRETER_H
#define MAX_ID_LEN 64
#include "types.h"
#include "parser.h"
#include "include/uthash.h"
typedef enum GroundRuntimeError {
ARG_TYPE_MISMATCH, TOO_FEW_ARGS, TOO_MANY_ARGS, UNKNOWN_LABEL, UNKNOWN_VARIABLE, LIST_ERROR, STRING_ERROR, MATH_ERROR, RETURN_TYPE_MISMATCH, FIXME
} GroundRuntimeError;
typedef enum GroundDebugInstructionType {
DUMP, INSPECT, EVAL, CONTINUE, EXIT, HELP, UNKNOWN
} GroundDebugInstructionType;
typedef struct GroundLabel {
char id[MAX_ID_LEN];
int lineNum;
UT_hash_handle hh;
} GroundLabel;
typedef struct GroundVariable {
char id[MAX_ID_LEN];
GroundValue value;
UT_hash_handle hh;
} GroundVariable;
typedef struct GroundScope {
GroundLabel** labels;
GroundVariable** variables;
} GroundScope;
typedef struct GroundDebugInstruction {
GroundDebugInstructionType type;
char* arg;
} GroundDebugInstruction;
GroundValue interpretGroundProgram(GroundProgram* in, GroundScope* inScope);
GroundValue interpretGroundInstruction(GroundInstruction inst, GroundScope* scope);
#endif