parser/ast|parser: PRIMITIVE -> KNOWN

Primitive is a bit of a word conflict here; primitives are what we'd
expect our callables to be named eventually.  However, these parser
"primitives" are just well known symbols that we want to optimise the
representation of for later stages.  Thus, KNOWN is a bit better for
signalling intent then PRIMITIVE is.
This commit is contained in:
2026-01-28 07:30:02 +00:00
parent 947e05cdc8
commit 2dc0de78b5
3 changed files with 25 additions and 25 deletions

View File

@@ -15,23 +15,23 @@
/// Types the AST can encode
typedef enum
{
AST_NODE_TYPE_PRIMITIVE = 0,
AST_NODE_TYPE_KNOWN = 0,
AST_NODE_TYPE_SYMBOL,
AST_NODE_TYPE_STRING,
NUM_AST_NODE_TYPES,
} ast_node_type_t;
/// Primitives (values, callables, etc) as symbols
/// Known symbols - may reference callables or values.
typedef enum
{
AST_PRIM_NIL = 0,
AST_PRIM_PUTSTR,
AST_KNOWN_NIL = 0,
AST_KNOWN_PUTSTR,
NUM_AST_PRIMS,
} ast_prim_t;
NUM_AST_KNOWNS,
} ast_known_t;
const char *ast_prim_to_cstr(ast_prim_t);
const char *ast_known_to_cstr(ast_known_t);
/// Node of the AST as a tagged union
typedef struct
@@ -40,13 +40,13 @@ typedef struct
ast_node_type_t type;
union
{
ast_prim_t as_prim;
ast_known_t as_known;
sv_t as_symbol;
sv_t as_string;
} value;
} ast_node_t;
ast_node_t ast_node_prim(u64 byte, ast_prim_t primitive);
ast_node_t ast_node_known(u64 byte, ast_known_t known);
ast_node_t ast_node_symbol(u64 byte, sv_t symbol);
ast_node_t ast_node_string(u64 byte, sv_t string);
void ast_node_print(FILE *fp, ast_node_t *node);