reality-engine/src/compiler.h

48 lines
868 B
C

#ifndef ZRL_COMPILER_H
#define ZRL_COMPILER_H
#include "lexer.h"
#include "opcodes.h"
typedef enum { INT, REAL, NATURAL, POINTER, STRING, ARRAY, PLEX } SymbolType;
typedef struct plex_def_t {
SymbolType subtype;
uint32_t size;
} PlexDef;
typedef struct array_def_t {
SymbolType subtype;
uint32_t length;
} ArrayDef;
#define SYMBOL_NAME_SIZE 24
typedef struct symbol_t {
char name[SYMBOL_NAME_SIZE];
SymbolType type;
union {
PlexDef pd;
ArrayDef ad;
};
int8_t reg;
uint8_t flags[3]; /* only use for padding now, might be used later*/
uint32_t frame;
uint32_t ptr;
} Symbol;
#define MODULE_NAME_SIZE 32
#define SYMBOL_COUNT 256
typedef struct symbol_table_t {
char name[MODULE_NAME_SIZE];
Symbol symbols[SYMBOL_COUNT];
uint32_t sc;
} SymbolTable;
extern SymbolTable st;
bool compile(const char *source, VM *vm);
#endif