let the reader check rvalue counts before converting to set or set-r
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
dd97f3b7f6
commit
0455d6cdb3
@ -165,7 +165,8 @@ static char* synerrstr[] =
|
|||||||
"stray backslash",
|
"stray backslash",
|
||||||
"block expression expected",
|
"block expression expected",
|
||||||
"block expression disallowed",
|
"block expression disallowed",
|
||||||
"invalid lvalue"
|
"invalid lvalue",
|
||||||
|
"invalid rvalue"
|
||||||
};
|
};
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------
|
||||||
|
@ -169,7 +169,8 @@ enum hcl_synerrnum_t
|
|||||||
HCL_SYNERR_BACKSLASH, /* stray backslash */
|
HCL_SYNERR_BACKSLASH, /* stray backslash */
|
||||||
HCL_SYNERR_BLOCK, /* block expression expected */
|
HCL_SYNERR_BLOCK, /* block expression expected */
|
||||||
HCL_SYNERR_BLOCKBANNED, /* block expression disallowed */
|
HCL_SYNERR_BLOCKBANNED, /* block expression disallowed */
|
||||||
HCL_SYNERR_LVALUE /* invalid lvalue */
|
HCL_SYNERR_LVALUE, /* invalid lvalue */
|
||||||
|
HCL_SYNERR_RVALUE /* invalid rvalue */
|
||||||
};
|
};
|
||||||
typedef enum hcl_synerrnum_t hcl_synerrnum_t;
|
typedef enum hcl_synerrnum_t hcl_synerrnum_t;
|
||||||
|
|
||||||
|
25
lib/read.c
25
lib/read.c
@ -61,7 +61,7 @@ static struct voca_t
|
|||||||
{ 3, { '(',' ',')' /* XLIST */ } },
|
{ 3, { '(',' ',')' /* XLIST */ } },
|
||||||
{ 4, { '(',':',' ',')' /* MLIST */ } },
|
{ 4, { '(',':',' ',')' /* MLIST */ } },
|
||||||
{ 4, { '(',':','=',')' /* ALIST */ } },
|
{ 4, { '(',':','=',')' /* ALIST */ } },
|
||||||
{ 4, { '(','B','O',')' /* ALIST */ } },
|
{ 4, { '(','B','O',')' /* BLIST */ } },
|
||||||
{ 3, { '{',' ','}' /* BLOCK */ } },
|
{ 3, { '{',' ','}' /* BLOCK */ } },
|
||||||
{ 4, { '#','[',' ',']' /* ARRAY */ } },
|
{ 4, { '#','[',' ',']' /* ARRAY */ } },
|
||||||
{ 5, { '#','b','[',' ',']' /* BYTE ARRAY */ } },
|
{ 5, { '#','b','[',' ',']' /* BYTE ARRAY */ } },
|
||||||
@ -530,6 +530,7 @@ static HCL_INLINE hcl_cnode_t* leave_list (hcl_t* hcl, hcl_loc_t* list_loc, int*
|
|||||||
{
|
{
|
||||||
hcl_rstl_t* rstl;
|
hcl_rstl_t* rstl;
|
||||||
hcl_cnode_t* head;
|
hcl_cnode_t* head;
|
||||||
|
hcl_oow_t count;
|
||||||
hcl_loc_t loc;
|
hcl_loc_t loc;
|
||||||
int fv, concode;
|
int fv, concode;
|
||||||
|
|
||||||
@ -538,6 +539,7 @@ static HCL_INLINE hcl_cnode_t* leave_list (hcl_t* hcl, hcl_loc_t* list_loc, int*
|
|||||||
rstl = hcl->c->r.st; /* get the stack top */
|
rstl = hcl->c->r.st; /* get the stack top */
|
||||||
|
|
||||||
head = rstl->head;
|
head = rstl->head;
|
||||||
|
count = rstl->count;
|
||||||
fv = rstl->flagv;
|
fv = rstl->flagv;
|
||||||
loc = rstl->loc;
|
loc = rstl->loc;
|
||||||
concode = LIST_FLAG_GET_CONCODE(fv);
|
concode = LIST_FLAG_GET_CONCODE(fv);
|
||||||
@ -554,7 +556,7 @@ static HCL_INLINE hcl_cnode_t* leave_list (hcl_t* hcl, hcl_loc_t* list_loc, int*
|
|||||||
}
|
}
|
||||||
else if (concode == HCL_CONCODE_ALIST)
|
else if (concode == HCL_CONCODE_ALIST)
|
||||||
{
|
{
|
||||||
hcl_setsynerrbfmt (hcl, HCL_SYNERR_NOVALUE, TOKEN_LOC(hcl), HCL_NULL, "missing value after :=");
|
hcl_setsynerrbfmt (hcl, HCL_SYNERR_RVALUE, TOKEN_LOC(hcl), HCL_NULL, "missing rvalue after :=");
|
||||||
}
|
}
|
||||||
else if (concode == HCL_CONCODE_BLIST)
|
else if (concode == HCL_CONCODE_BLIST)
|
||||||
{
|
{
|
||||||
@ -635,7 +637,20 @@ static HCL_INLINE hcl_cnode_t* leave_list (hcl_t* hcl, hcl_loc_t* list_loc, int*
|
|||||||
fake_tok_ptr = &fake_tok;
|
fake_tok_ptr = &fake_tok;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO: check the number of arguments in advance??? */
|
|
||||||
|
HCL_ASSERT (hcl, count >= 2); /* the missing rvalue check has been done above */
|
||||||
|
if (count != 2)
|
||||||
|
{
|
||||||
|
hcl_cnode_t* rval;
|
||||||
|
rval = HCL_CNODE_CONS_CDR(head);
|
||||||
|
rval = HCL_CNODE_CONS_CDR(rval);
|
||||||
|
rval = HCL_CNODE_CONS_CAR(rval);
|
||||||
|
|
||||||
|
hcl_setsynerrbfmt (hcl, HCL_SYNERR_RVALUE, HCL_CNODE_GET_LOC(rval), HCL_CNODE_GET_TOK(rval), "too many rvalues after :=");
|
||||||
|
if (head) hcl_freecnode (hcl, head);
|
||||||
|
return HCL_NULL;
|
||||||
|
}
|
||||||
|
|
||||||
sym = hcl_makecnodesymbol(hcl, 0, &loc, fake_tok_ptr);
|
sym = hcl_makecnodesymbol(hcl, 0, &loc, fake_tok_ptr);
|
||||||
if (HCL_UNLIKELY(!sym))
|
if (HCL_UNLIKELY(!sym))
|
||||||
{
|
{
|
||||||
@ -1374,13 +1389,13 @@ static int feed_process_token (hcl_t* hcl)
|
|||||||
/* if auto-forged */
|
/* if auto-forged */
|
||||||
#if 0
|
#if 0
|
||||||
/* TODO: remove this part if the assertion is confirmed true in the #else part... */
|
/* TODO: remove this part if the assertion is confirmed true in the #else part... */
|
||||||
if (concode != HCL_CONCODE_XLIST && concode != HCL_CONCODE_MLIST && concode != HCL_CONCODE_ALIST)
|
if (concode != HCL_CONCODE_XLIST && concode != HCL_CONCODE_MLIST && concode != HCL_CONCODE_ALIST && concode != HCL_CONCODE_BLIST)
|
||||||
{
|
{
|
||||||
hcl_setsynerr (hcl, HCL_SYNERR_UNBALPBB, TOKEN_LOC(hcl), HCL_NULL);
|
hcl_setsynerr (hcl, HCL_SYNERR_UNBALPBB, TOKEN_LOC(hcl), HCL_NULL);
|
||||||
goto oops;
|
goto oops;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
HCL_ASSERT (hcl, concode == HCL_CONCODE_XLIST || concode == HCL_CONCODE_MLIST || concode == HCL_CONCODE_ALIST);
|
HCL_ASSERT (hcl, concode == HCL_CONCODE_XLIST || concode == HCL_CONCODE_MLIST || concode == HCL_CONCODE_ALIST || concode == HCL_CONCODE_BLIST);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
frd->obj = leave_list(hcl, &frd->list_loc, &frd->flagv, &oldflagv);
|
frd->obj = leave_list(hcl, &frd->list_loc, &frd->flagv, &oldflagv);
|
||||||
|
Loading…
Reference in New Issue
Block a user