skopy/lib/include/sym.h

49 lines
903 B
C

#ifndef SK_SYM_H
#define SK_SYM_H
#include "commons.h"
struct symbol
{
int id;
char* name;
bool is_const;
struct env* env;
};
struct env
{
struct vec symbols;
struct env* parent;
};
struct sym
{
int id_counter;
struct env* env;
};
void env_init(struct env* self);
void env_free(struct env* self);
struct symbol* env_try_get(struct env* self, char const* name);
void symbol_init(struct symbol* self,
int id,
char const* name,
struct env* env);
void symbol_free(struct symbol* self);
void sym_init(struct sym* self);
void sym_free(struct sym* self);
int sym_decl_var(struct sym* self, char const* name);
int sym_decl_const(struct sym* self, char const* name);
void sym_open_scope(struct sym* self);
void sym_close_scope(struct sym* self);
struct symbol* sym_try_get(struct sym* self, char const* name);
#endif