let 'fun' replace 'defun' totally
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:
@ -18,11 +18,11 @@ class B + ##ERROR: syntax error - prohibited binary selector '+'
|
||||
J := 11
|
||||
class B {
|
||||
if (== J 10) {
|
||||
defun :*newA() {
|
||||
fun :*newA() {
|
||||
return self
|
||||
}
|
||||
} else {
|
||||
defun :*newB() {
|
||||
fun :*newB() {
|
||||
return self
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
| J |
|
||||
|
||||
defun xxx (x y z
|
||||
fun xxx (x y z
|
||||
:: r ) {
|
||||
|
||||
| k
|
||||
|
@ -134,13 +134,13 @@ printf :*; ##ERROR: syntax error - prohibited in this context
|
||||
|
||||
---
|
||||
|
||||
defun :: fun1() { ##ERROR: syntax error - function name not symbol in defun
|
||||
fun :: fun1() { ##ERROR: syntax error - invalid function name '::' for 'fun'
|
||||
return 10;
|
||||
};
|
||||
|
||||
---
|
||||
|
||||
defun :* fun1() { ##ERROR: syntax error - function name not symbol in defun
|
||||
fun :* fun1() { ##ERROR: syntax error - invalid function name ':*' for 'fun'
|
||||
return 10;
|
||||
};
|
||||
|
||||
|
18
t/fun-01.hcl
18
t/fun-01.hcl
@ -1,4 +1,4 @@
|
||||
defun aaa(a b) {
|
||||
fun aaa(a b) {
|
||||
| c |
|
||||
set c (+ a b);
|
||||
return c;
|
||||
@ -14,13 +14,13 @@ if (== k 30) {
|
||||
|
||||
## --------------------------------------
|
||||
|
||||
defun mkfun(t) {
|
||||
fun mkfun(t) {
|
||||
return (fun(c) {
|
||||
return (+ t c);
|
||||
});
|
||||
}
|
||||
|
||||
defun mkfun2(t) {
|
||||
fun mkfun2(t) {
|
||||
return {fun(c) {
|
||||
return (fun(d) {
|
||||
return (+ d c t)
|
||||
@ -64,7 +64,7 @@ if (== k 80) {
|
||||
## --------------------------------------
|
||||
|
||||
## multiple return values
|
||||
defun f(a :: b c) { b := (+ a 10); c := (+ a 20) }
|
||||
fun f(a :: b c) { b := (+ a 10); c := (+ a 20) }
|
||||
[x, y] := (f 9)
|
||||
if (== x 19) {
|
||||
printf "OK - %d\n" x
|
||||
@ -78,7 +78,7 @@ if (== y 29) {
|
||||
}
|
||||
|
||||
## --------------------------------------
|
||||
k := (defun qq(t) (+ t 20))
|
||||
k := (fun qq(t) (+ t 20))
|
||||
x := (k 8)
|
||||
y := (qq 9)
|
||||
|
||||
@ -97,16 +97,16 @@ if (== y 29) {
|
||||
## --------------------------------------
|
||||
|
||||
defclass A [ a b c ] {
|
||||
defun :* newInstance(x y z) {
|
||||
fun :* newInstance(x y z) {
|
||||
set a x
|
||||
set b y
|
||||
set c z
|
||||
return self
|
||||
};
|
||||
|
||||
defun get-a() { return a; };
|
||||
##defun get-b() b;
|
||||
##defun get-c() c;
|
||||
fun get-a() { return a; };
|
||||
##fun get-b() b;
|
||||
##fun get-c() c;
|
||||
};
|
||||
|
||||
k := (A:newInstance 11 22 33);
|
||||
|
@ -14,21 +14,21 @@ fun Number: ~= (oprnd) { return (~= self oprnd) }
|
||||
|
||||
class A [ a b c ] {
|
||||
|
||||
defun :*newInstance(x y z) {
|
||||
fun :*newInstance(x y z) {
|
||||
set a x;
|
||||
set b y;
|
||||
set c z;
|
||||
return self;
|
||||
};
|
||||
|
||||
defun get-a() { return self.a; };
|
||||
defun get-b() { return self.b; };
|
||||
defun get-c() { return self.c; };
|
||||
fun get-a() { return self.a; };
|
||||
fun get-b() { return self.b; };
|
||||
fun get-c() { return self.c; };
|
||||
};
|
||||
|
||||
class B :: A [ d e f ] {
|
||||
|
||||
defun :*newInstance(x y z) {
|
||||
fun :*newInstance(x y z) {
|
||||
super:newInstance (* x 2) (* y 2) (* z 2);
|
||||
set d x;
|
||||
set e y;
|
||||
@ -36,11 +36,11 @@ class B :: A [ d e f ] {
|
||||
return self;
|
||||
};
|
||||
|
||||
defun :: getSuper() { return super; };
|
||||
###defun :: getSuperclass() { return (self:superclass); };
|
||||
defun :: getSelf() { return self; };
|
||||
fun :: getSuper() { return super; };
|
||||
###fun :: getSuperclass() { return (self:superclass); };
|
||||
fun :: getSelf() { return self; };
|
||||
|
||||
defun sum() {
|
||||
fun sum() {
|
||||
return (+ (super:get-a) (super:get-b) (super:get-c) self.d self.e self.f);
|
||||
};
|
||||
};
|
||||
|
@ -12,8 +12,8 @@ fun Number: ~= (oprnd) { return (~= self oprnd) }
|
||||
## --------------------------------------------------------------
|
||||
set t (
|
||||
class [ x ] {
|
||||
defun :* make() { x := 1234; return self; };
|
||||
defun get-x() { return x };
|
||||
fun :* make() { x := 1234; return self; };
|
||||
fun get-x() { return x };
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
z1 := 0
|
||||
z2 := 0
|
||||
|
||||
defun loop1() {
|
||||
fun loop1() {
|
||||
| k |
|
||||
|
||||
k := 1
|
||||
@ -15,7 +15,7 @@ defun loop1() {
|
||||
sem-signal s1
|
||||
}
|
||||
|
||||
defun loop2() {
|
||||
fun loop2() {
|
||||
| k |
|
||||
|
||||
k := 0
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
set i 100;
|
||||
|
||||
defun ff(a b :: x y z) {
|
||||
fun ff(a b :: x y z) {
|
||||
set x (+ a b i);
|
||||
set y (+ x x);
|
||||
set z (+ 999 i);
|
||||
@ -36,12 +36,12 @@
|
||||
set X1 999;
|
||||
set X2 888;
|
||||
|
||||
defun :: get ( :: x y) {
|
||||
fun :: get ( :: x y) {
|
||||
set x X1;
|
||||
set y X2;
|
||||
};
|
||||
|
||||
defun :: get2 (inc :: x y) {
|
||||
fun :: get2 (inc :: x y) {
|
||||
set x (+ X1 inc);
|
||||
set y (+ X2 inc);
|
||||
};
|
||||
|
@ -1,4 +1,4 @@
|
||||
defun fn-y (t1 t2 va-ctx) {
|
||||
fun fn-y (t1 t2 va-ctx) {
|
||||
| i |
|
||||
i := 0
|
||||
while (< i (va-count va-ctx)) {
|
||||
@ -7,7 +7,7 @@ defun fn-y (t1 t2 va-ctx) {
|
||||
}
|
||||
}
|
||||
|
||||
defun x(a b ... :: x y z) {
|
||||
fun x(a b ... :: x y z) {
|
||||
|i|
|
||||
|
||||
x := (va-count)
|
||||
|
10
t/var-01.hcl
10
t/var-01.hcl
@ -1,4 +1,4 @@
|
||||
defun x (a b :: r) {
|
||||
fun x (a b :: r) {
|
||||
|
||||
| x y |
|
||||
|
||||
@ -30,7 +30,7 @@ if (~= t 500) (printf "ERROR: t is not equal to 500\n") \
|
||||
else (printf "OK: %d\n" t)
|
||||
|
||||
|
||||
defun x () {
|
||||
fun x () {
|
||||
|
||||
| x y |
|
||||
|
||||
@ -58,17 +58,17 @@ x
|
||||
|
||||
class T [ j ] {
|
||||
|
||||
defun :* new() {
|
||||
fun :* new() {
|
||||
set j 99
|
||||
return self
|
||||
}
|
||||
|
||||
defun x() {
|
||||
fun x() {
|
||||
set R {
|
||||
| x |
|
||||
set x 1
|
||||
while (< x j) {
|
||||
defun Q() x
|
||||
fun Q() x
|
||||
set x (+ x 1)
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
defun x (a :: x y z) {
|
||||
fun x (a :: x y z) {
|
||||
x := (* a a);
|
||||
y := (+ a a);
|
||||
z := (- x y);
|
||||
|
@ -1,5 +1,5 @@
|
||||
defclass A [ a ] {
|
||||
defun :* init1() {
|
||||
fun :* init1() {
|
||||
| b |
|
||||
set b (+ 1 2);
|
||||
set a b;
|
||||
@ -15,7 +15,7 @@ defclass A [ a ] {
|
||||
printf ">>> %d\n" j;
|
||||
}
|
||||
|
||||
defun :* init2() {
|
||||
fun :* init2() {
|
||||
| b |
|
||||
set b (+ 10 20);
|
||||
set a b;
|
||||
@ -26,7 +26,7 @@ defclass A [ a ] {
|
||||
|
||||
---
|
||||
|
||||
defun String length() { ##ERROR: syntax error - no argument list
|
||||
fun String length() { ##ERROR: syntax error - no argument list
|
||||
}
|
||||
|
||||
---
|
||||
|
@ -1,2 +1,2 @@
|
||||
defun self.x() { ##ERROR: syntax error - function name not symbol
|
||||
fun self.x() { ##ERROR: syntax error - invalid function name 'self.x' for 'fun'
|
||||
};
|
||||
|
Reference in New Issue
Block a user