commit cf61eb6e98feef2d30d0aac7c2c7906d9404c2ae
parent e064fd5ec9ce8da126b45eaa0d564576812dfc03
Author: NunoSempere <nuno.sempere@protonmail.com>
Date: Mon, 1 May 2023 21:36:50 -0400
step: make top level interpretation more parsimonious
Diffstat:
2 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/mumble b/mumble
Binary files differ.
diff --git a/src/mumble.c b/src/mumble.c
@@ -116,12 +116,27 @@ lispval* read_lispval_num(mpc_ast_t* t)
}
lispval* read_lispval(mpc_ast_t* t)
{
+ // Non-ignorable children
+ // Relevant for the edge-case of considering the case where you
+ // only have one top level item.
+ int c = 0;
+ int c_index = -1;
+ for(int i=0; i<t->children_num; i++){
+ mpc_ast_t* child = t->children[i];
+ if( ( strcmp(child->tag, "regex") != 0 ) || (strcmp(child->contents, "") != 0 ) || child->children_num != 0 ){
+ c++;
+ c_index = i;
+ }
+ }
+ if(VERBOSE) printf("\nNon ignorable children: %i", c);
+
if (strstr(t->tag, "number")) {
return read_lispval_num(t);
} else if (strstr(t->tag, "symbol")) {
return lispval_sym(t->contents);
+ } else if ((strcmp(t->tag, ">") == 0) && (c==1)) {
+ return read_lispval(t->children[c_index]);
} else if ((strcmp(t->tag, ">") == 0) || strstr(t->tag, "sexpr") || strstr(t->tag, "qexpr")) {
-
lispval* x;
if((strcmp(t->tag, ">") == 0) || strstr(t->tag, "sexpr")){
x = lispval_sexpr();