From cf0162e1400ac30658b3a90cb32cb888bd810c64 Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Sun, 7 Jan 2024 10:38:37 +0900 Subject: [PATCH] := experiment --- lib/read.c | 53 ++++++++++++++++++++++++++++++++++++++++++-------- t/Makefile.am | 1 + t/Makefile.in | 1 + t/mlist-01.err | 1 + 4 files changed, 48 insertions(+), 8 deletions(-) create mode 100644 t/mlist-01.err diff --git a/lib/read.c b/lib/read.c index ad917a3..d205818 100644 --- a/lib/read.c +++ b/lib/read.c @@ -535,9 +535,9 @@ static HCL_INLINE hcl_cnode_t* leave_list (hcl_t* hcl, hcl_loc_t* list_loc, int* } else { - hcl_synerrnum_t sen; - sen = (fv & COMMAED)? HCL_SYNERR_COMMANOVALUE: HCL_SYNERR_COLONNOVALUE; - hcl_setsynerr (hcl, sen, TOKEN_LOC(hcl), HCL_NULL); + hcl_synerrnum_t err; + err = (fv & COMMAED)? HCL_SYNERR_COMMANOVALUE: HCL_SYNERR_COLONNOVALUE; + hcl_setsynerr (hcl, err, TOKEN_LOC(hcl), HCL_NULL); } if (head) hcl_freecnode (hcl, head); return HCL_NULL; @@ -558,15 +558,50 @@ static HCL_INLINE hcl_cnode_t* leave_list (hcl_t* hcl, hcl_loc_t* list_loc, int* *flagv = hcl->c->r.st->flagv; } - /* NOTE: empty xlist will get translated to `null`. - * this is useful when used in the lambda expression to express an empty argument. also in defun. - * (lambda () ...) is equivalent to (lambda null ...) - * (defun x() ...) */ - if (head) { HCL_ASSERT (hcl, HCL_CNODE_IS_CONS(head)); + + int x = 0; + /* HACK */ + if (concode == HCL_CONCODE_ALIST) + { + hcl_cnode_t* sym, * newhead; + hcl_oocs_t fake_tok, * fake_tok_ptr = HCL_NULL; + + + /* TODO: this part is experimenttal... */ + + static hcl_ooch_t set[4] = { 's', 'e', 't', '\0' }; + fake_tok.ptr = set; + fake_tok.len = 3; + fake_tok_ptr = &fake_tok; + + /* THIS LOCATION IS ALSO WRONG */ + sym = hcl_makecnodesymbol(hcl, 0, TOKEN_LOC(hcl), fake_tok_ptr); + if (HCL_UNLIKELY(!sym)) + { + /* TDOO: better error message */ + if (head) hcl_freecnode (hcl, head); + return HCL_NULL; + } + + + newhead = hcl_makecnodecons(hcl, 0, &loc, fake_tok_ptr, sym, head); + if (HCL_UNLIKELY(!newhead)) + { + hcl_freecnode (hcl, sym); + if (head) hcl_freecnode (hcl, head); + return HCL_NULL; + } + head = newhead; + concode = HCL_CONCODE_XLIST; + x = 1; + } + /* END HACK */ + 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; return head; } @@ -674,6 +709,8 @@ static HCL_INLINE int can_coloneq_list (hcl_t* hcl) /* TODO: some transformation is required... */ + LIST_FLAG_SET_CONCODE(rstl->flagv, HCL_CONCODE_ALIST); + rstl->flagv |= COLONEQED; return 1; } diff --git a/t/Makefile.am b/t/Makefile.am index 7b0eb54..d9880a5 100644 --- a/t/Makefile.am +++ b/t/Makefile.am @@ -13,6 +13,7 @@ check_ERRORS = \ do-01.err \ do-02.err \ feed-01.err \ + mlist-01.err \ var-01.err \ var-02.err \ var-03.err \ diff --git a/t/Makefile.in b/t/Makefile.in index 7b30d61..5f6751b 100644 --- a/t/Makefile.in +++ b/t/Makefile.in @@ -484,6 +484,7 @@ check_ERRORS = \ do-01.err \ do-02.err \ feed-01.err \ + mlist-01.err \ var-01.err \ var-02.err \ var-03.err \ diff --git a/t/mlist-01.err b/t/mlist-01.err new file mode 100644 index 0000000..126cbcb --- /dev/null +++ b/t/mlist-01.err @@ -0,0 +1 @@ +(1:) ##ERROR: syntax error - missing message after :