changed ::: to :: to indicate class variables, parent class, retvar
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2024-02-04 01:57:53 +09:00
parent b20d6b14d8
commit 48e6df233b
17 changed files with 59 additions and 37 deletions

View File

@ -86,6 +86,11 @@ hcl_cnode_t* hcl_makecnodetrpcolons (hcl_t* hcl, int flags, const hcl_loc_t* loc
return make_cnode(hcl, HCL_CNODE_TRPCOLONS, flags, loc, tok);
}
hcl_cnode_t* hcl_makecnodedblcolons (hcl_t* hcl, int flags, const hcl_loc_t* loc, const hcl_oocs_t* tok)
{
return make_cnode(hcl, HCL_CNODE_DBLCOLONS, flags, loc, tok);
}
hcl_cnode_t* hcl_makecnodecolongt (hcl_t* hcl, int flags, const hcl_loc_t* loc, const hcl_oocs_t* tok)
{
return make_cnode(hcl, HCL_CNODE_COLONGT, flags, loc, tok);

View File

@ -2406,7 +2406,7 @@ static int compile_class (hcl_t* hcl, hcl_cnode_t* src, int defclass)
hcl_cnode_t* tmp, * dcl;
tmp = HCL_CNODE_CONS_CAR(obj);
if (!HCL_CNODE_IS_TRPCOLONS(tmp)) goto no_superclass;
if (!HCL_CNODE_IS_DBLCOLONS(tmp)) goto no_superclass;
tmp = obj;
obj = HCL_CNODE_CONS_CDR(obj);
@ -2485,18 +2485,18 @@ static HCL_INLINE int compile_class_p1 (hcl_t* hcl)
hcl_cnode_t* tmp;
hcl_oow_t dclcount;
/*
(defclass X ::: T
::: | a b c | ## class variables
(defclass X :: T
:: | a b c | ## class variables
)
(defclass X
::: T | a b c | ## instance varaiables.
:: T | a b c | ## instance varaiables.
)
(defclass X
::: | a b c | ## class variables
:: | a b c | ## class variables
)
*/
tmp = HCL_CNODE_CONS_CAR(obj);
if (HCL_CNODE_IS_TRPCOLONS(tmp))
if (HCL_CNODE_IS_DBLCOLONS(tmp))
{
/* class variables */
hcl_oow_t checkpoint;
@ -2745,11 +2745,10 @@ static int compile_lambda (hcl_t* hcl, hcl_cnode_t* src, int defun)
defun_name = HCL_CNODE_CONS_CAR(obj);
if (is_in_class_init_scope(hcl))
{
if ((HCL_CNODE_IS_TRPCOLONS(defun_name) || HCL_CNODE_IS_COLONSTAR(defun_name)))
if ((HCL_CNODE_IS_DBLCOLONS(defun_name) || HCL_CNODE_IS_COLONSTAR(defun_name)))
{
/* class method - (defun ::: xxxx () ...) inside class definition */
/* class method - (defun:+ xxxx() ...) inside class definition */
/* class instantiation method - (defun:* xxxx() ...) inside class definition */
/* class method - (defun ::xxxx () ...) inside class definition */
/* class instantiation method - (defun :*xxxx() ...) inside class definition */
obj = HCL_CNODE_CONS_CDR(obj);
if (!obj)
{
@ -2757,7 +2756,7 @@ static int compile_lambda (hcl_t* hcl, hcl_cnode_t* src, int defun)
return -1;
}
fun_type = HCL_CNODE_IS_TRPCOLONS(defun_name)? FUN_CM: FUN_CIM;
fun_type = HCL_CNODE_IS_DBLCOLONS(defun_name)? FUN_CM: FUN_CIM;
defun_name = HCL_CNODE_CONS_CAR(obj); /* advance to the actual name */
}
else
@ -2849,7 +2848,7 @@ static int compile_lambda (hcl_t* hcl, hcl_cnode_t* src, int defun)
}
else if (va)
{
if (HCL_CNODE_IS_TRPCOLONS(arg))
if (HCL_CNODE_IS_DBLCOLONS(arg))
{
in_ret_args = 1;
}
@ -2861,7 +2860,7 @@ static int compile_lambda (hcl_t* hcl, hcl_cnode_t* src, int defun)
}
else
{
if (HCL_CNODE_IS_TRPCOLONS(arg))
if (HCL_CNODE_IS_DBLCOLONS(arg))
{
in_ret_args = 1;
}
@ -4609,8 +4608,15 @@ redo:
hcl_setsynerrbfmt (hcl, HCL_SYNERR_TRPCOLONSBANNED, HCL_CNODE_GET_LOC(oprnd), HCL_CNODE_GET_TOK(oprnd), "triple colons disallowed in this context", HCL_CNODE_GET_TYPE(oprnd));
return -1;
case HCL_CNODE_DBLCOLONS:
case HCL_CNODE_COLONLT:
case HCL_CNODE_COLONGT:
case HCL_CNODE_COLONSTAR:
default:
/*
hcl_setsynerrbfmt (hcl, HCL_SYNERR_INTERN, HCL_CNODE_GET_LOC(oprnd), HCL_CNODE_GET_TOK(oprnd), "internal error - unexpected object type %d", HCL_CNODE_GET_TYPE(oprnd));
*/
hcl_setsynerrbfmt (hcl, HCL_SYNERR_BANNED, HCL_CNODE_GET_LOC(oprnd), HCL_CNODE_GET_TOK(oprnd), "prohibited in this context", HCL_CNODE_GET_TYPE(oprnd));
return -1;
}
@ -4699,7 +4705,7 @@ static int compile_object_list (hcl_t* hcl)
car = HCL_CNODE_CONS_CAR(oprnd);
/* this optimization is buggy for now... need to perfect the break condition here */
if (HCL_CNODE_IS_CONS(car) || (HCL_CNODE_IS_SYMBOL(car) && HCL_CNODE_SYMBOL_SYNCODE(car)) || HCL_CNODE_IS_ELLIPSIS(car) || HCL_CNODE_IS_TRPCOLONS(car)) break;
if (HCL_CNODE_IS_CONS(car) || (HCL_CNODE_IS_SYMBOL(car) && HCL_CNODE_SYMBOL_SYNCODE(car)) || HCL_CNODE_IS_ELLIPSIS(car) || HCL_CNODE_IS_DBLCOLONS(car)) break;
oprnd = cdr;
}

View File

@ -258,6 +258,7 @@ enum hcl_cnode_type_t
HCL_CNODE_SUPER,
HCL_CNODE_ELLIPSIS,
HCL_CNODE_TRPCOLONS,
HCL_CNODE_DBLCOLONS, /* :: */
HCL_CNODE_COLONGT, /* :> */
HCL_CNODE_COLONLT, /* :< */
HCL_CNODE_COLONSTAR, /* :* */
@ -283,6 +284,7 @@ typedef enum hcl_cnode_flagt hcl_cnode_flag_t;
#define HCL_CNODE_IS_ELLIPSIS(x) ((x)->cn_type == HCL_CNODE_ELLIPSIS)
#define HCL_CNODE_IS_TRPCOLONS(x) ((x)->cn_type == HCL_CNODE_TRPCOLONS)
#define HCL_CNODE_IS_DBLCOLONS(x) ((x)->cn_type == HCL_CNODE_DBLCOLONS)
#define HCL_CNODE_IS_COLONGT(x) ((x)->cn_type == HCL_CNODE_COLONGT)
#define HCL_CNODE_IS_COLONLT(x) ((x)->cn_type == HCL_CNODE_COLONLT)
#define HCL_CNODE_IS_COLONSTAR(x) ((x)->cn_type == HCL_CNODE_COLONSTAR)
@ -1783,6 +1785,7 @@ hcl_cnode_t* hcl_makecnodeself (hcl_t* hcl, int flags, const hcl_loc_t* loc, con
hcl_cnode_t* hcl_makecnodesuper (hcl_t* hcl, int flags, const hcl_loc_t* loc, const hcl_oocs_t* tok);
hcl_cnode_t* hcl_makecnodeellipsis (hcl_t* hcl, int flags, const hcl_loc_t* loc, const hcl_oocs_t* tok);
hcl_cnode_t* hcl_makecnodetrpcolons (hcl_t* hcl, int flags, const hcl_loc_t* loc, const hcl_oocs_t* tok);
hcl_cnode_t* hcl_makecnodedblcolons (hcl_t* hcl, int flags, const hcl_loc_t* loc, const hcl_oocs_t* tok);
hcl_cnode_t* hcl_makecnodecolongt (hcl_t* hcl, int flags, const hcl_loc_t* loc, const hcl_oocs_t* tok);
hcl_cnode_t* hcl_makecnodecolonlt (hcl_t* hcl, int flags, const hcl_loc_t* loc, const hcl_oocs_t* tok);
hcl_cnode_t* hcl_makecnodecolonstar (hcl_t* hcl, int flags, const hcl_loc_t* loc, const hcl_oocs_t* tok);

View File

@ -817,6 +817,7 @@ void hcl_dumpcnode (hcl_t* hcl, hcl_cnode_t* cnode, int newline)
case HCL_CNODE_SUPER:
case HCL_CNODE_ELLIPSIS:
case HCL_CNODE_TRPCOLONS:
case HCL_CNODE_DBLCOLONS:
case HCL_CNODE_COLONGT:
case HCL_CNODE_COLONLT:
case HCL_CNODE_COLONSTAR:

View File

@ -210,7 +210,7 @@ static HCL_INLINE int is_delimchar (hcl_ooci_t c)
return c == '(' || c == ')' || c == '[' || c == ']' || c == '{' || c == '}' ||
c == '|' || c == ',' || c == '.' || c == ':' || c == ';' ||
/* the first characters of tokens in delim_token_tab up to this point */
c == '#' || c == '\"' || c == '\'' || c == '\\' || is_spacechar(c) || c == HCL_UCI_EOF;
c == '#' || c == '\"' || c == '\'' || c == '\\' || is_spacechar(c) || c == HCL_OOCI_EOF;
}
/* TODO: remove this use the one in comp.c */
@ -1432,6 +1432,10 @@ static int feed_process_token (hcl_t* hcl)
frd->obj = hcl_makecnodetrpcolons(hcl, 0, TOKEN_LOC(hcl), TOKEN_NAME(hcl));
goto auto_xlist;
case HCL_TOK_DBLCOLONS:
frd->obj = hcl_makecnodedblcolons(hcl, 0, TOKEN_LOC(hcl), TOKEN_NAME(hcl));
goto auto_xlist;
case HCL_TOK_COLONGT:
frd->obj = hcl_makecnodecolongt(hcl, 0, TOKEN_LOC(hcl), TOKEN_NAME(hcl));
goto auto_xlist;