changed the syntax of the class-level variable declacration to use square brackets
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
2024-07-09 23:44:24 +09:00
parent e91c9da9d4
commit 8f87dbe008
9 changed files with 113 additions and 151 deletions

View File

@ -1,8 +1,8 @@
class B | x y | {
class B [ x y ] {
};
class X :: B | a b | {
class X :: B [ a b ] {
fun :* new(t) {
| a |
set self.a t;
@ -75,7 +75,7 @@ Array:boom
---
class X | a b c | {
class X [ a b c ] {
fun :* new () {
self.a := 20
return self
@ -95,10 +95,10 @@ printf "%d\n" ((X:new):get_a)
---
class F | a b c | {
class F [ a b c ] {
}
class X | a b c | {
class X [ a b c ] {
fun oh() {
fun F:get_a() {
return super.a ##ERROR: syntax error - not allowed to prefix with super

View File

@ -96,7 +96,7 @@ if (x = 29) {
## --------------------------------------
defclass A | a b c | {
defclass A [ a b c ] {
defun :* newInstance(x y z) {
set a x
set b y

View File

@ -1,6 +1,6 @@
## test class instantiation methods
class A | a b c | {
class A [ a b c ] {
defun :*newInstance(x y z) {
set a x;
@ -14,7 +14,7 @@ class A | a b c | {
defun get-c() { return self.c; };
};
class B :: A | d e f | {
class B :: A [ d e f ] {
defun :*newInstance(x y z) {
super:newInstance (* x 2) (* y 2) (* z 2);

View File

@ -1,5 +1,5 @@
set t (
class | x | {
class [ x ] {
defun :* make() { x := 1234; return self; };
defun get-x() { return x };
}
@ -27,7 +27,7 @@ else { printf "OK: value is %d\n" v };
## --------------------------------------------------------------
class X | a b c d | {
class X [ a b c d ] {
fun :*new() {
return self;
}
@ -54,10 +54,10 @@ else { printf "OK: value is %d\n" v }
## --------------------------------------------------------------
class F | j t | {
class F [ j t ] {
}
class X | a b c | {
class X [ a b c ] {
fun :* new () {
self.a := 20
return self
@ -95,10 +95,10 @@ else { printf "OK: value is %d\n" v }
## --------------------------------------------------------------
class F | j t | {
class F [ j t ] {
}
class X | a b c | {
class X [ a b c ] {
fun :* new () {
| j |
self.a := 20

View File

@ -29,7 +29,7 @@
## test return variables in message sends
defclass B :: | X1 X2 | {
defclass B [ [X1 X2] ] {
set X1 999;
set X2 888;

View File

@ -56,7 +56,7 @@ defun x () {
x
class T | j | {
class T [ j ] {
defun :* new() {
set j 99

View File

@ -1,4 +1,4 @@
defclass A | a | {
defclass A [ a ] {
defun :* init1() {
| b |
set b (+ 1 2);
@ -28,3 +28,26 @@ defclass A | a | {
defun String length() { ##ERROR: syntax error - no argument list
}
---
class A [ 10 ] { ##ERROR: syntax error - not variable name - 10
}
---
class A [ a := 20 ] { ##ERROR: syntax error - := disallowed
}
---
class A [ [ [a] ] ] { ##ERROR: syntax error - not variable name
}
---
class A [ a + ] { ##ERROR: syntax error - prohibited binary operator - +
}
## TODO: This check is supposed to fail. + must be treated as a binop symbol
##---
##class A [ + ] { ##ERROR: syntax error - prohibited binary operator - +
##}

View File

@ -1,3 +1,3 @@
defclass A | a | {
defclass A [ a ] {
| j | ##ERROR: syntax error - variable declaration disallowed in class init scope
};