changed the syntax for clarity - attribute list to use a tuple, class variable list to use a normal parenthesized list
This commit is contained in:
@ -58,16 +58,36 @@ class a: #(1 2) { ##ERROR: syntax error - no valid superclass name after ':' for
|
||||
J := 11
|
||||
class B {
|
||||
if (== J 10) {
|
||||
fun(#ci) newA() {
|
||||
fun[#ci] newA() { ##ERROR: syntax error - function 'newA' defined with 'fun' prohibited in class initialziation context
|
||||
return self
|
||||
}
|
||||
} else {
|
||||
fun(#ci) newB() {
|
||||
fun[#ci] newB() {
|
||||
return self
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
##t2 := (B:newB)
|
||||
##t1 := (B:newA) ##error: exception not handled - "unable to send newA to B - 'newA' not found in B"
|
||||
|
||||
---
|
||||
|
||||
class B {
|
||||
|
||||
}
|
||||
|
||||
J := 11
|
||||
if (== J 10) {
|
||||
fun[#ci] B:newA() {
|
||||
return self
|
||||
}
|
||||
} else {
|
||||
fun[#ci] B:newB() {
|
||||
return self
|
||||
}
|
||||
}
|
||||
|
||||
t2 := (B:newB)
|
||||
t1 := (B:newA) ##ERROR: exception not handled - "unable to send newA to B - 'newA' not found in B"
|
||||
|
||||
@ -87,7 +107,7 @@ class B {
|
||||
|
||||
class X: B {
|
||||
var a b
|
||||
fun(#ci) new(t) {
|
||||
fun[#ci] new(t) {
|
||||
| a |
|
||||
set self.a t;
|
||||
set a 100;
|
||||
@ -109,11 +129,11 @@ class X: B {
|
||||
---
|
||||
|
||||
class X {
|
||||
fun(#ci) xxx() {
|
||||
fun[#ci] xxx() {
|
||||
return X;
|
||||
}
|
||||
|
||||
fun(#ci) qqq() {
|
||||
fun[#ci] qqq() {
|
||||
return "hello"
|
||||
}
|
||||
|
||||
@ -124,10 +144,10 @@ class X {
|
||||
|
||||
---
|
||||
class X {
|
||||
fun(#ci) xxx() {
|
||||
fun[#ci] xxx() {
|
||||
return X;
|
||||
}
|
||||
fun(#ci) qqq() {
|
||||
fun[#ci] qqq() {
|
||||
return "hello"
|
||||
}
|
||||
}
|
||||
@ -152,7 +172,7 @@ fun X:xxx() { ##ERROR: exception not handled - "not class"
|
||||
## and the clase instantiation method can't specify the size
|
||||
## you can't place an item in the arrya at all.
|
||||
|
||||
fun(#ci) Array:boom() {
|
||||
fun[#ci] Array:boom() {
|
||||
core.basicAtPut self 0 10 ##ERROR: exception not handled - "position(0) out of range - negative or greater than or equal to 0"
|
||||
printf "%O" self
|
||||
return self
|
||||
@ -163,7 +183,7 @@ Array:boom
|
||||
|
||||
class X {
|
||||
var a b c
|
||||
fun(#ci) new () {
|
||||
fun[#ci] new () {
|
||||
self.a := 20
|
||||
return self
|
||||
}
|
||||
@ -243,7 +263,7 @@ class a {
|
||||
|
||||
class X10 {
|
||||
var x
|
||||
fun(#ci) make() { x := 1234; return self; };
|
||||
fun[#ci] make() { x := 1234; return self; };
|
||||
fun get-x() { return x };
|
||||
}
|
||||
|
||||
@ -260,44 +280,44 @@ class String { ##ERROR: exception not handled - "incompatible redefintion of Str
|
||||
|
||||
---
|
||||
|
||||
class() { ##ERROR: syntax error - empty attribute list on unnamed class for 'class'
|
||||
class[] { ##ERROR: syntax error - empty attribute list on unnamed class for 'class'
|
||||
}
|
||||
|
||||
---
|
||||
|
||||
class() Kuduro { ##ERROR: syntax error - empty attribute list on 'Kuduro' for 'class'
|
||||
class[] Kuduro { ##ERROR: syntax error - empty attribute list on 'Kuduro' for 'class'
|
||||
}
|
||||
|
||||
---
|
||||
|
||||
class(#byte #limited #char) Kuduro { ##ERROR: syntax error - conflicting or duplicate class attribute name '#char'
|
||||
class[#byte #limited #char] Kuduro { ##ERROR: syntax error - conflicting or duplicate class attribute name '#char'
|
||||
}
|
||||
|
||||
---
|
||||
class(#byte #limited #final #limited) Kuduro { ##ERROR: syntax error - conflicting or duplicate class attribute name '#limited'
|
||||
class[#byte #limited #final #limited] Kuduro { ##ERROR: syntax error - conflicting or duplicate class attribute name '#limited'
|
||||
}
|
||||
|
||||
|
||||
---
|
||||
class(#byte #bytes) Kuduro { ##ERROR: syntax error - unrecognized class attribute name '#bytes'
|
||||
class[#byte #bytes] Kuduro { ##ERROR: syntax error - unrecognized class attribute name '#bytes'
|
||||
}
|
||||
|
||||
---
|
||||
class Kuduro [a b c] {
|
||||
class Kuduro (a b c) {
|
||||
var d e
|
||||
var a ##ERROR: syntax error - duplicate instance variable name 'a'
|
||||
}
|
||||
|
||||
---
|
||||
|
||||
class Kuduro [a [b] c] {
|
||||
class Kuduro (a (b) c) {
|
||||
var d e
|
||||
var b ##ERROR: syntax error - duplicate instance variable name 'b'
|
||||
}
|
||||
|
||||
---
|
||||
|
||||
class Kuduro [a [b] c] {
|
||||
class Kuduro (a (b) c) {
|
||||
var d e
|
||||
var(#class) b ##ERROR: syntax error - duplicate class variable name 'b'
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ if (== y 29) {
|
||||
|
||||
class A {
|
||||
var a b c
|
||||
fun(#ci) newInstance(x y z) {
|
||||
fun[#ci] newInstance(x y z) {
|
||||
set a x
|
||||
set b y
|
||||
set c z
|
||||
|
@ -15,7 +15,7 @@ fun Number: ~= (oprnd) { return (~= self oprnd) }
|
||||
class A {
|
||||
var a b c
|
||||
|
||||
fun(#ci) newInstance(x y z) {
|
||||
fun[#ci] newInstance(x y z) {
|
||||
set a x;
|
||||
set b y;
|
||||
set c z;
|
||||
@ -30,7 +30,7 @@ class A {
|
||||
class B: A {
|
||||
var d e f
|
||||
|
||||
fun(#ci) newInstance(x y z) {
|
||||
fun[#ci] newInstance(x y z) {
|
||||
super:newInstance (* x 2) (* y 2) (* z 2);
|
||||
set d x;
|
||||
set e y;
|
||||
@ -38,9 +38,9 @@ class B: A {
|
||||
return self;
|
||||
};
|
||||
|
||||
fun(#c) getSuper() { return super; };
|
||||
###fun(#c) getSuperclass() { return (self:superclass); };
|
||||
fun(#c) getSelf() { return self; };
|
||||
fun[#c] getSuper() { return super; };
|
||||
###fun[#c] getSuperclass() { return (self:superclass); };
|
||||
fun[#c] getSelf() { return self; };
|
||||
|
||||
fun sum() {
|
||||
return (+ (super:get-a) (super:get-b) (super:get-c) self.d self.e self.f);
|
||||
|
@ -13,7 +13,7 @@ fun Number: ~= (oprnd) { return (~= self oprnd) }
|
||||
set t (
|
||||
class {
|
||||
var x
|
||||
fun(#ci) make() { x := 1234; return self; };
|
||||
fun[#ci] make() { x := 1234; return self; };
|
||||
fun get-x() { return x };
|
||||
}
|
||||
);
|
||||
@ -43,7 +43,7 @@ else { printf "OK: value is %d\n" v };
|
||||
|
||||
class X0 {
|
||||
var a b c d
|
||||
fun(#ci) new() {
|
||||
fun[#ci] new() {
|
||||
return self;
|
||||
}
|
||||
|
||||
@ -72,7 +72,7 @@ else { printf "OK: value is %d\n" v }
|
||||
|
||||
class X1 {
|
||||
var a b c
|
||||
fun(#classinst) new () {
|
||||
fun[#classinst] new () {
|
||||
self.a := 20
|
||||
return self
|
||||
}
|
||||
@ -115,11 +115,11 @@ class F {
|
||||
|
||||
class X2 {
|
||||
var a b c
|
||||
fun(#classinst) new () {
|
||||
fun[#classinst] new () {
|
||||
| j |
|
||||
self.a := 20
|
||||
j := (self.a * 2)
|
||||
fun(#class) F:get_x() { return (j * j) }
|
||||
fun[#class] F:get_x() { return (j * j) }
|
||||
return self
|
||||
}
|
||||
}
|
||||
@ -131,7 +131,7 @@ else { printf "OK: value is %d\n" v }
|
||||
|
||||
## --------------------------------------------------------------
|
||||
class X3 {
|
||||
fun(#ci) new (a b) {
|
||||
fun[#ci] new (a b) {
|
||||
fun X3:sum() { return (fun(j) { return (j + (a + b)) }) }
|
||||
return self;
|
||||
}
|
||||
@ -143,15 +143,15 @@ else { printf "OK: value is %d\n" v }
|
||||
|
||||
## --------------------------------------------------------------
|
||||
class X4 {
|
||||
fun(#class) t() {
|
||||
fun[#class] t() {
|
||||
| X5 |
|
||||
class X5 { ## this X5 isn't the local variable X4
|
||||
fun(#class) t() {
|
||||
fun[#class] t() {
|
||||
X6 := (class {
|
||||
fun(#class) t() {
|
||||
fun[#class] t() {
|
||||
| X7 |
|
||||
X7 := (class { ## this X4 is the local variable X4
|
||||
fun(#class) t() { return 60 }
|
||||
fun[#class] t() { return 60 }
|
||||
})
|
||||
return 40
|
||||
}
|
||||
@ -186,7 +186,7 @@ else { printf "OK: value is %d\n" v }
|
||||
## --------------------------------------------------------------
|
||||
class X10 {
|
||||
var x
|
||||
fun(#ci) make() { x := 1234; return self; };
|
||||
fun[#ci] make() { x := 1234; return self; };
|
||||
fun get-x() { return x };
|
||||
}
|
||||
|
||||
|
@ -37,12 +37,12 @@
|
||||
set X1 999;
|
||||
set X2 888;
|
||||
|
||||
fun(#class) get ( :: x y) {
|
||||
fun[#class] get ( :: x y) {
|
||||
set x X1;
|
||||
set y X2;
|
||||
};
|
||||
|
||||
fun(#class) get2 (inc :: x y) {
|
||||
fun[#class] get2 (inc :: x y) {
|
||||
set x (+ X1 inc);
|
||||
set y (+ X2 inc);
|
||||
};
|
||||
@ -63,9 +63,9 @@
|
||||
class X {
|
||||
var x y
|
||||
|
||||
fun(#class) f(a :: b c) { b := (+ a 10); c := (+ a 20) }
|
||||
fun[#class] f(a :: b c) { b := (+ a 10); c := (+ a 20) }
|
||||
|
||||
fun(#classinst) new(z) {
|
||||
fun[#classinst] new(z) {
|
||||
## multi-variable assignment with return variables to member variables
|
||||
[self.x, self.y] := (X:f z)
|
||||
return self;
|
||||
|
@ -59,7 +59,7 @@ x
|
||||
class T {
|
||||
var j
|
||||
|
||||
fun(#classinst) new() {
|
||||
fun[#classinst] new() {
|
||||
set j 99
|
||||
return self
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
class A [ a ] {
|
||||
fun(#ci) init1() {
|
||||
class A ( a ) {
|
||||
fun[#ci] init1() {
|
||||
| b |
|
||||
set b (+ 1 2);
|
||||
set a b;
|
||||
@ -15,7 +15,7 @@ class A [ a ] {
|
||||
printf ">>> %d\n" j;
|
||||
}
|
||||
|
||||
fun(#ci) init2() {
|
||||
fun[#ci] init2() {
|
||||
| b |
|
||||
set b (+ 10 20);
|
||||
set a b;
|
||||
@ -31,24 +31,28 @@ fun String length() { ##ERROR: syntax error - 'String' not followed by ( but fol
|
||||
|
||||
---
|
||||
|
||||
class A [ 10 ] { ##ERROR: syntax error - not variable name '10'
|
||||
class A ( 10 ) { ##ERROR: syntax error - not variable name '10'
|
||||
}
|
||||
|
||||
---
|
||||
|
||||
class A [ a := 20 ] { ##ERROR: syntax error - := disallowed
|
||||
class A ( a := 20 ) { ##ERROR: syntax error - block expression expected as 'class' body
|
||||
}
|
||||
|
||||
---
|
||||
class A [ [ [a] ] ] { ##ERROR: syntax error - not variable name
|
||||
|
||||
class A ( ( (a) ) ) { ##ERROR: syntax error - not variable name
|
||||
}
|
||||
|
||||
---
|
||||
class A [ a + ] { ##ERROR: syntax error - not variable name '+'
|
||||
|
||||
## TODO: improve the reader to be aware that it's in the class definition context
|
||||
## while reading '(a + )' and to flag + as an invalid variable name...
|
||||
class A ( a + ) { ##ERROR: syntax error - no operand after binary selector '+'
|
||||
}
|
||||
|
||||
---
|
||||
class A [ + ] { ##ERROR: syntax error - not variable name '+'
|
||||
class A ( + ) { ##ERROR: syntax error - not variable name '+'
|
||||
}
|
||||
|
||||
---
|
||||
|
@ -79,22 +79,22 @@ fun fun fun1() { ##ERROR: syntax error - invalid function name 'fun' for 'fun'
|
||||
|
||||
---
|
||||
|
||||
fun(#ci) fun1() { ##ERROR: syntax error - attribute list prohibited on plain function 'fun1'
|
||||
fun[#ci] fun1() { ##ERROR: syntax error - attribute list prohibited on plain function 'fun1'
|
||||
}
|
||||
|
||||
---
|
||||
|
||||
fun() () { ##ERROR: syntax error - attribute list prohibited on unnamed function for 'fun'
|
||||
fun[] () { ##ERROR: syntax error - attribute list prohibited on unnamed function for 'fun'
|
||||
}
|
||||
|
||||
---
|
||||
|
||||
fun() X:y() { ##ERROR: syntax error - empty attribute list on 'X:y' for 'fun'
|
||||
fun[] X:y() { ##ERROR: syntax error - empty attribute list on 'X:y' for 'fun'
|
||||
}
|
||||
|
||||
---
|
||||
|
||||
class X {
|
||||
fun() y() { ##ERROR: syntax error - empty attribute list on 'y' for 'fun'
|
||||
fun[] y() { ##ERROR: syntax error - empty attribute list on 'y' for 'fun'
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user