91 lines
2.3 KiB
Common Lisp
91 lines
2.3 KiB
Common Lisp
class Ok1{};
|
|
class Ok2_1 inherits Ok1 {};
|
|
class Ok2_2 inherits Ok1 {};
|
|
|
|
class ErrTest {
|
|
errCase(): Bool {
|
|
{
|
|
case (new NOEXIST) of
|
|
x1:
|
|
Bool => true;
|
|
x2:
|
|
Int => x2 <- 10;
|
|
x3:
|
|
NOEXIST => x3 + 10;
|
|
x3:
|
|
NOEXIST => new Object;
|
|
x4:
|
|
Int => x4 + true;
|
|
x4:
|
|
Object => 111;
|
|
x5:
|
|
SELF_TYPE => self;
|
|
x5:
|
|
SELF_TYPE => self;
|
|
self:
|
|
SELF_TYPE => self;
|
|
esac;
|
|
1 + case (new Ok2_2) of
|
|
x1 : Ok2_1 => new Ok2_1;
|
|
x2 : Ok2_2 => new Ok2_2;
|
|
esac;
|
|
}
|
|
};
|
|
errArith(): Object {
|
|
{
|
|
new NOEXIST;
|
|
true + 1;
|
|
1 + true;
|
|
(1 * false) + (true * 2);
|
|
1 + "" + true * true;
|
|
(~(not 2)) + 2;
|
|
1 = false;
|
|
not(~(not 2)<(not (true * true))) ;
|
|
}
|
|
};
|
|
errLet(): Object {
|
|
let x1:NOEXIST, x2:Int<-10, x3:NOEXIST <- x1, x4:Bool <- 10 in {
|
|
x1 <- attr1 + x1;
|
|
10 + (self <- 10 + false);
|
|
}
|
|
};
|
|
attr1: NOEXIST;
|
|
};
|
|
|
|
class ErrMethods {
|
|
errMethod(x1:Int, x1:Bool) : Bool {
|
|
x1
|
|
};
|
|
errMethod2(x1:Int, x2:NOEXIST) : Bool {
|
|
x2 + x1
|
|
};
|
|
};
|
|
|
|
class Main {
|
|
attr1: Bool <- (new Err5).hello();
|
|
attr2: Int <- (new Err5).bye();
|
|
self(): SELF_TYPE { new SELF_TYPE };
|
|
attr3: NOEXIST <- 10;
|
|
main(): Object {
|
|
{
|
|
attr3.hello(1 + false) + 10;
|
|
let x:Int, y:NOEXIST in {
|
|
x1 <- x + 1;
|
|
x <- false;
|
|
x <- x1;
|
|
attr3 * 10;
|
|
y * 10;
|
|
if (y) then y else attr3 fi;
|
|
};
|
|
while (1 + 1) loop
|
|
x1 <- true
|
|
pool;
|
|
if (1 + 1) then 2 else 3 fi;
|
|
(new ErrMethods).errMethod(true + false);
|
|
(new ErrMethods).errMethod2(false, false);
|
|
(new ErrMethods).errMethod2(true + false);
|
|
attr2@SELF_TYPE.hello();
|
|
self@Main.self();
|
|
}
|
|
};
|
|
}; |