This commit is contained in:
parent
57629478a1
commit
bb4786b6ca
@ -17,6 +17,7 @@ A HCL program is composed of expressions.
|
||||
- do
|
||||
- elif
|
||||
- else
|
||||
- fun
|
||||
- if
|
||||
- lambda
|
||||
- or
|
||||
@ -30,7 +31,7 @@ A HCL program is composed of expressions.
|
||||
```
|
||||
do;
|
||||
do 10;
|
||||
do { | k | set k 20; printf "k=%d\n" k };
|
||||
do { | k | set k 20; printf "k=%d\n" k; };
|
||||
```
|
||||
|
||||
## Literals
|
||||
|
@ -1822,7 +1822,9 @@ static int compile_break (hcl_t* hcl, hcl_cnode_t* src)
|
||||
}
|
||||
}
|
||||
|
||||
hcl_setsynerrbfmt (hcl, HCL_SYNERR_BREAK, HCL_CNODE_GET_LOC(src), HCL_NULL, "%.*js outside loop", HCL_CNODE_GET_TOKLEN(cmd), HCL_CNODE_GET_TOKPTR(cmd));
|
||||
hcl_setsynerrbfmt (
|
||||
hcl, HCL_SYNERR_BREAK, HCL_CNODE_GET_LOC(src), HCL_NULL,
|
||||
"%.*js outside loop", HCL_CNODE_GET_TOKLEN(cmd), HCL_CNODE_GET_TOKPTR(cmd));
|
||||
return -1;
|
||||
|
||||
inside_loop:
|
||||
@ -1860,7 +1862,9 @@ inside_loop:
|
||||
|
||||
/* this part must no be reached. if a loop control block is found,
|
||||
* there must exist a COP_POST_UNTIL_BODY or COP_POST_WHILE_BODY frame */
|
||||
hcl_setsynerrbfmt (hcl, HCL_SYNERR_INTERN, HCL_CNODE_GET_LOC(src), HCL_NULL, "internal error in compiling %.*js", HCL_CNODE_GET_TOKLEN(cmd), HCL_CNODE_GET_TOKPTR(cmd));
|
||||
hcl_setsynerrbfmt (
|
||||
hcl, HCL_SYNERR_INTERN, HCL_CNODE_GET_LOC(src), HCL_NULL,
|
||||
"internal error in compiling %.*js", HCL_CNODE_GET_TOKLEN(cmd), HCL_CNODE_GET_TOKPTR(cmd));
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
14
lib/read.c
14
lib/read.c
@ -1251,7 +1251,7 @@ static int feed_process_token (hcl_t* hcl)
|
||||
}
|
||||
|
||||
concode = LIST_FLAG_GET_CONCODE(rstl->flagv);
|
||||
if (concode != HCL_CONCODE_XLIST) /* TODO: handle MLIST as weel if the other part is implemented */
|
||||
if (concode != HCL_CONCODE_XLIST) /* TODO: handle MLIST as well if the other part is implemented */
|
||||
{
|
||||
hcl_setsynerr (hcl, HCL_SYNERR_UNBALPBB, TOKEN_LOC(hcl), HCL_NULL);
|
||||
goto oops;
|
||||
@ -1270,6 +1270,7 @@ static int feed_process_token (hcl_t* hcl)
|
||||
{
|
||||
int oldflagv;
|
||||
int concode;
|
||||
hcl_rstl_t* rstl;
|
||||
|
||||
if (frd->level <= 0)
|
||||
{
|
||||
@ -1277,6 +1278,17 @@ static int feed_process_token (hcl_t* hcl)
|
||||
goto oops;
|
||||
}
|
||||
|
||||
if (TOKEN_TYPE(hcl) == HCL_TOK_RBRACE)
|
||||
{
|
||||
rstl = hcl->c->r.st; /* check the parent, not the current */
|
||||
if (rstl && (rstl->flagv & AUTO_FORGED))
|
||||
{
|
||||
/* the auto-forged list has not been terminated. it must be terminated closed first */
|
||||
hcl_setsynerrbfmt (hcl, HCL_SYNERR_SEMICOLON, TOKEN_LOC(hcl), TOKEN_NAME(hcl), "semicolon expected");
|
||||
goto oops;
|
||||
}
|
||||
}
|
||||
|
||||
concode = LIST_FLAG_GET_CONCODE(frd->flagv);
|
||||
if (concode == HCL_CONCODE_XLIST && (frd->flagv & AUTO_FORGED))
|
||||
{
|
||||
|
8
t/do-02.err
Normal file
8
t/do-02.err
Normal file
@ -0,0 +1,8 @@
|
||||
## if `do` is not enclosed in `( )`, it supports only the limited number of expressions.
|
||||
|
||||
do ; ## this is ok
|
||||
|
||||
do 1; ## this is ok
|
||||
|
||||
do { set k 10; printf "k=%d\n" k; } ##ERROR: syntax error - more than one expression after do
|
||||
{ set k 20; printf "k=%d\n" k; };
|
6
t/feed-01.err
Normal file
6
t/feed-01.err
Normal file
@ -0,0 +1,6 @@
|
||||
## the left brace opens a list explicitly and doesn't auto-forge a container list.
|
||||
## so the semicolon after it is a redundant one. `do {};` would work because the semicolon
|
||||
## terminates the auto-forged list of `do` and `{}`.
|
||||
{
|
||||
printf "hello, world\n";
|
||||
}; ##ERROR: syntax error - unexpected semicolon
|
3
t/var-03.err
Normal file
3
t/var-03.err
Normal file
@ -0,0 +1,3 @@
|
||||
defclass A | a | {
|
||||
| j | ##ERROR: syntax error - variable declaration disallowed in class init scope
|
||||
};
|
Loading…
Reference in New Issue
Block a user