diff --git a/lib/comp.c b/lib/comp.c index 88047b8..ea4134e 100644 --- a/lib/comp.c +++ b/lib/comp.c @@ -2281,7 +2281,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_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)); cmd = HCL_CNODE_CONS_CAR(xlist); /* do itself */ obj = HCL_CNODE_CONS_CDR(xlist); /* expression list after it */ @@ -3915,6 +3915,10 @@ static int compile_cons_xlist_expression (hcl_t* hcl, hcl_cnode_t* obj, int nret if (compile_fun(hcl, obj, 0) <= -1) return -1; goto done; + case HCL_CNODE_DO: + if (compile_do(hcl, obj) <= -1) return -1; + goto done; + case HCL_CNODE_IF: if (compile_if(hcl, obj) <= -1) return -1; goto done; diff --git a/lib/hcl-prv.h b/lib/hcl-prv.h index 5e023b0..5535fdf 100644 --- a/lib/hcl-prv.h +++ b/lib/hcl-prv.h @@ -303,6 +303,7 @@ enum hcl_tok_type_t HCL_TOK_CLASS, HCL_TOK_FUN, + HCL_TOK_DO, HCL_TOK_IF, HCL_TOK_ELIF, HCL_TOK_ELSE, @@ -399,6 +400,7 @@ enum hcl_cnode_type_t HCL_CNODE_CLASS, HCL_CNODE_FUN, + HCL_CNODE_DO, HCL_CNODE_IF, HCL_CNODE_ELIF, HCL_CNODE_ELSE, diff --git a/lib/read.c b/lib/read.c index bcd65ca..d50c3e1 100644 --- a/lib/read.c +++ b/lib/read.c @@ -60,6 +60,7 @@ static struct voca_t { 5, { 'c','l','a','s','s' } }, { 3, { 'f','u','n' } }, + { 2, { 'd','o' } }, { 2, { 'i','f' } }, { 4, { 'e','l','i','f' } }, { 4, { 'e','l','s','e' } }, @@ -117,6 +118,7 @@ enum voca_id_t VOCA_KW_CLASS, VOCA_KW_FUN, + VOCA_KW_DO, VOCA_KW_IF, VOCA_KW_ELIF, VOCA_KW_ELSE, @@ -441,6 +443,7 @@ static hcl_tok_type_t classify_ident_token (hcl_t* hcl, const hcl_oocs_t* v) { VOCA_KW_CLASS, HCL_TOK_CLASS }, { VOCA_KW_FUN, HCL_TOK_FUN }, + { VOCA_KW_DO, HCL_TOK_DO }, { VOCA_KW_IF, HCL_TOK_IF }, { VOCA_KW_ELIF, HCL_TOK_ELIF }, { VOCA_KW_ELSE, HCL_TOK_ELSE }, @@ -1272,6 +1275,7 @@ static hcl_cnode_type_t kw_to_cnode_type (int tok_type) HCL_CNODE_CLASS, HCL_CNODE_FUN, + HCL_CNODE_DO, HCL_CNODE_IF, HCL_CNODE_ELIF, HCL_CNODE_ELSE, @@ -1693,6 +1697,7 @@ static int feed_process_token (hcl_t* hcl) case HCL_TOK_CLASS: case HCL_TOK_FUN: + case HCL_TOK_DO: case HCL_TOK_IF: case HCL_TOK_ELIF: case HCL_TOK_ELSE: