Added linked-list based stack
This commit is contained in:
parent
f3ae278e53
commit
d8f5ad44b5
|
|
@ -8,6 +8,8 @@
|
|||
|
||||
#include <stddef.h>
|
||||
|
||||
#include "sls/lexer.h"
|
||||
|
||||
typedef enum {
|
||||
STACK_IDENTIFIER,
|
||||
STACK_I64,
|
||||
|
|
@ -23,9 +25,35 @@ typedef enum {
|
|||
STACK_CHARACTER,
|
||||
STACK_BOOLEAN,
|
||||
STACK_TOKEN_STRING,
|
||||
} StackTypes;
|
||||
} 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;
|
||||
};
|
||||
StackItem *next;
|
||||
} StackItem;
|
||||
|
||||
typedef struct {
|
||||
StackItem *stack;
|
||||
|
||||
} InterpreterState;
|
||||
|
||||
#endif // SLS_INTERPRETER_H
|
||||
|
|
|
|||
Loading…
Reference in New Issue