summaryrefslogtreecommitdiff
path: root/uscript
diff options
context:
space:
mode:
authoriamcheeseman <[email protected]>2026-04-25 19:14:55 -0400
committeriamcheeseman <[email protected]>2026-04-25 19:14:55 -0400
commitb8db294d0c843084a20cd7b6c2f087ba6edce530 (patch)
treee6e0e1ae19827f49c7500b3e563c20433a94f11f /uscript
parentf328d3b2bea11f6b89bf4b3707205ecd8496b93d (diff)
microscript: rename zilch to nadaHEADmaster
Diffstat (limited to 'uscript')
-rw-r--r--uscript/lex.c8
-rw-r--r--uscript/lex.h4
-rw-r--r--uscript/map.c22
-rw-r--r--uscript/parser.c12
-rw-r--r--uscript/us_debug.c2
-rw-r--r--uscript/uscript.c8
-rw-r--r--uscript/val.c18
-rw-r--r--uscript/val.h4
-rw-r--r--uscript/vm.c4
-rw-r--r--uscript/xbytecode.h2
10 files changed, 41 insertions, 43 deletions
diff --git a/uscript/lex.c b/uscript/lex.c
index b940cd4..84c038e 100644
--- a/uscript/lex.c
+++ b/uscript/lex.c
@@ -104,7 +104,7 @@ struct token create_token(struct lexer *lex, u16 token_kind)
tok.len = (int)(lex->head - lex->base);
tok.line = lex->line;
tok.col = lex->col - tok.len;
- tok.val = create_zilch();
+ tok.val = create_nada();
return tok;
}
@@ -117,7 +117,7 @@ struct token err_token(struct lexer *lex, const char *msg)
tok.len = (int)strlen(msg);
tok.line = lex->line;
tok.col = lex->col;
- tok.val = create_zilch();
+ tok.val = create_nada();
return tok;
}
@@ -192,7 +192,7 @@ struct token ident_token(struct lexer *lex)
else if (match_kw(lex, "loop"))
kind = TOKEN_LOOP;
else if (match_kw(lex, "nada"))
- kind = TOKEN_ZILCH;
+ kind = TOKEN_NADA;
else if (match_kw(lex, "next"))
kind = TOKEN_NEXT;
else if (match_kw(lex, "not"))
@@ -203,8 +203,6 @@ struct token ident_token(struct lexer *lex)
kind = TOKEN_RET;
else if (match_kw(lex, "true"))
kind = TOKEN_TRUE;
- else if (match_kw(lex, "zilch"))
- kind = TOKEN_ZILCH;
return create_token(lex, kind);
}
diff --git a/uscript/lex.h b/uscript/lex.h
index 58ea353..e81981c 100644
--- a/uscript/lex.h
+++ b/uscript/lex.h
@@ -28,6 +28,7 @@
_(MINUS_EQL) \
_(MOD_EQL) \
_(MULT_EQL) \
+ _(NADA) \
_(NEQL) \
_(NEXT) \
_(NOT) \
@@ -36,8 +37,7 @@
_(PLUS_EQL) \
_(RET) \
_(STR) \
- _(TRUE) \
- _(ZILCH)
+ _(TRUE)
// single-character tokens are represented by their ASCII value, but other types
// of tokens are represented by a token_kind enum value.
diff --git a/uscript/map.c b/uscript/map.c
index 01f2462..d1f4da6 100644
--- a/uscript/map.c
+++ b/uscript/map.c
@@ -14,7 +14,7 @@ uint32_t hash_val(struct us_val v)
return *(uint32_t*)&n;
}
case VAL_BOOL: return get_bool(v) ? 1 : 0;
- case VAL_ZILCH: return 2;
+ case VAL_NADA: return 2;
case VAL_STR: // TODO: string should use a different hash function
case VAL_ARR:
case VAL_MAP:
@@ -30,8 +30,8 @@ uint32_t hash_val(struct us_val v)
static
struct us_map_kv *find_entry(struct us_map_kv *map, int cap, struct us_val k)
{
- if (k.type == VAL_ZILCH) {
- us_err("use of zilch as a map key");
+ if (k.type == VAL_NADA) {
+ us_err("use of nada as a map key");
}
uint32_t hash = hash_val(k);
@@ -41,8 +41,8 @@ struct us_map_kv *find_entry(struct us_map_kv *map, int cap, struct us_val k)
while (true) {
struct us_map_kv *item = &map[i];
- if (item->key.type == VAL_ZILCH) {
- if (item->val.type == VAL_ZILCH) {
+ if (item->key.type == VAL_NADA) {
+ if (item->val.type == VAL_NADA) {
return ts ? ts : item;
} else if (ts == NULL) {
ts = item;
@@ -60,14 +60,14 @@ void grow_map(struct us_map *map, int new_cap)
{
struct us_map_kv *new = mem_alloc(sizeof(struct us_map_kv) * new_cap);
for (int i = 0; i < new_cap; i++) {
- new[i].key = create_zilch();
- new[i].val = create_zilch();
+ new[i].key = create_nada();
+ new[i].val = create_nada();
}
map->len = 0;
for (int i = 0; i < map->cap; i++) {
struct us_map_kv *item = &map->e[i];
- if (item->key.type == VAL_ZILCH)
+ if (item->key.type == VAL_NADA)
continue;
struct us_map_kv *dst = find_entry(new, new_cap, item->key);
@@ -102,7 +102,7 @@ void map_set_value(struct us_map *map, struct us_val k, struct us_val v)
}
struct us_map_kv *kv = find_entry(map->e, map->cap, k);
- if (kv->key.type == VAL_ZILCH) {
+ if (kv->key.type == VAL_NADA) {
if (val_as_bool(map->locked))
us_err("attempt to modify keylocked map");
map->len++;
@@ -130,7 +130,7 @@ bool map_get_value(struct us_map *map, struct us_val k, struct us_val *v)
}
struct us_map_kv *kv = find_entry(map->e, map->cap, k);
- if (kv->key.type == VAL_ZILCH)
+ if (kv->key.type == VAL_NADA)
goto fail;
if (v)
@@ -138,6 +138,6 @@ bool map_get_value(struct us_map *map, struct us_val k, struct us_val *v)
return true;
fail:
if (v)
- *v = create_zilch();
+ *v = create_nada();
return false;
}
diff --git a/uscript/parser.c b/uscript/parser.c
index 2bb1afa..7f1cd49 100644
--- a/uscript/parser.c
+++ b/uscript/parser.c
@@ -180,7 +180,7 @@ int declare_named_variable(struct parser *p, const char* name)
token.line = p->cur.line;
token.col = p->cur.col;
token.kind = TOKEN_IDENT;
- token.val = create_zilch();
+ token.val = create_nada();
return declare_variable(p, token);
}
@@ -313,7 +313,7 @@ void begin_function(struct parser *p, struct us_proto *proto)
static
void end_function(struct parser *p)
{
- parser_add_byte(p, BC_ZILCH);
+ parser_add_byte(p, BC_NADA);
parser_add_byte(p, BC_RET);
struct func_parser *fp = p->fp;
@@ -373,7 +373,7 @@ void parse_literal(struct parser *p)
switch (p->prev.kind) {
case TOKEN_FALSE: parser_add_byte(p, BC_FALSE); break;
case TOKEN_TRUE: parser_add_byte(p, BC_TRUE); break;
- case TOKEN_ZILCH: parser_add_byte(p, BC_ZILCH); break;
+ case TOKEN_NADA: parser_add_byte(p, BC_NADA); break;
}
}
@@ -701,7 +701,7 @@ struct expr expressions[] = {
[TOKEN_RET] = {NULL, NULL, PREC_NONE},
[TOKEN_STR] = {parse_string, NULL, PREC_NONE},
[TOKEN_TRUE] = {parse_literal, NULL, PREC_NONE},
- [TOKEN_ZILCH] = {parse_literal, NULL, PREC_NONE},
+ [TOKEN_NADA] = {parse_literal, NULL, PREC_NONE},
};
static void stat(struct parser *p);
@@ -760,7 +760,7 @@ void var_def_stat(struct parser *p, bool is_global)
if (consume(p, '='))
expr(p);
else
- parser_add_byte(p, BC_ZILCH);
+ parser_add_byte(p, BC_NADA);
if (is_global) {
struct us_str *ident = copy_str(name.start, name.len);
@@ -1053,7 +1053,7 @@ void ret_stat(struct parser *p)
if (p->cur.kind != TOKEN_END && p->cur.kind != ';') {
expr(p);
} else {
- parser_add_byte(p, BC_ZILCH);
+ parser_add_byte(p, BC_NADA);
}
parser_add_byte(p, BC_RET);
}
diff --git a/uscript/us_debug.c b/uscript/us_debug.c
index 15465ce..102ea63 100644
--- a/uscript/us_debug.c
+++ b/uscript/us_debug.c
@@ -80,7 +80,7 @@ int print_instruction(struct us_proto *proto, int idx)
}
case BC_FALSE:
case BC_TRUE:
- case BC_ZILCH:
+ case BC_NADA:
case BC_PUSH_INDEX:
case BC_GET_INDEX:
case BC_SET_INDEX:
diff --git a/uscript/uscript.c b/uscript/uscript.c
index 6afdb25..27c7486 100644
--- a/uscript/uscript.c
+++ b/uscript/uscript.c
@@ -17,7 +17,7 @@ void core_print(int argc)
olog(str);
mem_free(str);
- vm_push(create_zilch());
+ vm_push(create_nada());
}
void core_len(int argc)
@@ -33,7 +33,7 @@ void core_len(int argc)
vm_push(create_num(get_str(val)->len));
break;
default:
- vm_push(create_zilch());
+ vm_push(create_nada());
}
}
@@ -47,7 +47,7 @@ void core_range_next(int argc)
double inc = get_num(cfunc_get_upval(cfunc, 2));
if (min == max) {
- vm_push(create_zilch());
+ vm_push(create_nada());
return;
}
@@ -92,7 +92,7 @@ void arr_iter_next(int argc)
int len = da_len(arr->e);
if (i == len) {
- vm_push(create_zilch());
+ vm_push(create_nada());
return;
}
diff --git a/uscript/val.c b/uscript/val.c
index 9df040a..fcce61a 100644
--- a/uscript/val.c
+++ b/uscript/val.c
@@ -95,7 +95,7 @@ struct us_upval *create_upval(struct us_val *val)
{
struct us_upval *upval = mem_alloc(sizeof(struct us_upval));
upval->loc = val;
- upval->closed = create_zilch();
+ upval->closed = create_nada();
upval->next = NULL;
init_obj(wrap_upval(upval), &upval->header);
return upval;
@@ -146,7 +146,7 @@ void free_val(struct us_val v)
break;
case VAL_NUM:
case VAL_BOOL:
- case VAL_ZILCH:
+ case VAL_NADA:
break;
}
}
@@ -166,7 +166,7 @@ bool vals_eql(struct us_val a, struct us_val b)
switch (a.type) {
case VAL_NUM: return get_num(a) == get_num(b);
case VAL_BOOL: return get_bool(a) == get_bool(b);
- case VAL_ZILCH: return true;
+ case VAL_NADA: return true;
case VAL_STR: {
struct us_str *a_str = get_str(a);
struct us_str *b_str = get_str(b);
@@ -207,12 +207,12 @@ char *val_to_str(struct us_val v, int *len_out)
*len_out = strlen(bool_str);
return str;
}
- case VAL_ZILCH: {
- const char *zilch_str = "zilch";
- char *str = mem_alloc(strlen(zilch_str) + 1);
- strcpy(str, zilch_str);
+ case VAL_NADA: {
+ const char *nada_str = "nada";
+ char *str = mem_alloc(strlen(nada_str) + 1);
+ strcpy(str, nada_str);
if (len_out)
- *len_out = strlen(zilch_str);
+ *len_out = strlen(nada_str);
return str;
}
case VAL_STR: {
@@ -296,7 +296,7 @@ char *val_to_str(struct us_val v, int *len_out)
bool val_as_bool(struct us_val v)
{
- if (v.type == VAL_ZILCH)
+ if (v.type == VAL_NADA)
return false;
if (v.type == VAL_BOOL)
return get_bool(v);
diff --git a/uscript/val.h b/uscript/val.h
index 3c579af..0ab1876 100644
--- a/uscript/val.h
+++ b/uscript/val.h
@@ -6,7 +6,7 @@
#define create_num(n) ((struct us_val){.type=VAL_NUM, .dat={.number=(n)}})
#define create_bool(b) ((struct us_val){.type=VAL_BOOL, .dat={.boolean=(b)}})
-#define create_zilch() ((struct us_val){.type=VAL_ZILCH, .dat={.number=0}})
+#define create_nada() ((struct us_val){.type=VAL_NADA, .dat={.number=0}})
#define wrap_str(o) ((struct us_val){.type=VAL_STR, .dat={.str=(o)}})
#define wrap_arr(o) ((struct us_val){.type=VAL_ARR, .dat={.arr=(o)}})
#define wrap_map(o) ((struct us_val){.type=VAL_MAP, .dat={.map=(o)}})
@@ -37,7 +37,7 @@
enum val_type {
VAL_NUM,
VAL_BOOL,
- VAL_ZILCH,
+ VAL_NADA,
// Do not place any new object types before VAL_STR. Object types are
// detected by doing a comparison with VAL_STR. See val_is_obj().
VAL_STR,
diff --git a/uscript/vm.c b/uscript/vm.c
index 97f4958..817629d 100644
--- a/uscript/vm.c
+++ b/uscript/vm.c
@@ -282,7 +282,7 @@ void us_exec(struct us_func *func)
break;
case BC_FALSE: vm_push(create_bool(false)); break;
case BC_TRUE: vm_push(create_bool(true)); break;
- case BC_ZILCH: vm_push(create_zilch()); break;
+ case BC_NADA: vm_push(create_nada()); break;
case BC_ARR: {
struct us_arr *arr = create_arr();
u8 arr_len = read_byte();
@@ -502,7 +502,7 @@ int declare_global(struct us_str *name)
int idx = da_len(vm.gstack);
struct global global;
global.name = name;
- global.val = create_zilch();
+ global.val = create_nada();
da_append(struct global, &vm.gstack, global);
return idx;
}
diff --git a/uscript/xbytecode.h b/uscript/xbytecode.h
index 5eef6db..99e0e81 100644
--- a/uscript/xbytecode.h
+++ b/uscript/xbytecode.h
@@ -3,7 +3,7 @@ BC(LOAD_FUNC)
BC(SMALL_INT)
BC(FALSE)
BC(TRUE)
-BC(ZILCH)
+BC(NADA)
BC(ARR)
BC(MAP)
BC(GET_LOCAL)