Merge branch 'Dev' into MoreTypeCheck
This commit is contained in:
@ -45,9 +45,9 @@ selectionSort(data) := {
|
||||
data(i) := temp;
|
||||
i := i + 1;
|
||||
}
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
(* Function definition
|
||||
entry is the first function called
|
||||
|
6
tests/sprint1/test/sp1_simple_alpha.alpha
Normal file
6
tests/sprint1/test/sp1_simple_alpha.alpha
Normal file
@ -0,0 +1,6 @@
|
||||
type main: string -> integer
|
||||
function entry: main
|
||||
|
||||
entry(arg) := {
|
||||
return 0;
|
||||
}
|
@ -15,7 +15,6 @@ function make_list : list
|
||||
|
||||
make_list (a) := {
|
||||
[integer:orig_a; llnode: ret; llnode: curr; llnode: temp]
|
||||
|
||||
if (a < 0 | a = 0) then {
|
||||
return null;
|
||||
} else {
|
||||
@ -73,8 +72,8 @@ entry (arg) := {
|
||||
w := reserve w;
|
||||
w.x := 5;
|
||||
w.y := 7;
|
||||
result := bar1(w);
|
||||
(* result := bar1(w); *)
|
||||
result := bar2(5,7);
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
80
tests/sprint2/test/sp2_llnode_bad.alpha
Normal file
80
tests/sprint2/test/sp2_llnode_bad.alpha
Normal file
@ -0,0 +1,80 @@
|
||||
type main: string -> integer
|
||||
function entry: main
|
||||
|
||||
type rec: [integer: x; integer: y]
|
||||
type T1: integer -> integer
|
||||
type T2: rec -> integer
|
||||
|
||||
type llnode: [llnode: prev; integer: val; llnode: next]
|
||||
type list: integer -> llnode
|
||||
|
||||
function foo : T1
|
||||
function bar1 : T2
|
||||
function bar2 : T2
|
||||
function make_list : list
|
||||
|
||||
make_list (a) := {
|
||||
[integer:orig_a; llnode: ret; llnode: curr; llnode: temp]
|
||||
|
||||
if (a < 0 | a = 0) then {
|
||||
return null;
|
||||
} else {
|
||||
ret := reserve ret;
|
||||
ret.prev := null;
|
||||
ret.next := null;
|
||||
ret.val := a;
|
||||
while (0 < a) {
|
||||
temp := reserve temp;
|
||||
temp.prev := null;
|
||||
temp.next := null;
|
||||
temp.val := ret.val;
|
||||
if (a = orig_a) then {
|
||||
ret.next := temp;
|
||||
temp.prev := ret;
|
||||
curr := temp;
|
||||
} else {
|
||||
curr.next := temp;
|
||||
temp.prev := curr;
|
||||
curr := temp;
|
||||
}
|
||||
a := a - 1;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
foo (x) := {
|
||||
return x * x;
|
||||
}
|
||||
|
||||
bar1(a,b) := {
|
||||
return a * b;
|
||||
}
|
||||
|
||||
bar2(r,s) := {
|
||||
if (r < s) then {
|
||||
while (!(r < s)) {
|
||||
r := r + 1;
|
||||
}
|
||||
} else {
|
||||
[integer: x]
|
||||
x := 0;
|
||||
while (x < 10) {
|
||||
r := r + s;
|
||||
}
|
||||
}
|
||||
return r * s;
|
||||
}
|
||||
|
||||
entry (arg) := {
|
||||
[ integer: result ; rec: w; llnode: li; boolean: b]
|
||||
li := make_list(6, 7);
|
||||
result := foo(5);
|
||||
w := reserve w;
|
||||
w.x := 5;
|
||||
w.y := 7;
|
||||
result := bar1(w);
|
||||
result := bar2(5,7);
|
||||
|
||||
return 'a';
|
||||
}
|
25
tests/sprint3/test/sp3_if_else.alpha
Normal file
25
tests/sprint3/test/sp3_if_else.alpha
Normal file
@ -0,0 +1,25 @@
|
||||
type rec: [character: x; integer: y]
|
||||
|
||||
type T2: rec -> integer
|
||||
|
||||
type main: string -> integer
|
||||
function entry: main
|
||||
function bar: T2
|
||||
|
||||
bar (r,s) := {
|
||||
return 0;
|
||||
}
|
||||
|
||||
entry (arg) := {
|
||||
[ integer: result ; rec: w]
|
||||
if ( result = result ) then {
|
||||
if ( result < w.y ) then {
|
||||
result := 8;
|
||||
} else {
|
||||
result := 9;
|
||||
}(* *)
|
||||
} else {
|
||||
result := bar('c', 7);
|
||||
}
|
||||
return 0;
|
||||
}
|
27
tests/sprint3/test/sp3_if_while.alpha
Normal file
27
tests/sprint3/test/sp3_if_while.alpha
Normal file
@ -0,0 +1,27 @@
|
||||
type rec: [character: x; integer: y]
|
||||
|
||||
type T2: rec -> integer
|
||||
|
||||
type main: string -> integer
|
||||
function entry: main
|
||||
function bar: T2
|
||||
|
||||
bar (r,s) := {
|
||||
return 0;
|
||||
}
|
||||
|
||||
entry (arg) := {
|
||||
[ integer: result ; rec: w]
|
||||
while ( result = result ) {
|
||||
result := result + 8;
|
||||
if ( result < w.y ) then {
|
||||
while (true) {
|
||||
result := 8;
|
||||
}
|
||||
} else {
|
||||
result := 9;
|
||||
}
|
||||
result := bar('c', 7);
|
||||
}
|
||||
return 0;
|
||||
}
|
@ -12,7 +12,12 @@ bar (r,s) := {
|
||||
|
||||
entry (arg) := {
|
||||
[ integer: result ; rec: w]
|
||||
result := bar(1,2);
|
||||
while ( result = result ) {
|
||||
while ( result < w.y ) {
|
||||
result := 8;
|
||||
}
|
||||
result := 9;
|
||||
}
|
||||
result := bar('c', 7);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user