From 1e97a324ecde12025c5c1a1bd73239860d22b942 Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Thu, 3 Oct 2024 21:41:59 +0900 Subject: [PATCH] removed most of syncode stuffs --- lib/cnode.c | 5 +- lib/comp.c | 289 ++++++++++-------------------------------------- lib/gc.c | 86 -------------- lib/hcl-prv.h | 39 +++---- lib/hcl.h | 51 --------- lib/print.c | 5 + lib/read.c | 35 ++++-- t/call-5001.err | 2 +- 8 files changed, 106 insertions(+), 406 deletions(-) diff --git a/lib/cnode.c b/lib/cnode.c index 958aa3f..faa3d1e 100644 --- a/lib/cnode.c +++ b/lib/cnode.c @@ -124,10 +124,7 @@ hcl_cnode_t* hcl_makecnodebchrlit (hcl_t* hcl, int flags, const hcl_loc_t* loc, hcl_cnode_t* hcl_makecnodesymbol (hcl_t* hcl, int flags, const hcl_loc_t* loc, const hcl_oocs_t* tok) { - hcl_cnode_t* c = hcl_makecnode(hcl, HCL_CNODE_SYMBOL, flags, loc, tok); - if (HCL_UNLIKELY(!c)) return HCL_NULL; - c->u.symbol.syncode = hcl_getsyncodebyoocs_noseterr(hcl, tok); - return c; + return hcl_makecnode(hcl, HCL_CNODE_SYMBOL, flags, loc, tok); } hcl_cnode_t* hcl_makecnodedsymbol (hcl_t* hcl, int flags, const hcl_loc_t* loc, const hcl_oocs_t* tok, int is_cla) diff --git a/lib/comp.c b/lib/comp.c index 51256c0..6f1f891 100644 --- a/lib/comp.c +++ b/lib/comp.c @@ -495,13 +495,6 @@ static int check_block_expression_as_body (hcl_t* hcl, hcl_cnode_t* c, const hcl goto no_block; } - if (HCL_CNODE_IS_SYMBOL_SYNCODED(car, HCL_SYNCODE_ELIF) || - HCL_CNODE_IS_SYMBOL_SYNCODED(car, HCL_SYNCODE_ELSE) || - HCL_CNODE_IS_SYMBOL_SYNCODED(car, HCL_SYNCODE_CATCH)) - { - goto no_block; - } - cdr = HCL_CNODE_CONS_CDR(c); if (cdr) { @@ -516,20 +509,10 @@ static int check_block_expression_as_body (hcl_t* hcl, hcl_cnode_t* c, const hcl /* after the body for `if` or `elif`, there can come `elif` or `else` */ if (HCL_CNODE_IS_TYPED(nxt, HCL_CNODE_ELIF) || HCL_CNODE_IS_TYPED(nxt, HCL_CNODE_ELSE)) goto ok; - if (HCL_CNODE_IS_SYMBOL(nxt)) - { - int syncode = HCL_CNODE_SYMBOL_SYNCODE(nxt); - if (syncode == HCL_SYNCODE_ELIF || syncode == HCL_SYNCODE_ELSE) goto ok; - } } else if (for_what == FOR_TRY) { if (HCL_CNODE_IS_TYPED(nxt, HCL_CNODE_CATCH)) goto ok; - if (HCL_CNODE_IS_SYMBOL(nxt)) - { - int syncode = HCL_CNODE_SYMBOL_SYNCODE(nxt); - if (syncode == HCL_SYNCODE_CATCH) goto ok; - } } } @@ -1542,15 +1525,12 @@ static int collect_vardcl (hcl_t* hcl, hcl_cnode_t* obj, hcl_cnode_t** nextobj, { var = HCL_CNODE_CONS_CAR(dcl); #if 0 - if (!HCL_CNODE_IS_SYMBOL(var)) + if (!HCL_CNODE_IS_SYMBOL_PLAIN(var)) { - hcl_setsynerrbfmt (hcl, HCL_SYNERR_ARGNAME, HCL_CNODE_GET_LOC(var), HCL_CNODE_GET_TOK(var), "local variable not symbol"); - return -1; - } - - if (HCL_CNODE_IS_SYMBOL(var) && HCL_CNODE_SYMBOL_SYNCODE(var) /* || HCL_OBJ_GET_FLAGS_KERNEL(var) >= 2 */) - { - hcl_setsynerrbfmt (hcl, HCL_SYNERR_BANNEDARGNAME, HCL_CNODE_GET_LOC(var), HCL_CNODE_GET_TOK(var), "special symbol not to be declared as local variable"); + hcl_setsynerrbfmt ( + hcl, HCL_SYNERR_ARGNAME, HCL_CNODE_GET_LOC(var), HCL_NULL, + "invalid local variable name '%.*js'", + HCL_CNODE_GET_TOKLEN(var), HCL_CNODE_GET_TOKPTR(var)); return -1; } #else @@ -1723,7 +1703,7 @@ static int compile_and (hcl_t* hcl, hcl_cnode_t* src) hcl_cnode_t* obj, * expr; HCL_ASSERT (hcl, HCL_CNODE_IS_CONS(src)); - HCL_ASSERT (hcl, HCL_CNODE_IS_SYMBOL_SYNCODED(HCL_CNODE_CONS_CAR(src), HCL_SYNCODE_AND)); + HCL_ASSERT (hcl, HCL_CNODE_IS_TYPED(HCL_CNODE_CONS_CAR(src), HCL_CNODE_AND)); obj = HCL_CNODE_CONS_CDR(src); @@ -1817,7 +1797,7 @@ static int compile_or (hcl_t* hcl, hcl_cnode_t* src) hcl_cnode_t* obj, * expr; HCL_ASSERT (hcl, HCL_CNODE_IS_CONS(src)); - HCL_ASSERT (hcl, HCL_CNODE_IS_SYMBOL_SYNCODED(HCL_CNODE_CONS_CAR(src), HCL_SYNCODE_OR)); + HCL_ASSERT (hcl, HCL_CNODE_IS_TYPED(HCL_CNODE_CONS_CAR(src), HCL_CNODE_OR)); obj = HCL_CNODE_CONS_CDR(src); @@ -1913,7 +1893,7 @@ static int compile_plus (hcl_t* hcl, hcl_cnode_t* src) hcl_cnode_t* obj, * expr; HCL_ASSERT (hcl, HCL_CNODE_IS_CONS(src)); - HCL_ASSERT (hcl, HCL_CNODE_IS_SYMBOL_SYNCODED(HCL_CNODE_CONS_CAR(src), HCL_SYNCODE_PLUS)); + HCL_ASSERT (hcl, HCL_CNODE_IS_TYPED(HCL_CNODE_CONS_CAR(src), HCL_CNODE_PLUS)); obj = HCL_CNODE_CONS_CDR(src); if (!obj) @@ -1981,7 +1961,7 @@ static int compile_break (hcl_t* hcl, hcl_cnode_t* src) hcl_ooi_t i; HCL_ASSERT (hcl, HCL_CNODE_IS_CONS(src)); - HCL_ASSERT (hcl, HCL_CNODE_IS_SYMBOL_SYNCODED(HCL_CNODE_CONS_CAR(src), HCL_SYNCODE_BREAK) || HCL_CNODE_IS_TYPED(HCL_CNODE_CONS_CAR(src), HCL_CNODE_BREAK)); + HCL_ASSERT (hcl, HCL_CNODE_IS_TYPED(HCL_CNODE_CONS_CAR(src), HCL_CNODE_BREAK)); cmd = HCL_CNODE_CONS_CAR(src); obj = HCL_CNODE_CONS_CDR(src); @@ -2096,7 +2076,7 @@ static int compile_continue (hcl_t* hcl, hcl_cnode_t* src) hcl_ooi_t i; HCL_ASSERT (hcl, HCL_CNODE_IS_CONS(src)); - HCL_ASSERT (hcl, HCL_CNODE_IS_SYMBOL_SYNCODED(HCL_CNODE_CONS_CAR(src), HCL_SYNCODE_CONTINUE) || HCL_CNODE_IS_TYPED(HCL_CNODE_CONS_CAR(src), HCL_CNODE_CONTINUE)); + HCL_ASSERT (hcl, HCL_CNODE_IS_TYPED(HCL_CNODE_CONS_CAR(src), HCL_CNODE_CONTINUE)); cmd = HCL_CNODE_CONS_CAR(src); obj = HCL_CNODE_CONS_CDR(src); @@ -2285,7 +2265,7 @@ static int compile_do (hcl_t* hcl, hcl_cnode_t* xlist) */ HCL_ASSERT (hcl, HCL_CNODE_IS_CONS(xlist)); - HCL_ASSERT (hcl, HCL_CNODE_IS_SYMBOL_SYNCODED(HCL_CNODE_CONS_CAR(xlist), HCL_SYNCODE_DO) || HCL_CNODE_IS_TYPED(HCL_CNODE_CONS_CAR(xlist), HCL_CNODE_DO)); + HCL_ASSERT (hcl, HCL_CNODE_IS_TYPED(HCL_CNODE_CONS_CAR(xlist), HCL_CNODE_DO)); #if 0 cmd = HCL_CNODE_CONS_CAR(xlist); /* do itself */ @@ -2313,7 +2293,7 @@ static int compile_if (hcl_t* hcl, hcl_cnode_t* src) hcl_cframe_t* cf; HCL_ASSERT (hcl, HCL_CNODE_IS_CONS(src)); - HCL_ASSERT (hcl, HCL_CNODE_IS_SYMBOL_SYNCODED(HCL_CNODE_CONS_CAR(src), HCL_SYNCODE_IF) || HCL_CNODE_IS_TYPED(HCL_CNODE_CONS_CAR(src), HCL_CNODE_IF)); + HCL_ASSERT (hcl, HCL_CNODE_IS_TYPED(HCL_CNODE_CONS_CAR(src), HCL_CNODE_IF)); /* (if (< 20 30) * (perform this) @@ -2423,7 +2403,7 @@ static HCL_INLINE int compile_elif (hcl_t* hcl) src = cf->operand; HCL_ASSERT (hcl, HCL_CNODE_IS_CONS(src)); - HCL_ASSERT (hcl, HCL_CNODE_IS_SYMBOL_SYNCODED(HCL_CNODE_CONS_CAR(src), HCL_SYNCODE_ELIF) || HCL_CNODE_IS_TYPED(HCL_CNODE_CONS_CAR(src), HCL_CNODE_ELIF)); + HCL_ASSERT (hcl, HCL_CNODE_IS_TYPED(HCL_CNODE_CONS_CAR(src), HCL_CNODE_ELIF)); cmd = HCL_CNODE_CONS_CAR(src); /* elif itself */ obj = HCL_CNODE_CONS_CDR(src); @@ -2464,7 +2444,7 @@ static HCL_INLINE int compile_else (hcl_t* hcl) src = cf->operand; HCL_ASSERT (hcl, HCL_CNODE_IS_CONS(src)); - HCL_ASSERT (hcl, HCL_CNODE_IS_SYMBOL_SYNCODED(HCL_CNODE_CONS_CAR(src), HCL_SYNCODE_ELSE) || HCL_CNODE_IS_TYPED(HCL_CNODE_CONS_CAR(src), HCL_CNODE_ELSE)); + HCL_ASSERT (hcl, HCL_CNODE_IS_TYPED(HCL_CNODE_CONS_CAR(src), HCL_CNODE_ELSE)); cmd = HCL_CNODE_CONS_CAR(src); /* else itself */ obj = HCL_CNODE_CONS_CDR(src); @@ -2523,7 +2503,7 @@ static int compile_class (hcl_t* hcl, hcl_cnode_t* src) class_name = HCL_NULL; - HCL_ASSERT (hcl, HCL_CNODE_IS_SYMBOL_SYNCODED(cmd, HCL_SYNCODE_CLASS) || HCL_CNODE_IS_TYPED(cmd, HCL_CNODE_CLASS)); + HCL_ASSERT (hcl, HCL_CNODE_IS_TYPED(cmd, HCL_CNODE_CLASS)); /* TODO: attribute lsit */ @@ -2544,15 +2524,6 @@ static int compile_class (hcl_t* hcl, hcl_cnode_t* src) return -1; } - if (HCL_CNODE_SYMBOL_SYNCODE(tmp)) /*|| HCL_OBJ_GET_FLAGS_KERNEL(tmp) >= 1) */ - { - hcl_setsynerrbfmt ( - hcl, HCL_SYNERR_BANNEDVARNAME, HCL_CNODE_GET_LOC(tmp), HCL_NULL, - "special symbol '%.*js' used as class name", - HCL_CNODE_GET_TOKLEN(tmp), HCL_CNODE_GET_TOKPTR(tmp)); - return -1; - } - class_name = tmp; obj = HCL_CNODE_CONS_CDR(obj); } @@ -2953,8 +2924,7 @@ static int compile_fun (hcl_t* hcl, hcl_cnode_t* src) fun_body = HCL_NULL; fun_type = FUN_PLAIN; - HCL_ASSERT (hcl, HCL_CNODE_IS_SYMBOL_SYNCODED(cmd, HCL_SYNCODE_FUN) || - HCL_CNODE_IS_TYPED(cmd, HCL_CNODE_FUN)); + HCL_ASSERT (hcl, HCL_CNODE_IS_TYPED(cmd, HCL_CNODE_FUN)); if (next) { @@ -3249,17 +3219,6 @@ static int compile_fun (hcl_t* hcl, hcl_cnode_t* src) return -1; } - /* TODO: delete this error check once SYNCODE stuffs are all deleted */ - if (HCL_CNODE_IS_SYMBOL(arg) && HCL_CNODE_SYMBOL_SYNCODE(arg) /* || HCL_OBJ_GET_FLAGS_KERNEL(arg) >= 2 */) - { - hcl_setsynerrbfmt ( - hcl, HCL_SYNERR_BANNEDVARNAME, HCL_CNODE_GET_LOC(arg), HCL_NULL, - "special symbol '%.*js' used as return variable for '%.*js'", - HCL_CNODE_GET_TOKLEN(arg), HCL_CNODE_GET_TOKPTR(arg), - HCL_CNODE_GET_TOKLEN(cmd), HCL_CNODE_GET_TOKPTR(cmd)); - return -1; - } - if (add_temporary_variable(hcl, HCL_CNODE_GET_TOK(arg), tv_dup_start) <= -1) { if (hcl->errnum == HCL_EEXIST) @@ -3314,17 +3273,6 @@ static int compile_fun (hcl_t* hcl, hcl_cnode_t* src) } else { - /* TODO: delete this error check once SYNCODE stuffs are all deleted */ - if (HCL_CNODE_IS_SYMBOL(arg) && HCL_CNODE_SYMBOL_SYNCODE(arg) /* || HCL_OBJ_GET_FLAGS_KERNEL(arg) >= 2 */) - { - hcl_setsynerrbfmt ( - hcl, HCL_SYNERR_BANNEDARGNAME, HCL_CNODE_GET_LOC(arg), HCL_NULL, - "special symbol '%.*js' used as argument name for '%.*js'", - HCL_CNODE_GET_TOKLEN(arg), HCL_CNODE_GET_TOKPTR(arg), - HCL_CNODE_GET_TOKLEN(cmd), HCL_CNODE_GET_TOKPTR(cmd)); - return -1; - } - if (add_temporary_variable(hcl, HCL_CNODE_GET_TOK(arg), tv_dup_start) <= -1) { if (hcl->errnum == HCL_EEXIST) @@ -3443,9 +3391,7 @@ static int compile_return (hcl_t* hcl, hcl_cnode_t* src, int ret_from_home) hcl_ooi_t i; HCL_ASSERT (hcl, HCL_CNODE_IS_CONS(src)); - HCL_ASSERT (hcl, HCL_CNODE_IS_SYMBOL_SYNCODED(HCL_CNODE_CONS_CAR(src), HCL_SYNCODE_RETURN) || - HCL_CNODE_IS_SYMBOL_SYNCODED(HCL_CNODE_CONS_CAR(src), HCL_SYNCODE_REVERT) || - HCL_CNODE_IS_TYPED(HCL_CNODE_CONS_CAR(src), HCL_CNODE_RETURN) || + HCL_ASSERT (hcl, HCL_CNODE_IS_TYPED(HCL_CNODE_CONS_CAR(src), HCL_CNODE_RETURN) || HCL_CNODE_IS_TYPED(HCL_CNODE_CONS_CAR(src), HCL_CNODE_REVERT)); fbi = &hcl->c->fnblk.info[hcl->c->fnblk.depth]; @@ -3535,7 +3481,7 @@ static int compile_set (hcl_t* hcl, hcl_cnode_t* src) int x; HCL_ASSERT (hcl, HCL_CNODE_IS_CONS(src)); - HCL_ASSERT (hcl, HCL_CNODE_IS_SYMBOL_SYNCODED(HCL_CNODE_CONS_CAR(src), HCL_SYNCODE_SET)); + HCL_ASSERT (hcl, HCL_CNODE_IS_TYPED(HCL_CNODE_CONS_CAR(src), HCL_CNODE_SET)); cmd = HCL_CNODE_CONS_CAR(src); obj = HCL_CNODE_CONS_CDR(src); @@ -3558,12 +3504,6 @@ static int compile_set (hcl_t* hcl, hcl_cnode_t* src) return -1; } - if (HCL_CNODE_IS_SYMBOL(var) && HCL_CNODE_SYMBOL_SYNCODE(var)/* || HCL_OBJ_GET_FLAGS_KERNEL(var) >= 2*/) - { - hcl_setsynerrbfmt (hcl, HCL_SYNERR_BANNEDVARNAME, HCL_CNODE_GET_LOC(var), HCL_CNODE_GET_TOK(var), "special symbol not to be used as variable name in %.*js", HCL_CNODE_GET_TOKLEN(cmd), HCL_CNODE_GET_TOKPTR(cmd)); - return -1; - } - obj = HCL_CNODE_CONS_CDR(obj); if (!obj) { @@ -3623,7 +3563,7 @@ static int compile_set_r (hcl_t* hcl, hcl_cnode_t* src) hcl_var_info_t vi; HCL_ASSERT (hcl, HCL_CNODE_IS_CONS(src)); - HCL_ASSERT (hcl, HCL_CNODE_IS_SYMBOL_SYNCODED(HCL_CNODE_CONS_CAR(src), HCL_SYNCODE_SET_R)); + HCL_ASSERT (hcl, HCL_CNODE_IS_TYPED(HCL_CNODE_CONS_CAR(src), HCL_CNODE_SET_R)); cmd = HCL_CNODE_CONS_CAR(src); obj = HCL_CNODE_CONS_CDR(src); @@ -3644,19 +3584,13 @@ static int compile_set_r (hcl_t* hcl, hcl_cnode_t* src) do { var = HCL_CNODE_CONS_CAR(obj); - if (!HCL_CNODE_IS_SYMBOL(var)) + if (!HCL_CNODE_IS_SYMBOL(var)) /* TODO: should this be HCL_CNODE_IS_SYMBOL_PLAIN(var)?? */ { if (nvars > 0) break; hcl_setsynerrbfmt (hcl, HCL_SYNERR_VARNAME, HCL_CNODE_GET_LOC(var), HCL_CNODE_GET_TOK(var), "variable name not symbol in %.*js", HCL_CNODE_GET_TOKLEN(cmd), HCL_CNODE_GET_TOKPTR(cmd)); return -1; } - if (HCL_CNODE_SYMBOL_SYNCODE(var)/* || HCL_OBJ_GET_FLAGS_KERNEL(var) >= 2*/) - { - hcl_setsynerrbfmt (hcl, HCL_SYNERR_BANNEDVARNAME, HCL_CNODE_GET_LOC(var), HCL_CNODE_GET_TOK(var), "special symbol not to be used as variable name in %.*js", HCL_CNODE_GET_TOKLEN(cmd), HCL_CNODE_GET_TOKPTR(cmd)); - return -1; - } - nvars++; obj = HCL_CNODE_CONS_CDR(obj); } @@ -3749,7 +3683,7 @@ static int compile_try (hcl_t* hcl, hcl_cnode_t* src) HCL_ASSERT (hcl, HCL_CNODE_IS_CONS(src)); - HCL_ASSERT (hcl, HCL_CNODE_IS_SYMBOL_SYNCODED(HCL_CNODE_CONS_CAR(src), HCL_SYNCODE_TRY) || HCL_CNODE_IS_TYPED(HCL_CNODE_CONS_CAR(src), HCL_CNODE_TRY)); + HCL_ASSERT (hcl, HCL_CNODE_IS_TYPED(HCL_CNODE_CONS_CAR(src), HCL_CNODE_TRY)); /* (try * (perform this) @@ -3847,7 +3781,7 @@ static HCL_INLINE int compile_catch (hcl_t* hcl) src = cf->operand; HCL_ASSERT (hcl, HCL_CNODE_IS_CONS(src)); - HCL_ASSERT (hcl, HCL_CNODE_IS_SYMBOL_SYNCODED(HCL_CNODE_CONS_CAR(src), HCL_SYNCODE_CATCH) || HCL_CNODE_IS_TYPED(HCL_CNODE_CONS_CAR(src), HCL_CNODE_CATCH)); + HCL_ASSERT (hcl, HCL_CNODE_IS_TYPED(HCL_CNODE_CONS_CAR(src), HCL_CNODE_CATCH)); cmd = HCL_CNODE_CONS_CAR(src); obj = HCL_CNODE_CONS_CDR(src); @@ -3867,14 +3801,21 @@ static HCL_INLINE int compile_catch (hcl_t* hcl) exarg = HCL_CNODE_CONS_CAR(obj); if (!HCL_CNODE_IS_CONS_CONCODED(exarg, HCL_CONCODE_XLIST) || hcl_countcnodecons(hcl, exarg) != 1) { - hcl_setsynerrbfmt (hcl, HCL_SYNERR_VARNAME, HCL_CNODE_GET_LOC(exarg), HCL_NULL, "not proper exception variable in %.*js", HCL_CNODE_GET_TOKLEN(cmd), HCL_CNODE_GET_TOKPTR(cmd)); + hcl_setsynerrbfmt ( + hcl, HCL_SYNERR_VARNAME, HCL_CNODE_GET_LOC(exarg), HCL_NULL, + "improper exception variable for '%.*js'", + HCL_CNODE_GET_TOKLEN(cmd), HCL_CNODE_GET_TOKPTR(cmd)); return -1; } exarg = HCL_CNODE_CONS_CAR(exarg); - if (!HCL_CNODE_IS_SYMBOL(exarg) || HCL_CNODE_SYMBOL_SYNCODE(exarg)) + if (!HCL_CNODE_IS_SYMBOL_PLAIN(exarg)) { - hcl_setsynerrbfmt (hcl, HCL_SYNERR_VARNAME, HCL_CNODE_GET_LOC(exarg), HCL_CNODE_GET_TOK(exarg), "invalid exception variable name in %.*js", HCL_CNODE_GET_TOKLEN(cmd), HCL_CNODE_GET_TOKPTR(cmd)); + hcl_setsynerrbfmt ( + hcl, HCL_SYNERR_VARNAME, HCL_CNODE_GET_LOC(exarg), HCL_NULL, + "invalid exception variable name '%.*js' for '%.*js'", + HCL_CNODE_GET_TOKLEN(exarg), HCL_CNODE_GET_TOKPTR(exarg), + HCL_CNODE_GET_TOKLEN(cmd), HCL_CNODE_GET_TOKPTR(cmd)); return -1; } @@ -3980,7 +3921,7 @@ static int compile_throw (hcl_t* hcl, hcl_cnode_t* src) /*hcl_cframe_t* cf;*/ HCL_ASSERT (hcl, HCL_CNODE_IS_CONS(src)); - HCL_ASSERT (hcl, HCL_CNODE_IS_SYMBOL_SYNCODED(HCL_CNODE_CONS_CAR(src), HCL_SYNCODE_THROW) || HCL_CNODE_IS_TYPED(HCL_CNODE_CONS_CAR(src), HCL_CNODE_THROW)); + HCL_ASSERT (hcl, HCL_CNODE_IS_TYPED(HCL_CNODE_CONS_CAR(src), HCL_CNODE_THROW)); obj = HCL_CNODE_CONS_CDR(src); @@ -4029,9 +3970,7 @@ static int compile_while (hcl_t* hcl, hcl_cnode_t* src, int next_cop) hcl_cframe_t* cf; HCL_ASSERT (hcl, HCL_CNODE_IS_CONS(src)); - HCL_ASSERT (hcl, HCL_CNODE_IS_SYMBOL_SYNCODED(HCL_CNODE_CONS_CAR(src), HCL_SYNCODE_UNTIL) || - HCL_CNODE_IS_SYMBOL_SYNCODED(HCL_CNODE_CONS_CAR(src), HCL_SYNCODE_WHILE) || - HCL_CNODE_IS_TYPED(HCL_CNODE_CONS_CAR(src), HCL_CNODE_UNTIL) || + HCL_ASSERT (hcl, HCL_CNODE_IS_TYPED(HCL_CNODE_CONS_CAR(src), HCL_CNODE_UNTIL) || HCL_CNODE_IS_TYPED(HCL_CNODE_CONS_CAR(src), HCL_CNODE_WHILE)); HCL_ASSERT (hcl, next_cop == COP_POST_UNTIL_COND || next_cop == COP_POST_WHILE_COND); @@ -4292,7 +4231,6 @@ static int compile_cons_alist_expression (hcl_t* hcl, hcl_cnode_t* cmd) static int compile_cons_xlist_expression (hcl_t* hcl, hcl_cnode_t* obj, int nrets) { hcl_cnode_t* car; - int syncode; /* syntax code of the first element */ /* a valid function call * (function-name argument-list) @@ -4368,117 +4306,33 @@ static int compile_cons_xlist_expression (hcl_t* hcl, hcl_cnode_t* obj, int nret case HCL_CNODE_REVERT: if (compile_return(hcl, obj, 1) <= -1) return -1; goto done; + + case HCL_CNODE_AND: + if (compile_and(hcl, obj) <= -1) return -1; + goto done; + + case HCL_CNODE_OR: + if (compile_or(hcl, obj) <= -1) return -1; + goto done; + + case HCL_CNODE_PLUS: + if (compile_plus(hcl, obj) <= -1) return -1; + goto done; + + case HCL_CNODE_SET: + if (compile_set(hcl, obj) <= -1) return -1; + goto done; + + case HCL_CNODE_SET_R: + if (compile_set_r(hcl, obj) <= -1) return -1; + goto done; } - if (HCL_CNODE_IS_SYMBOL(car) && (syncode = HCL_CNODE_SYMBOL_SYNCODE(car))) - { - if (nrets > 0) - { - hcl_setsynerrbfmt (hcl, HCL_SYNERR_CALLABLE, HCL_CNODE_GET_LOC(car), HCL_CNODE_GET_TOK(car), "not a function with return-variables"); - return -1; - } - - switch (syncode) - { - case HCL_SYNCODE_AND: - if (compile_and(hcl, obj) <= -1) return -1; - break; - - case HCL_SYNCODE_BREAK: - /* (break) */ - if (compile_break(hcl, obj) <= -1) return -1; - break; - - case HCL_SYNCODE_CATCH: - hcl_setsynerrbfmt (hcl, HCL_SYNERR_CATCH, HCL_CNODE_GET_LOC(car), HCL_CNODE_GET_TOK(car), "catch without try"); - return -1; - - case HCL_SYNCODE_CLASS: - if (compile_class(hcl, obj) <= -1) return -1; - break; - - case HCL_SYNCODE_CONTINUE: - /* (continue)*/ - if (compile_continue(hcl, obj) <= -1) return -1; - break; - - case HCL_SYNCODE_DO: - if (compile_do(hcl, obj) <= -1) return -1; - break; - - case HCL_SYNCODE_ELSE: - hcl_setsynerrbfmt (hcl, HCL_SYNERR_ELSE, HCL_CNODE_GET_LOC(car), HCL_CNODE_GET_TOK(car), "else without if"); - return -1; - - case HCL_SYNCODE_ELIF: - hcl_setsynerrbfmt (hcl, HCL_SYNERR_ELIF, HCL_CNODE_GET_LOC(car), HCL_CNODE_GET_TOK(car), "elif without if"); - return -1; - - case HCL_SYNCODE_IF: - if (compile_if(hcl, obj) <= -1) return -1; - break; - - case HCL_SYNCODE_FUN: - /* (fun (x y) (+ x y)) */ - if (compile_fun(hcl, obj) <= -1) return -1; - break; - - case HCL_SYNCODE_OR: - if (compile_or(hcl, obj) <= -1) return -1; - break; - - case HCL_SYNCODE_PLUS: - if (compile_plus(hcl, obj) <= -1) return -1; - break; - - case HCL_SYNCODE_RETURN: - /* (return 10) - * (return (+ 10 20)) */ - if (compile_return(hcl, obj, 0) <= -1) return -1; - break; - - case HCL_SYNCODE_REVERT: - if (compile_return(hcl, obj, 1) <= -1) return -1; - break; - - case HCL_SYNCODE_SET: - /* (set x 10) - * (set x (fun (x y) (+ x y)) */ - if (compile_set(hcl, obj) <= -1) return -1; - break; - - case HCL_SYNCODE_SET_R: - /* (set-r a b (func 10 20)) */ - if (compile_set_r(hcl, obj) <= -1) return -1; - break; - - case HCL_SYNCODE_THROW: - if (compile_throw(hcl, obj) <= -1) return -1; - break; - - case HCL_SYNCODE_TRY: - if (compile_try(hcl, obj) <= -1) return -1; - break; - - case HCL_SYNCODE_UNTIL: - if (compile_while(hcl, obj, COP_POST_UNTIL_COND) <= -1) return -1; - break; - - case HCL_SYNCODE_WHILE: - if (compile_while(hcl, obj, COP_POST_WHILE_COND) <= -1) return -1; - break; - - default: - HCL_DEBUG3 (hcl, "Internal error - unknown syncode %d at %s:%d\n", syncode, __FILE__, __LINE__); - hcl_setsynerrbfmt (hcl, HCL_SYNERR_INTERN, HCL_CNODE_GET_LOC(car), HCL_NULL, "internal error - unknown syncode %d", syncode); - return -1; - } - } - else if (HCL_CNODE_IS_SYMBOL(car) || HCL_CNODE_IS_DSYMBOL(car) || - HCL_CNODE_IS_CONS_CONCODED(car, HCL_CONCODE_XLIST) || - HCL_CNODE_IS_CONS_CONCODED(car, HCL_CONCODE_MLIST) || - HCL_CNODE_IS_CONS_CONCODED(car, HCL_CONCODE_BLIST) || - HCL_CNODE_IS_CONS_CONCODED(car, HCL_CONCODE_ALIST)) + if (HCL_CNODE_IS_SYMBOL(car) || HCL_CNODE_IS_DSYMBOL(car) || + HCL_CNODE_IS_CONS_CONCODED(car, HCL_CONCODE_XLIST) || + HCL_CNODE_IS_CONS_CONCODED(car, HCL_CONCODE_MLIST) || + HCL_CNODE_IS_CONS_CONCODED(car, HCL_CONCODE_BLIST) || + HCL_CNODE_IS_CONS_CONCODED(car, HCL_CONCODE_ALIST)) { /* normal function call * ( ...) */ @@ -4581,7 +4435,6 @@ static int compile_cons_mlist_expression (hcl_t* hcl, hcl_cnode_t* obj, int nret hcl_ooi_t nargs; hcl_ooi_t oldtop; hcl_cframe_t* cf; - int syncode; /* syntax code of the first element */ /* message sending * (: ...) @@ -4592,12 +4445,6 @@ static int compile_cons_mlist_expression (hcl_t* hcl, hcl_cnode_t* obj, int nret HCL_CNODE_IS_CONS_CONCODED(obj, HCL_CONCODE_MLIST)); car = HCL_CNODE_CONS_CAR(obj); - if (HCL_CNODE_IS_SYMBOL(car) && (syncode = HCL_CNODE_SYMBOL_SYNCODE(car))) - { - /* special symbols such as 'if' is not permitted here */ - hcl_setsynerrbfmt (hcl, HCL_SYNERR_BANNED, HCL_CNODE_GET_LOC(car), HCL_CNODE_GET_TOK(car), "unpermitted message receiver"); - return -1; - } /* store the position of COP_EMIT_CALL to be produced with * SWITCH_TOP_CFRAME() in oldtop for argument count patching @@ -4707,12 +4554,6 @@ static HCL_INLINE int compile_symbol (hcl_t* hcl, hcl_cnode_t* obj) HCL_ASSERT (hcl, HCL_CNODE_IS_SYMBOL(obj)); - if (HCL_CNODE_SYMBOL_SYNCODE(obj)) - { - hcl_setsynerrbfmt (hcl, HCL_SYNERR_BANNEDVARNAME, HCL_CNODE_GET_LOC(obj), HCL_CNODE_GET_TOK(obj), "special symbol not to be used as variable name"); - return -1; - } - /* check if a symbol is a local variable */ x = find_variable_backward_with_token(hcl, obj, &vi); if (x <= -1) return -1; @@ -5468,20 +5309,10 @@ static int compile_object_list (hcl_t* hcl) SWITCH_TOP_CFRAME (hcl, COP_COMPILE_ELSE, oprnd); goto done; } - else if (HCL_CNODE_IS_SYMBOL_SYNCODED(car, HCL_SYNCODE_ELIF)) - { - SWITCH_TOP_CFRAME (hcl, COP_COMPILE_ELIF, oprnd); - goto done; - } - else if (HCL_CNODE_IS_SYMBOL_SYNCODED(car, HCL_SYNCODE_ELSE)) - { - SWITCH_TOP_CFRAME (hcl, COP_COMPILE_ELSE, oprnd); - goto done; - } } else if (cop == COP_COMPILE_TRY_OBJECT_LIST || cop == COP_COMPILE_TRY_OBJECT_LIST_TAIL) { - if (HCL_CNODE_IS_SYMBOL_SYNCODED(car, HCL_SYNCODE_CATCH) || HCL_CNODE_IS_TYPED(car, HCL_CNODE_CATCH)) + if (HCL_CNODE_IS_TYPED(car, HCL_CNODE_CATCH)) { SWITCH_TOP_CFRAME (hcl, COP_COMPILE_CATCH, oprnd); goto done; diff --git a/lib/gc.c b/lib/gc.c index 4727111..666d8cf 100644 --- a/lib/gc.c +++ b/lib/gc.c @@ -29,36 +29,6 @@ #include /* getrusage */ #endif -static struct -{ - hcl_oow_t len; - hcl_ooch_t ptr[20]; - hcl_syncode_t syncode; - hcl_oow_t offset; -} syminfo[] = -{ - { 3, { 'a','n','d' }, HCL_SYNCODE_AND, HCL_OFFSETOF(hcl_t,s_and) }, - { 5, { 'b','r','e','a','k' }, HCL_SYNCODE_BREAK, HCL_OFFSETOF(hcl_t,s_break) }, - { 5, { 'c','a','t','c','h' }, HCL_SYNCODE_CATCH, HCL_OFFSETOF(hcl_t,s_catch) }, - { 5, { 'c','l','a','s','s' }, HCL_SYNCODE_CLASS, HCL_OFFSETOF(hcl_t,s_class) }, - { 8, { 'c','o','n','t','i','n','u','e' }, HCL_SYNCODE_CONTINUE, HCL_OFFSETOF(hcl_t,s_continue) }, - { 2, { 'd','o' }, HCL_SYNCODE_DO, HCL_OFFSETOF(hcl_t,s_do) }, - { 4, { 'e','l','i','f' }, HCL_SYNCODE_ELIF, HCL_OFFSETOF(hcl_t,s_elif) }, - { 4, { 'e','l','s','e' }, HCL_SYNCODE_ELSE, HCL_OFFSETOF(hcl_t,s_else) }, - { 3, { 'f','u','n' }, HCL_SYNCODE_FUN, HCL_OFFSETOF(hcl_t,s_fun) }, - { 2, { 'i','f' }, HCL_SYNCODE_IF, HCL_OFFSETOF(hcl_t,s_if) }, - { 2, { 'o','r' }, HCL_SYNCODE_OR, HCL_OFFSETOF(hcl_t,s_or) }, - { 4, { 'p','l','u','s' }, HCL_SYNCODE_PLUS, HCL_OFFSETOF(hcl_t,s_plus) }, - { 6, { 'r','e','t','u','r','n'}, HCL_SYNCODE_RETURN, HCL_OFFSETOF(hcl_t,s_return) }, - { 6, { 'r','e','v','e','r','t'}, HCL_SYNCODE_REVERT, HCL_OFFSETOF(hcl_t,s_revert) }, - { 3, { 's','e','t' }, HCL_SYNCODE_SET, HCL_OFFSETOF(hcl_t,s_set) }, - { 5, { 's','e','t','-','r' }, HCL_SYNCODE_SET_R, HCL_OFFSETOF(hcl_t,s_set_r) }, - { 5, { 't','h','r','o','w' }, HCL_SYNCODE_THROW, HCL_OFFSETOF(hcl_t,s_throw) }, - { 3, { 't','r','y' }, HCL_SYNCODE_TRY, HCL_OFFSETOF(hcl_t,s_try) }, - { 5, { 'u','n','t','i','l' }, HCL_SYNCODE_UNTIL, HCL_OFFSETOF(hcl_t,s_until) }, - { 5, { 'w','h','i','l','e' }, HCL_SYNCODE_WHILE, HCL_OFFSETOF(hcl_t,s_while) } -}; - /* ========================================================================= */ /* @@ -956,11 +926,6 @@ static HCL_INLINE void gc_ms_mark_roots (hcl_t* hcl) gc_ms_mark (hcl, hcl->_true); gc_ms_mark (hcl, hcl->_false); - for (i = 0; i < HCL_COUNTOF(syminfo); i++) - { - gc_ms_mark (hcl, *(hcl_oop_t*)((hcl_uint8_t*)hcl + syminfo[i].offset)); - } - for (i = 0; i < HCL_COUNTOF(kernel_classes); i++) { gc_ms_mark (hcl, *(hcl_oop_t*)((hcl_uint8_t*)hcl + kernel_classes[i].offset)); @@ -1235,14 +1200,6 @@ void hcl_gc (hcl_t* hcl) hcl->_true = hcl_moveoop(hcl, hcl->_true); hcl->_false = hcl_moveoop(hcl, hcl->_false); - for (i = 0; i < HCL_COUNTOF(syminfo); i++) - { - hcl_oop_t tmp; - tmp = *(hcl_oop_t*)((hcl_uint8_t*)hcl + syminfo[i].offset); - tmp = hcl_moveoop(hcl, tmp); - *(hcl_oop_t*)((hcl_uint8_t*)hcl + syminfo[i].offset) = tmp; - } - for (i = 0; i < HCL_COUNTOF(kernel_classes); i++) { hcl_oop_t tmp; @@ -1814,18 +1771,6 @@ int hcl_ignite (hcl_t* hcl, hcl_oow_t heapsize) if (HCL_UNLIKELY(!hcl->sysdic)) goto oops; } - /* symbol table available now. symbols can be created */ - for (i = 0; i < HCL_COUNTOF(syminfo); i++) - { - hcl_oop_t tmp; - - tmp = hcl_makesymbol(hcl, syminfo[i].ptr, syminfo[i].len); - if (HCL_UNLIKELY(!tmp)) goto oops; - - HCL_OBJ_SET_FLAGS_SYNCODE (tmp, syminfo[i].syncode); - *(hcl_oop_t*)((hcl_uint8_t*)hcl + syminfo[i].offset) = tmp; - } - if (!hcl->nil_process) { /* Create a nil process used to simplify nil check in GC. @@ -1882,34 +1827,3 @@ oops: return -1; } -hcl_syncode_t hcl_getsyncodebyoocs_noseterr (hcl_t* hcl, const hcl_oocs_t* name) -{ - hcl_oow_t i; - for (i = 0; i < HCL_COUNTOF(syminfo); i++) - { - if (hcl_comp_oochars(syminfo[i].ptr, syminfo[i].len, name->ptr, name->len) == 0) - return syminfo[i].syncode; - } - return HCL_SYNCODE_NONE; /* indicates no syntax code found */ -} - -hcl_syncode_t hcl_getsyncode_noseterr (hcl_t* hcl, const hcl_ooch_t* ptr, const hcl_oow_t len) -{ - hcl_oow_t i; - for (i = 0; i < HCL_COUNTOF(syminfo); i++) - { - if (hcl_comp_oochars(syminfo[i].ptr, syminfo[i].len, ptr, len) == 0) - return syminfo[i].syncode; - } - return HCL_SYNCODE_NONE; /* indicates no syntax code found */ -} - -const hcl_ooch_t* hcl_getsyncodename_noseterr (hcl_t* hcl, hcl_syncode_t syncode) -{ - hcl_oow_t i; - for (i = 0; i < HCL_COUNTOF(syminfo); i++) - { - if (syncode == syminfo[i].syncode) return syminfo[i].ptr; - } - return HCL_NULL; -} diff --git a/lib/hcl-prv.h b/lib/hcl-prv.h index eb4987b..437352c 100644 --- a/lib/hcl-prv.h +++ b/lib/hcl-prv.h @@ -317,6 +317,11 @@ enum hcl_tok_type_t HCL_TOK_WHILE, HCL_TOK_RETURN, HCL_TOK_REVERT, + HCL_TOK_AND, + HCL_TOK_OR, + HCL_TOK_PLUS, + HCL_TOK_SET, + HCL_TOK_SET_R, HCL_TOK_BINOP, HCL_TOK_IDENT, @@ -423,7 +428,12 @@ enum hcl_cnode_type_t HCL_CNODE_UNTIL, HCL_CNODE_WHILE, HCL_CNODE_RETURN, - HCL_CNODE_REVERT, /* language item for HCL_CODE_IS_FOR_LANG */ + HCL_CNODE_REVERT, + HCL_CNODE_AND, + HCL_CNODE_OR, + HCL_CNODE_PLUS, + HCL_CNODE_SET, + HCL_CNODE_SET_R, /* language item for HCL_CODE_IS_FOR_LANG */ HCL_CNODE_ELLIPSIS, /* ... */ HCL_CNODE_TRPCOLONS, /* ::: */ @@ -454,7 +464,7 @@ typedef enum hcl_cnode_flag_t hcl_cnode_flag_t; /* words to compose the language itself. * the words pointing to data items(e.g. super, self, nil, true, false) are excluded */ -#define HCL_CNODE_IS_FOR_LANG(x)((x)->cn_type >= HCL_CNODE_CLASS && (x)->cn_type <= HCL_CNODE_REVERT) +#define HCL_CNODE_IS_FOR_LANG(x)((x)->cn_type >= HCL_CNODE_CLASS && (x)->cn_type <= HCL_CNODE_SET_R) #define HCL_CNODE_IS_ELLIPSIS(x) ((x)->cn_type == HCL_CNODE_ELLIPSIS) #define HCL_CNODE_IS_TRPCOLONS(x) ((x)->cn_type == HCL_CNODE_TRPCOLONS) @@ -464,11 +474,9 @@ typedef enum hcl_cnode_flag_t hcl_cnode_flag_t; #define HCL_CNODE_IS_COLONLT(x) ((x)->cn_type == HCL_CNODE_COLONLT) #define HCL_CNODE_IS_SYMBOL(x) ((x)->cn_type == HCL_CNODE_SYMBOL) -#define HCL_CNODE_IS_SYMBOL_PLAIN(x) ((x)->cn_type == HCL_CNODE_SYMBOL && (x)->u.symbol.syncode == 0) +#define HCL_CNODE_IS_SYMBOL_PLAIN(x) ((x)->cn_type == HCL_CNODE_SYMBOL) #define HCL_CNODE_IS_SYMBOL_PLAIN_IDENT(x) (HCL_CNODE_IS_SYMBOL_PLAIN(x) && !hcl_is_binop_char((x)->cn_tok.ptr[0])) #define HCL_CNODE_IS_SYMBOL_PLAIN_BINOP(x) (HCL_CNODE_IS_SYMBOL_PLAIN(x) && hcl_is_binop_char((x)->cn_tok.ptr[0])) -#define HCL_CNODE_IS_SYMBOL_SYNCODED(x, code) ((x)->cn_type == HCL_CNODE_SYMBOL && (x)->u.symbol.syncode == (code)) -#define HCL_CNODE_SYMBOL_SYNCODE(x) ((x)->u.symbol.syncode) #define HCL_CNODE_IS_DSYMBOL(x) ((x)->cn_type == HCL_CNODE_DSYMBOL) #define HCL_CNODE_IS_DSYMBOL_CLA(x) ((x)->cn_type == HCL_CNODE_DSYMBOL && (x)->u.dsymbol.is_cla) @@ -502,10 +510,6 @@ struct hcl_cnode_t hcl_oob_t v; } bchrlit; struct - { - hcl_syncode_t syncode; /* special if non-zero */ - } symbol; - struct { int is_cla; /* class-level accessor. prefixed with self or super */ } dsymbol; @@ -1619,23 +1623,6 @@ void hcl_gc_ms_sweep_lazy ( hcl_oow_t allocsize ); -hcl_syncode_t hcl_getsyncodebyoocs_noseterr ( - hcl_t* hcl, - const hcl_oocs_t* name -); - -hcl_syncode_t hcl_getsyncode_noseterr ( - hcl_t* hcl, - const hcl_ooch_t* ptr, - const hcl_oow_t len -); - -const hcl_ooch_t* hcl_getsyncodename_noseterr ( - hcl_t* hcl, - hcl_syncode_t syncode -); - - /* ========================================================================= */ /* utf8.c */ /* ========================================================================= */ diff --git a/lib/hcl.h b/lib/hcl.h index d556e84..c88e00f 100644 --- a/lib/hcl.h +++ b/lib/hcl.h @@ -1680,28 +1680,6 @@ struct hcl_t hcl_oop_t _true; hcl_oop_t _false; - hcl_oop_t s_and; /* symbol */ - hcl_oop_t s_break; /* symbol */ - hcl_oop_t s_catch; /* symbol */ - hcl_oop_t s_class; /* symbol */ - hcl_oop_t s_continue; /* symbol */ - hcl_oop_t s_defun; /* symbol */ - hcl_oop_t s_do; /* symbol */ - hcl_oop_t s_elif; /* symbol */ - hcl_oop_t s_else; /* symbol */ - hcl_oop_t s_fun; /* symbol */ - hcl_oop_t s_if; /* symbol */ - hcl_oop_t s_or; /* symbol */ - hcl_oop_t s_plus; /* symbol */ - hcl_oop_t s_return; /* symbol */ - hcl_oop_t s_revert; /* symbol */ - hcl_oop_t s_set; /* symbol */ - hcl_oop_t s_set_r; /* symbol */ - hcl_oop_t s_throw; /* symbol */ - hcl_oop_t s_try; /* symbol */ /* _try is special in MSVC. */ - hcl_oop_t s_until; /* symbol */ - hcl_oop_t s_while; /* symbol */ - hcl_oop_dic_t symtab; /* system-wide symbol table. */ hcl_oop_dic_t sysdic; /* system dictionary. */ hcl_oop_process_scheduler_t processor; /* instance of ProcessScheduler */ @@ -2043,35 +2021,6 @@ enum hcl_brand_t }; typedef enum hcl_brand_t hcl_brand_t; -enum hcl_syncode_t -{ - HCL_SYNCODE_NONE = 0, - - /* SYNCODE 0 means it's not a syncode object. so the actual code begins with 1 */ - /* these enumerators can be set in the SYNCODE flags for a symbol */ - HCL_SYNCODE_AND = 1, - HCL_SYNCODE_BREAK, - HCL_SYNCODE_CATCH, - HCL_SYNCODE_CLASS, - HCL_SYNCODE_CONTINUE, - HCL_SYNCODE_DO, - HCL_SYNCODE_ELIF, - HCL_SYNCODE_ELSE, - HCL_SYNCODE_IF, - HCL_SYNCODE_FUN, - HCL_SYNCODE_OR, - HCL_SYNCODE_PLUS, - HCL_SYNCODE_RETURN, /* local return. return from the current context. */ - HCL_SYNCODE_REVERT, /* non-local return. return from home context */ - HCL_SYNCODE_SET, - HCL_SYNCODE_SET_R, - HCL_SYNCODE_THROW, - HCL_SYNCODE_TRY, - HCL_SYNCODE_UNTIL, - HCL_SYNCODE_WHILE -}; -typedef enum hcl_syncode_t hcl_syncode_t; - enum hcl_concode_t { /* these can be set in the SYNCODE flags for a cons cell */ diff --git a/lib/print.c b/lib/print.c index 19cce10..042bf2f 100644 --- a/lib/print.c +++ b/lib/print.c @@ -938,6 +938,11 @@ void hcl_dumpcnode (hcl_t* hcl, hcl_cnode_t* cnode, int newline) case HCL_CNODE_WHILE: case HCL_CNODE_RETURN: case HCL_CNODE_REVERT: + case HCL_CNODE_AND: + case HCL_CNODE_OR: + case HCL_CNODE_PLUS: + case HCL_CNODE_SET: + case HCL_CNODE_SET_R: case HCL_CNODE_ELLIPSIS: case HCL_CNODE_TRPCOLONS: diff --git a/lib/read.c b/lib/read.c index 12dd7ef..4b212b2 100644 --- a/lib/read.c +++ b/lib/read.c @@ -73,7 +73,9 @@ static struct voca_t { 5, { 'w','h','i','l','e' } }, { 6, { 'r','e','t','u','r','n' } }, { 6, { 'r','e','v','e','r','t' } }, - + { 3, { 'a','n','d' } }, + { 2, { 'o','r', } }, + { 4, { 'p','l','u','s' } }, { 3, { 's','e','t' } }, { 5, { 's','e','t','-','r' } }, @@ -131,9 +133,11 @@ enum voca_id_t VOCA_KW_WHILE, VOCA_KW_RETURN, VOCA_KW_REVERT, - - VOCA_SYM_SET, - VOCA_SYM_SET_R, + VOCA_KW_AND, + VOCA_KW_OR, + VOCA_KW_PLUS, + VOCA_KW_SET, + VOCA_KW_SET_R, VOCA_XLIST, VOCA_MLIST, @@ -478,7 +482,12 @@ static hcl_tok_type_t classify_ident_token (hcl_t* hcl, const hcl_oocs_t* v) { VOCA_KW_UNTIL, HCL_TOK_UNTIL }, { VOCA_KW_WHILE, HCL_TOK_WHILE }, { VOCA_KW_RETURN, HCL_TOK_RETURN }, - { VOCA_KW_REVERT, HCL_TOK_REVERT } + { VOCA_KW_REVERT, HCL_TOK_REVERT }, + { VOCA_KW_AND, HCL_TOK_AND }, + { VOCA_KW_OR, HCL_TOK_OR }, + { VOCA_KW_PLUS, HCL_TOK_PLUS }, + { VOCA_KW_SET, HCL_TOK_SET }, + { VOCA_KW_SET_R, HCL_TOK_SET_R } }; for (i = 0; i < HCL_COUNTOF(tab); i++) @@ -893,8 +902,7 @@ static HCL_INLINE int can_colon_list (hcl_t* hcl) * these class methods and class instantiation methods are supposed to be * implemented elsewhere because ':' has dual use while '::' or ':*' are * independent tokens */ - if (HCL_CNODE_IS_SYMBOL_SYNCODED(HCL_CNODE_CONS_CAR(rstl->head), HCL_SYNCODE_FUN) || - HCL_CNODE_IS_TYPED(HCL_CNODE_CONS_CAR(rstl->head), HCL_CNODE_FUN)) + if (HCL_CNODE_IS_TYPED(HCL_CNODE_CONS_CAR(rstl->head), HCL_CNODE_FUN)) { hcl_cnode_t* tmp, * next; next = HCL_CNODE_CONS_CDR(rstl->head); @@ -1428,7 +1436,12 @@ static hcl_cnode_type_t kw_to_cnode_type (int tok_type) HCL_CNODE_UNTIL, HCL_CNODE_WHILE, HCL_CNODE_RETURN, - HCL_CNODE_REVERT + HCL_CNODE_REVERT, + HCL_CNODE_AND, + HCL_CNODE_OR, + HCL_CNODE_PLUS, + HCL_CNODE_SET, + HCL_CNODE_SET_R }; return mapping[tok_type - HCL_TOK_NIL]; @@ -1863,10 +1876,14 @@ static int feed_process_token (hcl_t* hcl) case HCL_TOK_WHILE: case HCL_TOK_RETURN: case HCL_TOK_REVERT: + case HCL_TOK_AND: + case HCL_TOK_OR: + case HCL_TOK_PLUS: + case HCL_TOK_SET: + case HCL_TOK_SET_R: frd->obj = hcl_makecnode(hcl, kw_to_cnode_type(TOKEN_TYPE(hcl)), 0, TOKEN_LOC(hcl), TOKEN_NAME(hcl)); goto auto_xlist; - case HCL_TOK_ELLIPSIS: frd->obj = hcl_makecnodeellipsis(hcl, 0, TOKEN_LOC(hcl), TOKEN_NAME(hcl)); goto auto_xlist; diff --git a/t/call-5001.err b/t/call-5001.err index f413ec9..58f5d08 100644 --- a/t/call-5001.err +++ b/t/call-5001.err @@ -64,7 +64,7 @@ try {} catch ##ERROR: syntax error - no exception variable for 'catch' try { throw "excetion message" -} catch (e a) { ##ERROR: syntax error - not proper exception variable +} catch (e a) { ##ERROR: syntax error - improper exception variable for 'catch' printf "EXCEPTION - %s\n" e }