enhanced the error handling in lib/read.c
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
cf0162e140
commit
f70a087525
@ -1733,22 +1733,22 @@ int hcl_emitbyteinstruction (
|
|||||||
/* cnode.c */
|
/* cnode.c */
|
||||||
/* ========================================================================= */
|
/* ========================================================================= */
|
||||||
hcl_cnode_t* hcl_makecnodenil (hcl_t* hcl, int flags, const hcl_loc_t* loc, const hcl_oocs_t* tok);
|
hcl_cnode_t* hcl_makecnodenil (hcl_t* hcl, int flags, const hcl_loc_t* loc, const hcl_oocs_t* tok);
|
||||||
hcl_cnode_t* hcl_makecnodetrue (hcl_t* hcl, int flags, const hcl_loc_t* loc, const hcl_oocs_t* tok);
|
hcl_cnode_t* hcl_makecnodetrue (hcl_t* hcl, int flags, const hcl_loc_t* loc, const hcl_oocs_t* tok);
|
||||||
hcl_cnode_t* hcl_makecnodefalse (hcl_t* hcl, int flags, const hcl_loc_t* loc, const hcl_oocs_t* tok);
|
hcl_cnode_t* hcl_makecnodefalse (hcl_t* hcl, int flags, const hcl_loc_t* loc, const hcl_oocs_t* tok);
|
||||||
hcl_cnode_t* hcl_makecnodeself (hcl_t* hcl, int flags, const hcl_loc_t* loc, const hcl_oocs_t* tok);
|
hcl_cnode_t* hcl_makecnodeself (hcl_t* hcl, int flags, const hcl_loc_t* loc, const hcl_oocs_t* tok);
|
||||||
hcl_cnode_t* hcl_makecnodesuper (hcl_t* hcl, int flags, const hcl_loc_t* loc, const hcl_oocs_t* tok);
|
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_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_makecnodetrpcolons (hcl_t* hcl, int flags, const hcl_loc_t* loc, const hcl_oocs_t* tok);
|
||||||
hcl_cnode_t* hcl_makecnodedcstar (hcl_t* hcl, int flags, const hcl_loc_t* loc, const hcl_oocs_t* tok);
|
hcl_cnode_t* hcl_makecnodedcstar (hcl_t* hcl, int flags, const hcl_loc_t* loc, const hcl_oocs_t* tok);
|
||||||
hcl_cnode_t* hcl_makecnodecharlit (hcl_t* hcl, int flags, const hcl_loc_t* loc, const hcl_oocs_t* tok, const hcl_ooch_t v);
|
hcl_cnode_t* hcl_makecnodecharlit (hcl_t* hcl, int flags, const hcl_loc_t* loc, const hcl_oocs_t* tok, const hcl_ooch_t v);
|
||||||
hcl_cnode_t* hcl_makecnodesymbol (hcl_t* hcl, int flags, const hcl_loc_t* loc, const hcl_oocs_t* tok);
|
hcl_cnode_t* hcl_makecnodesymbol (hcl_t* hcl, int flags, const hcl_loc_t* loc, const hcl_oocs_t* tok);
|
||||||
hcl_cnode_t* hcl_makecnodedsymbol (hcl_t* hcl, int flags, const hcl_loc_t* loc, const hcl_oocs_t* tok, int is_cla);
|
hcl_cnode_t* hcl_makecnodedsymbol (hcl_t* hcl, int flags, const hcl_loc_t* loc, const hcl_oocs_t* tok, int is_cla);
|
||||||
hcl_cnode_t* hcl_makecnodestrlit (hcl_t* hcl, int flags, const hcl_loc_t* loc, const hcl_oocs_t* tok);
|
hcl_cnode_t* hcl_makecnodestrlit (hcl_t* hcl, int flags, const hcl_loc_t* loc, const hcl_oocs_t* tok);
|
||||||
hcl_cnode_t* hcl_makecnodenumlit (hcl_t* hcl, int flags, const hcl_loc_t* loc, const hcl_oocs_t* tok);
|
hcl_cnode_t* hcl_makecnodenumlit (hcl_t* hcl, int flags, const hcl_loc_t* loc, const hcl_oocs_t* tok);
|
||||||
hcl_cnode_t* hcl_makecnoderadnumlit (hcl_t* hcl, int flags, const hcl_loc_t* loc, const hcl_oocs_t* tok);
|
hcl_cnode_t* hcl_makecnoderadnumlit (hcl_t* hcl, int flags, const hcl_loc_t* loc, const hcl_oocs_t* tok);
|
||||||
hcl_cnode_t* hcl_makecnodefpdeclit (hcl_t* hcl, int flags, const hcl_loc_t* loc, const hcl_oocs_t* tok);
|
hcl_cnode_t* hcl_makecnodefpdeclit (hcl_t* hcl, int flags, const hcl_loc_t* loc, const hcl_oocs_t* tok);
|
||||||
hcl_cnode_t* hcl_makecnodesmptrlit (hcl_t* hcl, int flags, const hcl_loc_t* loc, const hcl_oocs_t* tok, hcl_oow_t v);
|
hcl_cnode_t* hcl_makecnodesmptrlit (hcl_t* hcl, int flags, const hcl_loc_t* loc, const hcl_oocs_t* tok, hcl_oow_t v);
|
||||||
hcl_cnode_t* hcl_makecnodeerrlit (hcl_t* hcl, int flags, const hcl_loc_t* loc, const hcl_oocs_t* tok, hcl_ooi_t v);
|
hcl_cnode_t* hcl_makecnodeerrlit (hcl_t* hcl, int flags, const hcl_loc_t* loc, const hcl_oocs_t* tok, hcl_ooi_t v);
|
||||||
hcl_cnode_t* hcl_makecnodecons (hcl_t* hcl, int flags, const hcl_loc_t* loc, const hcl_oocs_t* tok, hcl_cnode_t* car, hcl_cnode_t* cdr);
|
hcl_cnode_t* hcl_makecnodecons (hcl_t* hcl, int flags, const hcl_loc_t* loc, const hcl_oocs_t* tok, hcl_cnode_t* car, hcl_cnode_t* cdr);
|
||||||
hcl_cnode_t* hcl_makecnodeelist (hcl_t* hcl, int flags, const hcl_loc_t* loc, hcl_concode_t type);
|
hcl_cnode_t* hcl_makecnodeelist (hcl_t* hcl, int flags, const hcl_loc_t* loc, hcl_concode_t type);
|
||||||
hcl_cnode_t* hcl_makecnodeshell (hcl_t* hcl, int flags, const hcl_loc_t* loc, hcl_cnode_t* obj);
|
hcl_cnode_t* hcl_makecnodeshell (hcl_t* hcl, int flags, const hcl_loc_t* loc, hcl_cnode_t* obj);
|
||||||
|
43
lib/read.c
43
lib/read.c
@ -55,6 +55,8 @@ static struct voca_t
|
|||||||
{ 4, { 's','e','l','f' } },
|
{ 4, { 's','e','l','f' } },
|
||||||
{ 5, { 's','u','p','e','r' } },
|
{ 5, { 's','u','p','e','r' } },
|
||||||
|
|
||||||
|
{ 3, { 's','e','t' } },
|
||||||
|
|
||||||
{ 3, { '(',' ',')' /* XLIST */ } },
|
{ 3, { '(',' ',')' /* XLIST */ } },
|
||||||
{ 4, { '(',':',' ',')' /* MLIST */ } },
|
{ 4, { '(',':',' ',')' /* MLIST */ } },
|
||||||
{ 3, { '(',':','=',')' } },
|
{ 3, { '(',':','=',')' } },
|
||||||
@ -91,6 +93,8 @@ enum voca_id_t
|
|||||||
VOCA_KW_SELF,
|
VOCA_KW_SELF,
|
||||||
VOCA_KW_SUPER,
|
VOCA_KW_SUPER,
|
||||||
|
|
||||||
|
VOCA_SYM_SET,
|
||||||
|
|
||||||
VOCA_XLIST,
|
VOCA_XLIST,
|
||||||
VOCA_MLIST,
|
VOCA_MLIST,
|
||||||
VOCA_ALIST,
|
VOCA_ALIST,
|
||||||
@ -562,52 +566,57 @@ static HCL_INLINE hcl_cnode_t* leave_list (hcl_t* hcl, hcl_loc_t* list_loc, int*
|
|||||||
{
|
{
|
||||||
HCL_ASSERT (hcl, HCL_CNODE_IS_CONS(head));
|
HCL_ASSERT (hcl, HCL_CNODE_IS_CONS(head));
|
||||||
|
|
||||||
int x = 0;
|
|
||||||
/* HACK */
|
/* HACK */
|
||||||
if (concode == HCL_CONCODE_ALIST)
|
if (concode == HCL_CONCODE_ALIST)
|
||||||
{
|
{
|
||||||
|
/* tranform (var := val) to (set var val) */
|
||||||
hcl_cnode_t* sym, * newhead;
|
hcl_cnode_t* sym, * newhead;
|
||||||
hcl_oocs_t fake_tok, * fake_tok_ptr = HCL_NULL;
|
hcl_oocs_t fake_tok, * fake_tok_ptr = HCL_NULL;
|
||||||
|
|
||||||
|
fake_tok.ptr = vocas[VOCA_SYM_SET].str;
|
||||||
/* TODO: this part is experimenttal... */
|
fake_tok.len = vocas[VOCA_SYM_SET].len;
|
||||||
|
|
||||||
static hcl_ooch_t set[4] = { 's', 'e', 't', '\0' };
|
|
||||||
fake_tok.ptr = set;
|
|
||||||
fake_tok.len = 3;
|
|
||||||
fake_tok_ptr = &fake_tok;
|
fake_tok_ptr = &fake_tok;
|
||||||
|
|
||||||
/* THIS LOCATION IS ALSO WRONG */
|
/* TODO: check the number of argumetns in advance??? */
|
||||||
sym = hcl_makecnodesymbol(hcl, 0, TOKEN_LOC(hcl), fake_tok_ptr);
|
sym = hcl_makecnodesymbol(hcl, 0, &loc, fake_tok_ptr);
|
||||||
if (HCL_UNLIKELY(!sym))
|
if (HCL_UNLIKELY(!sym))
|
||||||
{
|
{
|
||||||
/* TDOO: better error message */
|
const hcl_ooch_t* orgmsg = hcl_backuperrmsg(hcl);
|
||||||
|
hcl_seterrbfmt (hcl, hcl_geterrnum(hcl), "failed to create symbol cnode for := - %js", orgmsg);
|
||||||
if (head) hcl_freecnode (hcl, head);
|
if (head) hcl_freecnode (hcl, head);
|
||||||
return HCL_NULL;
|
return HCL_NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
newhead = hcl_makecnodecons(hcl, 0, &loc, fake_tok_ptr, sym, head);
|
newhead = hcl_makecnodecons(hcl, 0, &loc, fake_tok_ptr, sym, head);
|
||||||
if (HCL_UNLIKELY(!newhead))
|
if (HCL_UNLIKELY(!newhead))
|
||||||
{
|
{
|
||||||
|
const hcl_ooch_t* orgmsg = hcl_backuperrmsg(hcl);
|
||||||
|
hcl_seterrbfmt (hcl, hcl_geterrnum(hcl), "failed to create cons cnode for := - %js", orgmsg);
|
||||||
hcl_freecnode (hcl, sym);
|
hcl_freecnode (hcl, sym);
|
||||||
if (head) hcl_freecnode (hcl, head);
|
if (head) hcl_freecnode (hcl, head);
|
||||||
return HCL_NULL;
|
return HCL_NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
head = newhead;
|
head = newhead;
|
||||||
concode = HCL_CONCODE_XLIST;
|
concode = HCL_CONCODE_XLIST; /* switch back to XLIST */
|
||||||
x = 1;
|
|
||||||
}
|
}
|
||||||
/* END HACK */
|
/* END HACK */
|
||||||
|
|
||||||
HCL_CNODE_CONS_CONCODE(head) = concode;
|
HCL_CNODE_CONS_CONCODE(head) = concode;
|
||||||
if (x) hcl_dumpcnode(hcl, head, 1);
|
|
||||||
if (fv & AUTO_FORGED) HCL_CNODE_GET_FLAGS(head) |= HCL_CNODE_AUTO_FORGED;
|
if (fv & AUTO_FORGED) HCL_CNODE_GET_FLAGS(head) |= HCL_CNODE_AUTO_FORGED;
|
||||||
return head;
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* the list is empty */
|
||||||
|
head = hcl_makecnodeelist(hcl, ((fv & AUTO_FORGED)? HCL_CNODE_AUTO_FORGED: 0), &loc, concode);
|
||||||
|
if (HCL_UNLIKELY(!head))
|
||||||
|
{
|
||||||
|
const hcl_ooch_t* orgmsg = hcl_backuperrmsg(hcl);
|
||||||
|
hcl_seterrbfmt (hcl, hcl_geterrnum(hcl), "failed to create empty list - %js", orgmsg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* the list is empty */
|
return head;
|
||||||
return hcl_makecnodeelist(hcl, ((fv & AUTO_FORGED)? HCL_CNODE_AUTO_FORGED: 0), &loc, concode);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static HCL_INLINE int can_dot_list (hcl_t* hcl)
|
static HCL_INLINE int can_dot_list (hcl_t* hcl)
|
||||||
|
Loading…
Reference in New Issue
Block a user