diff options
author | ubq323 <ubq323@ubq323.website> | 2024-08-06 18:24:28 +0100 |
---|---|---|
committer | ubq323 <ubq323@ubq323.website> | 2024-08-06 18:24:28 +0100 |
commit | a701883f4ea83022261304d225eb8225af52b302 (patch) | |
tree | d95127abc4cfa953653bdc550ebada0061678d16 | |
parent | 0cc8e1fd89aacd54926b61ac3b9c4a2810024b4a (diff) |
fix failing tests
-rw-r--r-- | com.c | 11 | ||||
-rw-r--r-- | read.c | 2 | ||||
-rw-r--r-- | state.h | 1 |
3 files changed, 10 insertions, 4 deletions
@@ -619,10 +619,10 @@ static void cpl_expr(Compiler *C, Val v, int flags) { if (form) { size_t nargs = len - 1; if (form->ellipsis) - CHECK(nargs >= form->min_params, "%s requires at least %d args", + CHECK(nargs >= form->min_params, "%s requires at least %d parameters", form->name, form->min_params); else - CHECK(nargs == form->min_params, "%s requires exactly %d args", + CHECK(nargs == form->min_params, "%s requires exactly %d parameters", form->name, form->min_params); form->action(C, a, form->op, flags); } else { @@ -654,6 +654,7 @@ int main(int argc, char **argv) { S->do_disasm = false; S->do_trace = false; + S->do_dumpsexpr = false; char *infile_names[16]; int infile_name_n = 0; @@ -669,6 +670,7 @@ int main(int argc, char **argv) { switch (argv[i][2]) { case 'l': S->do_disasm = true; break; case 't': S->do_trace = true; break; + case 's': S->do_dumpsexpr = true; break; default: ERROR("unknown option b"); } break; @@ -699,9 +701,12 @@ int main(int argc, char **argv) { fread(buf, 1, 8192, infile); buf[8192] = '\0'; ObjArr *top = read_exprs(S, buf); + + if (S->do_dumpsexpr) + println_val(VAL_OBJ(top)); + cpl_body(&com, top, 0, 0); - // println_val(VAL_OBJ(top)); // pcc_destroy(parser); // compile_body(&com, top.as.list, 0, 0); @@ -18,7 +18,7 @@ static bool is_ws(char x) { return x == ' ' || x == '\t' || x == '\n';} static bool is_num(char x) { return '0' <= x && x <= '9'; } static bool is_special(char x) { switch(x) { - case '(': case ')': case '[': case ']': case '\'': case '"': + case '(': case ')': case '[': case ']': case '"': return true; break; default: return false; break; } @@ -13,6 +13,7 @@ struct _state { bool do_disasm; bool do_trace; + bool do_dumpsexpr; }; State state_new(); |