fix: fix parser/generator issues
This commit is contained in:
@@ -1,102 +0,0 @@
|
||||
#ifndef FZL_WALKER_H
|
||||
#define FZL_WALKER_H
|
||||
|
||||
#include <common/fzl_extern.h>
|
||||
#include <common/fzl_opcodes.h>
|
||||
#include <common/fzl_types.h>
|
||||
#include <compiler/fzl_parser.h>
|
||||
#include <compiler/utils/fzl_const_pool.h>
|
||||
#include <compiler/utils/fzl_ctable.h>
|
||||
#include <compiler/utils/fzl_symtable.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
|
||||
// Type of context
|
||||
typedef enum
|
||||
{
|
||||
FZL_WALK_CTX_TYPE_GLOBAL,
|
||||
FZL_WALK_CTX_TYPE_FN,
|
||||
FZL_WALK_CTX_TYPE_CLASS,
|
||||
FZL_WALK_CTX_TYPE_ASSIGN,
|
||||
FZL_WALK_CTX_TYPE_LOOP,
|
||||
} fzl_walk_ctx_type_t;
|
||||
|
||||
// Internal walk function result
|
||||
typedef struct
|
||||
{
|
||||
fzl_type_t type;
|
||||
|
||||
char *error_msg;
|
||||
bool error;
|
||||
|
||||
char *classname;
|
||||
} fzl_walk_res_t;
|
||||
|
||||
// Function context descriptor
|
||||
typedef struct fzl_walk_ctx
|
||||
{
|
||||
fzl_walk_ctx_type_t type;
|
||||
struct fzl_walk_ctx *parent;
|
||||
|
||||
size_t initial_env_lvl;
|
||||
union
|
||||
{
|
||||
// function info
|
||||
struct
|
||||
{
|
||||
fzl_node_t *fn;
|
||||
};
|
||||
|
||||
// loops `break`s writeback addrs
|
||||
struct
|
||||
{
|
||||
size_t *breaks;
|
||||
size_t breaks_count;
|
||||
size_t breaks_remainder;
|
||||
};
|
||||
};
|
||||
} fzl_walk_ctx_t;
|
||||
|
||||
// Walker descriptor
|
||||
typedef struct
|
||||
{
|
||||
fzl_node_t *root;
|
||||
fzl_const_hash_pool_t *consts;
|
||||
|
||||
uint64_t *ops;
|
||||
size_t op_count;
|
||||
size_t op_remainder;
|
||||
|
||||
fzl_symtable_t *syms[64];
|
||||
size_t sym_top;
|
||||
|
||||
fzl_walk_ctx_t *ctx;
|
||||
|
||||
fzl_ctable_t *classes[64];
|
||||
size_t classes_count;
|
||||
|
||||
fzl_extern_lib_t extern_libs[64];
|
||||
size_t extern_libs_count;
|
||||
|
||||
fzl_extern_type_t extern_types[256];
|
||||
size_t extern_types_count;
|
||||
|
||||
fzl_extern_fn_t extern_fns[256];
|
||||
size_t extern_fns_count;
|
||||
} fzl_walker_t;
|
||||
|
||||
// Allocate new walker
|
||||
fzl_walker_t *fzl_mkwalker(fzl_node_t *root);
|
||||
|
||||
// Walk throught the entire AST and build:
|
||||
// 1. Constants table
|
||||
// 2. Operations
|
||||
int fzl_walk(fzl_walker_t *walker);
|
||||
|
||||
// Get last error message
|
||||
char *fzl_walker_geterror();
|
||||
|
||||
// Free walker
|
||||
void fzl_freewalker(fzl_walker_t *walker);
|
||||
|
||||
#endif // FZL_WALKER_H
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef FZL_WRITER_H
|
||||
#define FZL_WRITER_H
|
||||
|
||||
#include <compiler/fzl_walker.h>
|
||||
#include <compiler/fzl_gen.h>
|
||||
#include <compiler/utils/fzl_const_pool.h>
|
||||
|
||||
// File writer descriptor
|
||||
@@ -14,7 +14,7 @@ typedef struct
|
||||
fzl_writer_t *fzl_mkwriter(const char *filepath);
|
||||
|
||||
// Write out a file
|
||||
int fzl_write(fzl_writer_t *writer, fzl_walker_t *walker);
|
||||
int fzl_write(fzl_writer_t *writer, fzl_gen_t *gen);
|
||||
|
||||
// Get last writer error message
|
||||
char *fzl_writer_geterror();
|
||||
|
||||
Reference in New Issue
Block a user