'do' treated as a keyword
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
hyung-hwan 2024-08-23 01:07:08 +09:00
parent 229d3b1f29
commit 8602a479d7
3 changed files with 12 additions and 1 deletions

View File

@ -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_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 */ cmd = HCL_CNODE_CONS_CAR(xlist); /* do itself */
obj = HCL_CNODE_CONS_CDR(xlist); /* expression list after it */ 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; if (compile_fun(hcl, obj, 0) <= -1) return -1;
goto done; goto done;
case HCL_CNODE_DO:
if (compile_do(hcl, obj) <= -1) return -1;
goto done;
case HCL_CNODE_IF: case HCL_CNODE_IF:
if (compile_if(hcl, obj) <= -1) return -1; if (compile_if(hcl, obj) <= -1) return -1;
goto done; goto done;

View File

@ -303,6 +303,7 @@ enum hcl_tok_type_t
HCL_TOK_CLASS, HCL_TOK_CLASS,
HCL_TOK_FUN, HCL_TOK_FUN,
HCL_TOK_DO,
HCL_TOK_IF, HCL_TOK_IF,
HCL_TOK_ELIF, HCL_TOK_ELIF,
HCL_TOK_ELSE, HCL_TOK_ELSE,
@ -399,6 +400,7 @@ enum hcl_cnode_type_t
HCL_CNODE_CLASS, HCL_CNODE_CLASS,
HCL_CNODE_FUN, HCL_CNODE_FUN,
HCL_CNODE_DO,
HCL_CNODE_IF, HCL_CNODE_IF,
HCL_CNODE_ELIF, HCL_CNODE_ELIF,
HCL_CNODE_ELSE, HCL_CNODE_ELSE,

View File

@ -60,6 +60,7 @@ static struct voca_t
{ 5, { 'c','l','a','s','s' } }, { 5, { 'c','l','a','s','s' } },
{ 3, { 'f','u','n' } }, { 3, { 'f','u','n' } },
{ 2, { 'd','o' } },
{ 2, { 'i','f' } }, { 2, { 'i','f' } },
{ 4, { 'e','l','i','f' } }, { 4, { 'e','l','i','f' } },
{ 4, { 'e','l','s','e' } }, { 4, { 'e','l','s','e' } },
@ -117,6 +118,7 @@ enum voca_id_t
VOCA_KW_CLASS, VOCA_KW_CLASS,
VOCA_KW_FUN, VOCA_KW_FUN,
VOCA_KW_DO,
VOCA_KW_IF, VOCA_KW_IF,
VOCA_KW_ELIF, VOCA_KW_ELIF,
VOCA_KW_ELSE, 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_CLASS, HCL_TOK_CLASS },
{ VOCA_KW_FUN, HCL_TOK_FUN }, { VOCA_KW_FUN, HCL_TOK_FUN },
{ VOCA_KW_DO, HCL_TOK_DO },
{ VOCA_KW_IF, HCL_TOK_IF }, { VOCA_KW_IF, HCL_TOK_IF },
{ VOCA_KW_ELIF, HCL_TOK_ELIF }, { VOCA_KW_ELIF, HCL_TOK_ELIF },
{ VOCA_KW_ELSE, HCL_TOK_ELSE }, { 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_CLASS,
HCL_CNODE_FUN, HCL_CNODE_FUN,
HCL_CNODE_DO,
HCL_CNODE_IF, HCL_CNODE_IF,
HCL_CNODE_ELIF, HCL_CNODE_ELIF,
HCL_CNODE_ELSE, HCL_CNODE_ELSE,
@ -1693,6 +1697,7 @@ static int feed_process_token (hcl_t* hcl)
case HCL_TOK_CLASS: case HCL_TOK_CLASS:
case HCL_TOK_FUN: case HCL_TOK_FUN:
case HCL_TOK_DO:
case HCL_TOK_IF: case HCL_TOK_IF:
case HCL_TOK_ELIF: case HCL_TOK_ELIF:
case HCL_TOK_ELSE: case HCL_TOK_ELSE: