65 lines
1.2 KiB
C
65 lines
1.2 KiB
C
// Kyler Olsen
|
|
// YREA SLS
|
|
// Interpreter Header
|
|
// November 2025
|
|
|
|
#ifndef SLS_INTERPRETER_H
|
|
#define SLS_INTERPRETER_H
|
|
|
|
#include <stddef.h>
|
|
|
|
#include "sls/lexer.h"
|
|
#include "sls/hash_table.h"
|
|
|
|
typedef enum {
|
|
STACK_IDENTIFIER,
|
|
STACK_I64,
|
|
STACK_I32,
|
|
STACK_I16,
|
|
STACK_I8,
|
|
STACK_U64,
|
|
STACK_U32,
|
|
STACK_U16,
|
|
STACK_U8,
|
|
STACK_FLOAT,
|
|
STACK_DOUBLE,
|
|
STACK_CHARACTER,
|
|
STACK_BOOLEAN,
|
|
STACK_TOKEN_STRING,
|
|
} StackType;
|
|
|
|
extern const char *STACK_TYPES_NAMES[];
|
|
extern const size_t STACK_TYPE_COUNT;
|
|
|
|
typedef struct StackItem {
|
|
StackType type;
|
|
union {
|
|
Identifier identifier;
|
|
int64_t i64;
|
|
int32_t i32;
|
|
int16_t i16;
|
|
int8_t i8;
|
|
uint64_t u64;
|
|
uint32_t u32;
|
|
uint16_t u16;
|
|
uint8_t u8;
|
|
float f32;
|
|
double f64;
|
|
char character;
|
|
Boolean boolean;
|
|
TokenString token_string;
|
|
};
|
|
struct StackItem *next;
|
|
} StackItem;
|
|
|
|
typedef struct {
|
|
StackItem *stack;
|
|
HashTable functions;
|
|
} InterpreterState;
|
|
|
|
InterpreterState *interpreter_create();
|
|
void execute(InterpreterState *interpreter, LexerTokenResult *token);
|
|
void interpreter_delete(InterpreterState *interpreter);
|
|
|
|
#endif // SLS_INTERPRETER_H
|