feat+ref: refactor + new types

This commit is contained in:
samsonium
2026-10-11 08:51:54 +03:00
parent e3b8ec6b7d
commit 83e20d78f3
13 changed files with 532 additions and 341 deletions
+4 -1
View File
@@ -21,7 +21,10 @@ typedef enum
FZL_NODETYPE_MOD,
FZL_NODETYPE_UNARY_PLUS,
FZL_NODETYPE_UNARY_MINUS
FZL_NODETYPE_UNARY_MINUS,
FZL_NODETYPE_DECLARATION,
FZL_NODETYPE_ASSIGN
} fzl_nodetype_t;
// AST node descriptor
+3 -1
View File
@@ -21,8 +21,10 @@ typedef struct
char *source;
size_t size;
size_t position;
bool at_end;
size_t line_start;
size_t line_n;
} fzl_reader_t;
// Allocate new reader
+7 -3
View File
@@ -9,11 +9,13 @@
typedef enum
{
FZL_TOKTYPE_NAME, // abc
FZL_TOKTYPE_TYPE, // i16
FZL_TOKTYPE_LPAREN, // (
FZL_TOKTYPE_RPAREN, // )
FZL_TOKTYPE_COMMA, // ,
FZL_TOKTYPE_DOT, // .
FZL_TOKTYPE_STR_LITERAL, // ""
FZL_TOKTYPE_NUM_LITERAL, // 123
@@ -24,21 +26,23 @@ typedef enum
FZL_TOKTYPE_MINUS, // -
FZL_TOKTYPE_CARET, // ^
FZL_TOKTYPE_PERCENT, // %
FZL_TOKTYPE_EQ // =
} fzl_toktype_t;
// Token descriptor
typedef struct
{
fzl_toktype_t type;
uint16_t i0;
uint16_t i1;
size_t ln;
size_t cn;
bool store_value;
void *value;
uint16_t value_sz;
} fzl_token_t;
// Allocate new token
fzl_token_t *fzl_mktoken(const fzl_toktype_t type, uint16_t from, uint16_t to,
fzl_token_t *fzl_mktoken(const fzl_toktype_t type, size_t line, size_t col,
void *value, size_t value_sz);
// Free token and its contents
+11
View File
@@ -2,10 +2,21 @@
#define FZL_WALKER_H
#include <common/fzl_opcodes.h>
#include <common/fzl_types.h>
#include <compiler/fzl_parser.h>
#include <compiler/utils/fzl_const_pool.h>
#include <stdbool.h>
#include <stddef.h>
// Internal walk function result
typedef struct
{
fzl_type_t type;
char *error_msg;
bool error;
} fzl_walk_res_t;
// Walker descriptor
typedef struct
{