fixed wrong semicolon handling and enhanced eol/semiclon handling
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
f88c3a9c1f
commit
e3120e20a2
29
lib/read.c
29
lib/read.c
@ -1283,25 +1283,32 @@ static int feed_process_token (hcl_t* hcl)
|
||||
hcl_rstl_t* rstl;
|
||||
|
||||
semicolon:
|
||||
/* the parent list must be inspected instead of the current feed/read status pointed to by frd. */
|
||||
/* the parent list(rstl) must be inspected instead of the current
|
||||
* feed/read status pointed to by frd. */
|
||||
rstl = hcl->c->r.st;
|
||||
if (!rstl || !(rstl->flagv & AUTO_FORGED))
|
||||
{
|
||||
#if 0
|
||||
hcl_setsynerrbfmt (hcl, HCL_SYNERR_SEMICOLON, TOKEN_LOC(hcl), TOKEN_NAME(hcl), "unexpected semicolon");
|
||||
goto oops;
|
||||
#else
|
||||
/* allow redundant semicolons without not balanced with preceding expression */
|
||||
goto ok;
|
||||
#endif
|
||||
}
|
||||
if (!rstl) goto ok; /* redundant eol/semicolon */
|
||||
|
||||
concode = LIST_FLAG_GET_CONCODE(rstl->flagv);
|
||||
if (!(rstl->flagv & AUTO_FORGED))
|
||||
{
|
||||
if (TOKEN_TYPE(hcl) == HCL_TOK_EOL) goto ok;
|
||||
if (concode == HCL_CONCODE_BLOCK) goto ok;
|
||||
|
||||
hcl_setsynerr (hcl, HCL_SYNERR_SEMICOLON, TOKEN_LOC(hcl), HCL_NULL);
|
||||
goto oops;
|
||||
}
|
||||
|
||||
/* if auto-forged */
|
||||
#if 0
|
||||
/* 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)
|
||||
{
|
||||
hcl_setsynerr (hcl, HCL_SYNERR_UNBALPBB, TOKEN_LOC(hcl), HCL_NULL);
|
||||
goto oops;
|
||||
}
|
||||
#else
|
||||
HCL_ASSERT (hcl, concode == HCL_CONCODE_XLIST || concode == HCL_CONCODE_MLIST || concode == HCL_CONCODE_ALIST);
|
||||
#endif
|
||||
|
||||
frd->obj = leave_list(hcl, &frd->list_loc, &frd->flagv, &oldflagv);
|
||||
frd->level--;
|
||||
|
@ -16,6 +16,8 @@ check_ERRORS = \
|
||||
do-02.err \
|
||||
feed-01.err \
|
||||
feed-02.err \
|
||||
feed-03.err \
|
||||
feed-04.err \
|
||||
mlist-01.err \
|
||||
var-01.err \
|
||||
var-02.err \
|
||||
|
@ -487,6 +487,8 @@ check_ERRORS = \
|
||||
do-02.err \
|
||||
feed-01.err \
|
||||
feed-02.err \
|
||||
feed-03.err \
|
||||
feed-04.err \
|
||||
mlist-01.err \
|
||||
var-01.err \
|
||||
var-02.err \
|
||||
|
@ -3,6 +3,6 @@
|
||||
"hello, world\n"
|
||||
)
|
||||
|
||||
(printf; ##ERROR: synax error - unexpected semicolon
|
||||
(printf; ##ERROR: syntax error - unexpected semicolon
|
||||
"hello, world\n"
|
||||
)
|
||||
|
9
t/feed-03.err
Normal file
9
t/feed-03.err
Normal file
@ -0,0 +1,9 @@
|
||||
## semicolon inside #{} must raise a syntax error
|
||||
|
||||
a := #{
|
||||
"k1":
|
||||
"hello k1\n",
|
||||
"k2":
|
||||
"hello k2\n"; ##ERROR: syntax error - unexpected semicolon
|
||||
};
|
||||
|
11
t/feed-04.err
Normal file
11
t/feed-04.err
Normal file
@ -0,0 +1,11 @@
|
||||
{
|
||||
;;;
|
||||
|
||||
(do
|
||||
(printf "hello\n")
|
||||
(printf "hello\n")
|
||||
);;
|
||||
|
||||
k := [10 ; 20 ]; ##ERROR: syntax error - unexpected semicolon
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user