updated testers with updated syntax
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
hyung-hwan 2024-01-15 00:47:01 +09:00
parent 48a54d61c1
commit 656af796ed
6 changed files with 59 additions and 61 deletions

View File

@ -1042,7 +1042,7 @@ static HCL_INLINE int is_at_block_beginning (hcl_t* hcl)
return !rstl || (LIST_FLAG_GET_CONCODE(rstl->flagv) == HCL_CONCODE_BLOCK && (hcl->c->feed.rd.flagv & AT_BEGINNING)); return !rstl || (LIST_FLAG_GET_CONCODE(rstl->flagv) == HCL_CONCODE_BLOCK && (hcl->c->feed.rd.flagv & AT_BEGINNING));
} }
static int forge_auto_xlist_if_at_block_beginning (hcl_t* hcl, hcl_frd_t* frd) static int auto_forge_xlist_if_at_block_beginning (hcl_t* hcl, hcl_frd_t* frd)
{ {
if (is_at_block_beginning(hcl)) if (is_at_block_beginning(hcl))
{ {
@ -1174,14 +1174,14 @@ static int feed_process_token (hcl_t* hcl)
/* [] is a data list. so let's treat it like other literal /* [] is a data list. so let's treat it like other literal
* expressions(e.g. 1, "abc"). when it's placed at the block beginning, * expressions(e.g. 1, "abc"). when it's placed at the block beginning,
* create the outer XLIST. */ * create the outer XLIST. */
if (forge_auto_xlist_if_at_block_beginning(hcl, frd) <= -1) goto oops; if (auto_forge_xlist_if_at_block_beginning(hcl, frd) <= -1) goto oops;
frd->flagv = DATA_LIST; frd->flagv = DATA_LIST;
LIST_FLAG_SET_CONCODE (frd->flagv, HCL_CONCODE_ARRAY); LIST_FLAG_SET_CONCODE (frd->flagv, HCL_CONCODE_ARRAY);
goto start_list; goto start_list;
case HCL_TOK_BAPAREN: /* #[ */ case HCL_TOK_BAPAREN: /* #[ */
if (forge_auto_xlist_if_at_block_beginning(hcl, frd) <= -1) goto oops; if (auto_forge_xlist_if_at_block_beginning(hcl, frd) <= -1) goto oops;
frd->flagv = DATA_LIST; frd->flagv = DATA_LIST;
LIST_FLAG_SET_CONCODE (frd->flagv, HCL_CONCODE_BYTEARRAY); LIST_FLAG_SET_CONCODE (frd->flagv, HCL_CONCODE_BYTEARRAY);
@ -1194,13 +1194,13 @@ static int feed_process_token (hcl_t* hcl)
goto start_list; goto start_list;
case HCL_TOK_DLPAREN: /* #{ */ case HCL_TOK_DLPAREN: /* #{ */
if (forge_auto_xlist_if_at_block_beginning(hcl, frd) <= -1) goto oops; if (auto_forge_xlist_if_at_block_beginning(hcl, frd) <= -1) goto oops;
frd->flagv = DATA_LIST; frd->flagv = DATA_LIST;
LIST_FLAG_SET_CONCODE (frd->flagv, HCL_CONCODE_DIC); LIST_FLAG_SET_CONCODE (frd->flagv, HCL_CONCODE_DIC);
goto start_list; goto start_list;
case HCL_TOK_QLPAREN: /* #( */ case HCL_TOK_QLPAREN: /* #( */
if (forge_auto_xlist_if_at_block_beginning(hcl, frd) <= -1) goto oops; if (auto_forge_xlist_if_at_block_beginning(hcl, frd) <= -1) goto oops;
frd->flagv = DATA_LIST; frd->flagv = DATA_LIST;
LIST_FLAG_SET_CONCODE (frd->flagv, HCL_CONCODE_QLIST); LIST_FLAG_SET_CONCODE (frd->flagv, HCL_CONCODE_QLIST);
goto start_list; goto start_list;
@ -1529,7 +1529,7 @@ static int feed_process_token (hcl_t* hcl)
frd->flagv &= ~AT_BEGINNING; frd->flagv &= ~AT_BEGINNING;
} }
#else #else
if (forge_auto_xlist_if_at_block_beginning(hcl, frd) <= -1) goto oops; if (auto_forge_xlist_if_at_block_beginning(hcl, frd) <= -1) goto oops;
#endif #endif
break; break;
} }

View File

@ -1,3 +1,3 @@
## if `do` is not enclosed in `( )`, variable declaration is prohibited ## if `do` is not enclosed in `( )`, variable declaration is prohibited
(do | k | (set k 10)) do { | k | set k 10 };
do | k | {set k 10;}; ##ERROR: syntax error - variable declaration disallowed do | k | {set k 10;}; ##ERROR: syntax error - variable declaration disallowed

View File

@ -35,19 +35,17 @@ else { printf "OK %d\n" a; };
set b (B:newInstance 2 3 4); set b (B:newInstance 2 3 4);
set a (b:get-a); set a (b:get-a);
(if (/= a 4) (printf "ERROR: a must be 4\n") if (/= a 4) {printf "ERROR: a must be 4\n" }
else (printf "OK %d\n" a)) else { printf "OK %d\n" a };
set a (b:get-b); set a (b:get-b);
(if (/= a 6) (printf "ERROR: a must be 6\n") if (/= a 6) { printf "ERROR: a must be 6\n" }
else (printf "OK %d\n" a)) else { printf "OK %d\n" a };
set a (b:get-c); set a (b:get-c);
(if (/= a 8) (printf "ERROR: a must be 8\n") if (/= a 8) { printf "ERROR: a must be 8\n" }
else (printf "OK %d\n" a)) else {printf "OK %d\n" a };
set a (b:sum); set a (b:sum);
(if (/= a 27) (printf "ERROR: a must be 27\n") if (/= a 27) { printf "ERROR: a must be 27\n" }
else (printf "OK %d\n" a)) else { printf "OK %d\n" a };

View File

@ -16,7 +16,7 @@ defun test-non-local-ret-1(k) {
set a (test-non-local-ret-1 20); set a (test-non-local-ret-1 20);
if (/= a 28) { printf "ERROR: a must be 28\n" } if (/= a 28) { printf "ERROR: a must be 28\n" }
else { (printf "OK %d\n" a) }; else { printf "OK %d\n" a };
set a (test-non-local-ret-1 21); set a (test-non-local-ret-1 21);
if (/= a 41) { printf "ERROR: a must be 41\n" } if (/= a 41) { printf "ERROR: a must be 41\n" }

View File

@ -1,5 +1,5 @@
((fun() { (fun() {
## test return variables ## test return variables
| v1 v2 v3 i a b c d | | v1 v2 v3 i a b c d |
@ -13,17 +13,17 @@
set i (* i 10); set i (* i 10);
}; };
(set-r v1 v2 v3 (ff 10 20)) set-r v1 v2 v3 (ff 10 20);
(if (/= v1 130) (printf "ERROR: v1 must be 130\n")) if (/= v1 130) { printf "ERROR: v1 must be 130\n" };
(if (/= v2 260) (printf "ERROR: v2 must be 260\n")) if (/= v2 260) { printf "ERROR: v2 must be 260\n" };
(if (/= v3 1099) (printf "ERROR: v3 must be 1099\n")) if (/= v3 1099) { printf "ERROR: v3 must be 1099\n" };
(printf "OK v1=%d v2=%d v3=%d\n" v1 v2 v3) printf "OK v1=%d v2=%d v3=%d\n" v1 v2 v3;
(set-r v1 v2 (ff 1 2)) ## using 2 return variables only. not assigning to v3 set-r v1 v2 (ff 1 2); ## using 2 return variables only. not assigning to v3
(if (/= v1 1003) (printf "ERROR: v1 must be 1003\n")) if (/= v1 1003) { printf "ERROR: v1 must be 1003\n" };
(if (/= v2 2006) (printf "ERROR: v2 must be 2006\n")) if (/= v2 2006) { printf "ERROR: v2 must be 2006\n" };
(if (/= v3 1099) (printf "ERROR: v3 must be 1099\n")) if (/= v3 1099) { printf "ERROR: v3 must be 1099\n" };
(printf "OK v1=%d v2=%d v3=%d\n" v1 v2 v3) printf "OK v1=%d v2=%d v3=%d\n" v1 v2 v3;
@ -35,23 +35,23 @@
set X2 888; set X2 888;
defun ::: get ( ::: x y) { defun ::: get ( ::: x y) {
(set x X1) set x X1;
(set y X2) set y X2;
}; };
defun ::: get2 (inc ::: x y) { defun ::: get2 (inc ::: x y) {
(set x (+ X1 inc)) set x (+ X1 inc);
(set y (+ X2 inc)) set y (+ X2 inc);
}; };
}; };
(set-r a b (B:get)) set-r a b (B:get);
(set-r c d (B:get2 -100)) set-r c d (B:get2 -100);
(if (/= a 999) (printf "ERROR: a must be 999\n")) if (/= a 999) { printf "ERROR: a must be 999\n" };
(if (/= b 888) (printf "ERROR: b must be 888\n")) if (/= b 888) { printf "ERROR: b must be 888\n" };
(if (/= c 899) (printf "ERROR: c must be 899\n")) if (/= c 899) { printf "ERROR: c must be 899\n" };
(if (/= d 788) (printf "ERROR: d must be 788\n")) if (/= d 788) { printf "ERROR: d must be 788\n" };
printf "OK a=%d b=%d c=%d d=%d\n" a b c d; printf "OK a=%d b=%d c=%d d=%d\n" a b c d;
})); });

View File

@ -1,41 +1,41 @@
defun fn-y (t1 t2 va-ctx) { defun fn-y (t1 t2 va-ctx) {
| i | | i |
set i 0; i := 0;
while (< i (va-count va-ctx)) { while (< i (va-count va-ctx)) {
(printf "fn-y=>Y-VA[%d]=>[%d]\n" i (va-get i va-ctx)) printf "fn-y=>Y-VA[%d]=>[%d]\n" i (va-get i va-ctx);
(set i (+ i 1)) i := (+ i 1);
}; };
}; };
defun x(a b ... ::: x y z) { defun x(a b ... ::: x y z) {
|i| |i|
(set x (va-count)) set x (va-count);
(set y (* a b)) set y (* a b);
(set z (+ a b)) set z (+ a b);
set i 0; set i 0;
while (< i (va-count)) { while (< i (va-count)) {
(printf "VA[%d]=>[%d]\n" i (va-get i)) printf "VA[%d]=>[%d]\n" i (va-get i);
(set i (+ i 1)) set i (+ i 1);
}; };
fn-y "hello" "world" (va-context); fn-y "hello" "world" (va-context);
(return) return;
}; };
(set t (x 10 20 30)) set t (x 10 20 30);
(if (/= t 1) (printf "ERROR: t is not 1\n") if (/= t 1) { printf "ERROR: t is not 1\n" }
else (printf "OK: %d\n" t)) else { printf "OK: %d\n" t };
(set t (set-r a b c (x 10 20 30 40 50))) set t (set-r a b c (x 10 20 30 40 50));
(if (/= t 3) (printf "ERROR: t is not 3\n") if (/= t 3) { printf "ERROR: t is not 3\n" }
else (printf "OK: %d\n" t)) else { printf "OK: %d\n" t };
(if (/= a 3) (printf "ERROR: a is not 3\n") if (/= a 3) { printf "ERROR: a is not 3\n" }
else (printf "OK: %d\n" a)) else { printf "OK: %d\n" a };
(if (/= b 200) (printf "ERROR: b is not 200\n") if (/= b 200) { printf "ERROR: b is not 200\n" }
else (printf "OK: %d\n" b)) else { printf "OK: %d\n" b };
(if (/= c 30) (printf "ERROR: c is not 30\n") if (/= c 30) { printf "ERROR: c is not 30\n" }
else (printf "OK: %d\n" c)) else { printf "OK: %d\n" c };