1
0
Fork 0
undar-lang-register/src/compiler.h

46 lines
772 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_table_t {
char name[SYMBOL_NAME_SIZE];
SymbolType type;
union {
PlexDef pd;
ArrayDef ad;
};
int8_t reg;
union {
uint32_t frame;
uint32_t ptr;
};
} Symbol;
#define MODULE_NAME_SIZE 32
#define SYMBOL_COUNT 256
typedef struct module_t {
char name[MODULE_NAME_SIZE];
Symbol symbols[SYMBOL_COUNT];
} Module;
bool compile(const char *source, VM *vm);
#endif