carl
This commit is contained in:
10
tests/carl/Errors/entry.undeclaredType.alpha
Normal file
10
tests/carl/Errors/entry.undeclaredType.alpha
Normal file
@ -0,0 +1,10 @@
|
||||
type M : string -> integer
|
||||
|
||||
function foo : M
|
||||
|
||||
foo (s) := {
|
||||
[
|
||||
int: x
|
||||
]
|
||||
return 0;
|
||||
}
|
16
tests/carl/Errors/entry.undeclaredType.alpha.asc
Normal file
16
tests/carl/Errors/entry.undeclaredType.alpha.asc
Normal file
@ -0,0 +1,16 @@
|
||||
alpha parser, version 0.2 (2023-03-04) - Annotated Source Code for file entry.undeclaredType.alpha
|
||||
001: type M : string -> integer
|
||||
002:
|
||||
003: function foo : M
|
||||
004:
|
||||
005: foo (s) := {
|
||||
006: [
|
||||
007: int: x
|
||||
^0 ^1
|
||||
LINE 7:9 ** ERROR #0: the name 'int', used here as a type, has not been declared at this point in the program.
|
||||
LINE 7:14 ** ERROR #1: the name 'x' is being declared with an unknown type.
|
||||
|
||||
008: ]
|
||||
009: return 0;
|
||||
010: }
|
||||
011:
|
7
tests/carl/Errors/entry.undeclaredVar.alpha
Normal file
7
tests/carl/Errors/entry.undeclaredVar.alpha
Normal file
@ -0,0 +1,7 @@
|
||||
type M : string -> integer
|
||||
|
||||
function entry : M
|
||||
|
||||
entry(s) := {
|
||||
return x;
|
||||
}
|
12
tests/carl/Errors/entry.undeclaredVar.alpha.asc
Normal file
12
tests/carl/Errors/entry.undeclaredVar.alpha.asc
Normal file
@ -0,0 +1,12 @@
|
||||
alpha parser, version 0.2 (2023-03-04) - Annotated Source Code for file entry.undeclaredVar.alpha
|
||||
001: type M : string -> integer
|
||||
002:
|
||||
003: function entry : M
|
||||
004:
|
||||
005: entry(s) := {
|
||||
006: return x;
|
||||
^0
|
||||
LINE 6:12 ** ERROR #0: the name 'x', used here as a variable name, has not been declared at this point in the program.
|
||||
|
||||
007: }
|
||||
008:
|
14
tests/carl/Errors/error.operator.alpha
Normal file
14
tests/carl/Errors/error.operator.alpha
Normal file
@ -0,0 +1,14 @@
|
||||
type string2int: string -> integer
|
||||
|
||||
function entry : string2int
|
||||
|
||||
entry(arg) := {
|
||||
[ integer: i; integer: sum ]
|
||||
sum := 0;
|
||||
i := 0;
|
||||
while (i < 10) {
|
||||
sum = sum + i;
|
||||
i := i + 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
19
tests/carl/Errors/error.operator.alpha.asc
Normal file
19
tests/carl/Errors/error.operator.alpha.asc
Normal file
@ -0,0 +1,19 @@
|
||||
alpha parser, version 0.2 (2023-03-04) - Annotated Source Code for file error.operator.alpha
|
||||
001: type string2int: string -> integer
|
||||
002:
|
||||
003: function entry : string2int
|
||||
004:
|
||||
005: entry(arg) := {
|
||||
006: [ integer: i; integer: sum ]
|
||||
007: sum := 0;
|
||||
008: i := 0;
|
||||
009: while (i < 10) {
|
||||
010: sum = sum + i;
|
||||
^0
|
||||
LINE 10:13 ** ERROR #0: assignment operator (:=) expected but equality operator (=) found.
|
||||
|
||||
011: i := i + 1;
|
||||
012: }
|
||||
013: return 0;
|
||||
014: }
|
||||
015:
|
8
tests/carl/NoErrors/entry.definition.alpha
Normal file
8
tests/carl/NoErrors/entry.definition.alpha
Normal file
@ -0,0 +1,8 @@
|
||||
(* type string : 1 -> character *)
|
||||
type M : string -> integer
|
||||
|
||||
function entry : M
|
||||
|
||||
entry(s) := {
|
||||
return 0;
|
||||
}
|
10
tests/carl/NoErrors/entry.definition.alpha.asc
Normal file
10
tests/carl/NoErrors/entry.definition.alpha.asc
Normal file
@ -0,0 +1,10 @@
|
||||
alpha parser, version 0.2 (2023-03-04) - Annotated Source Code for file entry.definition.alpha
|
||||
001: (* type string : 1 -> character *)
|
||||
002: type M : string -> integer
|
||||
003:
|
||||
004: function entry : M
|
||||
005:
|
||||
006: entry(s) := {
|
||||
007: return 0;
|
||||
008: }
|
||||
009:
|
11
tests/carl/NoErrors/entry.duplicateDifferent.alpha
Normal file
11
tests/carl/NoErrors/entry.duplicateDifferent.alpha
Normal file
@ -0,0 +1,11 @@
|
||||
type M : string -> integer
|
||||
|
||||
function entry : M
|
||||
|
||||
entry(s) := {
|
||||
[
|
||||
integer: x;
|
||||
character: x
|
||||
]
|
||||
return x;
|
||||
}
|
13
tests/carl/NoErrors/entry.duplicateDifferent.alpha.asc
Normal file
13
tests/carl/NoErrors/entry.duplicateDifferent.alpha.asc
Normal file
@ -0,0 +1,13 @@
|
||||
alpha parser, version 0.2 (2023-03-04) - Annotated Source Code for file entry.duplicateDifferent.alpha
|
||||
001: type M : string -> integer
|
||||
002:
|
||||
003: function entry : M
|
||||
004:
|
||||
005: entry(s) := {
|
||||
006: [
|
||||
007: integer: x;
|
||||
008: character: x
|
||||
009: ]
|
||||
010: return x;
|
||||
011: }
|
||||
012:
|
9
tests/carl/NoErrors/entry.duplicateSame.alpha
Normal file
9
tests/carl/NoErrors/entry.duplicateSame.alpha
Normal file
@ -0,0 +1,9 @@
|
||||
type M : string -> integer
|
||||
function entry : M
|
||||
|
||||
entry(s) := {
|
||||
[
|
||||
integer: x; integer: x
|
||||
]
|
||||
return x;
|
||||
}
|
11
tests/carl/NoErrors/entry.duplicateSame.alpha.asc
Normal file
11
tests/carl/NoErrors/entry.duplicateSame.alpha.asc
Normal file
@ -0,0 +1,11 @@
|
||||
alpha parser, version 0.2 (2023-03-04) - Annotated Source Code for file entry.duplicateSame.alpha
|
||||
001: type M : string -> integer
|
||||
002: function entry : M
|
||||
003:
|
||||
004: entry(s) := {
|
||||
005: [
|
||||
006: integer: x; integer: x
|
||||
007: ]
|
||||
008: return x;
|
||||
009: }
|
||||
010:
|
11
tests/carl/NoErrors/entry.local.alpha
Normal file
11
tests/carl/NoErrors/entry.local.alpha
Normal file
@ -0,0 +1,11 @@
|
||||
type M : string -> integer
|
||||
|
||||
function entry : M
|
||||
|
||||
entry(s) := {
|
||||
[
|
||||
integer: x
|
||||
]
|
||||
x := 0;
|
||||
return x;
|
||||
}
|
13
tests/carl/NoErrors/entry.local.alpha.asc
Normal file
13
tests/carl/NoErrors/entry.local.alpha.asc
Normal file
@ -0,0 +1,13 @@
|
||||
alpha parser, version 0.2 (2023-03-04) - Annotated Source Code for file entry.local.alpha
|
||||
001: type M : string -> integer
|
||||
002:
|
||||
003: function entry : M
|
||||
004:
|
||||
005: entry(s) := {
|
||||
006: [
|
||||
007: integer: x
|
||||
008: ]
|
||||
009: x := 0;
|
||||
010: return x;
|
||||
011: }
|
||||
012:
|
14
tests/carl/NoErrors/error.none.alpha
Normal file
14
tests/carl/NoErrors/error.none.alpha
Normal file
@ -0,0 +1,14 @@
|
||||
type string2int: string -> integer
|
||||
|
||||
function entry : string2int
|
||||
|
||||
entry(arg) := {
|
||||
[ integer: i ; integer: sum ]
|
||||
sum := 0;
|
||||
i := 0 ;
|
||||
while (i < 10) {
|
||||
sum := sum + i;
|
||||
i := i + 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
16
tests/carl/NoErrors/error.none.alpha.asc
Normal file
16
tests/carl/NoErrors/error.none.alpha.asc
Normal file
@ -0,0 +1,16 @@
|
||||
alpha parser, version 0.2 (2023-03-04) - Annotated Source Code for file error.none.alpha
|
||||
001: type string2int: string -> integer
|
||||
002:
|
||||
003: function entry : string2int
|
||||
004:
|
||||
005: entry(arg) := {
|
||||
006: [ integer: i ; integer: sum ]
|
||||
007: sum := 0;
|
||||
008: i := 0 ;
|
||||
009: while (i < 10) {
|
||||
010: sum := sum + i;
|
||||
011: i := i + 1;
|
||||
012: }
|
||||
013: return 0;
|
||||
014: }
|
||||
015:
|
3
tests/carl/NoErrors/function.declaration.alpha
Normal file
3
tests/carl/NoErrors/function.declaration.alpha
Normal file
@ -0,0 +1,3 @@
|
||||
type M : integer -> integer
|
||||
|
||||
function f : M
|
5
tests/carl/NoErrors/function.declaration.alpha.asc
Normal file
5
tests/carl/NoErrors/function.declaration.alpha.asc
Normal file
@ -0,0 +1,5 @@
|
||||
alpha parser, version 0.2 (2023-03-04) - Annotated Source Code for file function.declaration.alpha
|
||||
001: type M : integer -> integer
|
||||
002:
|
||||
003: function f : M
|
||||
004:
|
7
tests/carl/NoErrors/function.definition.alpha
Normal file
7
tests/carl/NoErrors/function.definition.alpha
Normal file
@ -0,0 +1,7 @@
|
||||
type M : integer -> integer
|
||||
|
||||
function f : M
|
||||
|
||||
f(x) := {
|
||||
return x;
|
||||
}
|
9
tests/carl/NoErrors/function.definition.alpha.asc
Normal file
9
tests/carl/NoErrors/function.definition.alpha.asc
Normal file
@ -0,0 +1,9 @@
|
||||
alpha parser, version 0.2 (2023-03-04) - Annotated Source Code for file function.definition.alpha
|
||||
001: type M : integer -> integer
|
||||
002:
|
||||
003: function f : M
|
||||
004:
|
||||
005: f(x) := {
|
||||
006: return x;
|
||||
007: }
|
||||
008:
|
73
tests/carl/NoErrors/functionValue.alpha
Normal file
73
tests/carl/NoErrors/functionValue.alpha
Normal file
@ -0,0 +1,73 @@
|
||||
(* Type definitions *)
|
||||
|
||||
(* mapping type *)
|
||||
type string2int: string -> integer
|
||||
|
||||
(* array of functions *)
|
||||
type funArray: 1 -> string2int
|
||||
|
||||
(* record of functions *)
|
||||
type funRec: [ string2int: f; string2int: g ]
|
||||
|
||||
(* function returning function *)
|
||||
type integer_2_string2int: integer -> string2int
|
||||
|
||||
(* function returning function *)
|
||||
type string2int_2_integer: string2int -> integer
|
||||
|
||||
|
||||
type iXiXc: [integer: a; integer: b; character: c]
|
||||
|
||||
type iic2b: iXiXc -> Boolean
|
||||
|
||||
(* Function declarations using the above type definitions *)
|
||||
function a: string2int
|
||||
function b: integer_2_string2int
|
||||
function c: string2int_2_integer
|
||||
|
||||
function d: iic2b
|
||||
|
||||
d(x,y,z) := {
|
||||
return (x < y & z < 'm');
|
||||
}
|
||||
|
||||
function entry: string2int
|
||||
|
||||
a(x) := {
|
||||
[string : s]
|
||||
s := x;
|
||||
return 0;
|
||||
}
|
||||
|
||||
b(x) := {
|
||||
[integer: i]
|
||||
i := x;
|
||||
return a;
|
||||
}
|
||||
|
||||
c(x) := {
|
||||
[string: s]
|
||||
s := "Hi!";
|
||||
return x(s);
|
||||
}
|
||||
|
||||
|
||||
(* Function definition
|
||||
entry is the first function called
|
||||
*)
|
||||
entry(arg) := {
|
||||
[integer: result; string2int: f; integer: temp]
|
||||
temp := a("Hello");
|
||||
f := b(temp);
|
||||
result := c(f);
|
||||
if (d(1,2,'c'))
|
||||
then {
|
||||
result := 0;
|
||||
}
|
||||
else {
|
||||
[ Boolean : b]
|
||||
result := entry("hello");
|
||||
}
|
||||
result := c(f);
|
||||
return result;
|
||||
}
|
75
tests/carl/NoErrors/functionValue.alpha.asc
Normal file
75
tests/carl/NoErrors/functionValue.alpha.asc
Normal file
@ -0,0 +1,75 @@
|
||||
alpha parser, version 0.2 (2023-03-04) - Annotated Source Code for file functionValue.alpha
|
||||
001: (* Type definitions *)
|
||||
002:
|
||||
003: (* mapping type *)
|
||||
004: type string2int: string -> integer
|
||||
005:
|
||||
006: (* array of functions *)
|
||||
007: type funArray: 1 -> string2int
|
||||
008:
|
||||
009: (* record of functions *)
|
||||
010: type funRec: [ string2int: f; string2int: g ]
|
||||
011:
|
||||
012: (* function returning function *)
|
||||
013: type integer_2_string2int: integer -> string2int
|
||||
014:
|
||||
015: (* function returning function *)
|
||||
016: type string2int_2_integer: string2int -> integer
|
||||
017:
|
||||
018:
|
||||
019: type iXiXc: [integer: a; integer: b; character: c]
|
||||
020:
|
||||
021: type iic2b: iXiXc -> Boolean
|
||||
022:
|
||||
023: (* Function declarations using the above type definitions *)
|
||||
024: function a: string2int
|
||||
025: function b: integer_2_string2int
|
||||
026: function c: string2int_2_integer
|
||||
027:
|
||||
028: function d: iic2b
|
||||
029:
|
||||
030: d(x,y,z) := {
|
||||
031: return (x < y & z < 'm');
|
||||
032: }
|
||||
033:
|
||||
034: function entry: string2int
|
||||
035:
|
||||
036: a(x) := {
|
||||
037: [string : s]
|
||||
038: s := x;
|
||||
039: return 0;
|
||||
040: }
|
||||
041:
|
||||
042: b(x) := {
|
||||
043: [integer: i]
|
||||
044: i := x;
|
||||
045: return a;
|
||||
046: }
|
||||
047:
|
||||
048: c(x) := {
|
||||
049: [string: s]
|
||||
050: s := "Hi!";
|
||||
051: return x(s);
|
||||
052: }
|
||||
053:
|
||||
054:
|
||||
055: (* Function definition
|
||||
056: entry is the first function called
|
||||
057: *)
|
||||
058: entry(arg) := {
|
||||
059: [integer: result; string2int: f; integer: temp]
|
||||
060: temp := a("Hello");
|
||||
061: f := b(temp);
|
||||
062: result := c(f);
|
||||
063: if (d(1,2,'c'))
|
||||
064: then {
|
||||
065: result := 0;
|
||||
066: }
|
||||
067: else {
|
||||
068: [ Boolean : b]
|
||||
069: result := entry("hello");
|
||||
070: }
|
||||
071: result := c(f);
|
||||
072: return result;
|
||||
073: }
|
||||
074:
|
29
tests/carl/NoErrors/sample.good.alpha
Normal file
29
tests/carl/NoErrors/sample.good.alpha
Normal file
@ -0,0 +1,29 @@
|
||||
|
||||
(* Type definitions *)
|
||||
type int2int: integer -> integer
|
||||
type string2int: string -> integer
|
||||
|
||||
(* Function declarations
|
||||
They use the above type definitions
|
||||
*)
|
||||
function square : int2int
|
||||
function entry : string2int
|
||||
|
||||
(* Function definition
|
||||
Functions must be declared before they are defined
|
||||
*)
|
||||
square(x) := {
|
||||
return x * x;
|
||||
}
|
||||
|
||||
(* Function definition
|
||||
entry is the first function called
|
||||
*)
|
||||
entry(arg) := {
|
||||
[ integer: input ; integer: expected ; integer: actual ; Boolean: result ]
|
||||
input := 7;
|
||||
expected := 49;
|
||||
actual := square(input);
|
||||
result := expected = actual;
|
||||
return 0;
|
||||
}
|
31
tests/carl/NoErrors/sample.good.alpha.asc
Normal file
31
tests/carl/NoErrors/sample.good.alpha.asc
Normal file
@ -0,0 +1,31 @@
|
||||
alpha parser, version 0.2 (2023-03-04) - Annotated Source Code for file sample.good.alpha
|
||||
001:
|
||||
001: (* Type definitions *)
|
||||
003: type int2int: integer -> integer
|
||||
004: type string2int: string -> integer
|
||||
005:
|
||||
006: (* Function declarations
|
||||
007: They use the above type definitions
|
||||
008: *)
|
||||
009: function square : int2int
|
||||
010: function entry : string2int
|
||||
011:
|
||||
012: (* Function definition
|
||||
013: Functions must be declared before they are defined
|
||||
014: *)
|
||||
015: square(x) := {
|
||||
016: return x * x;
|
||||
017: }
|
||||
018:
|
||||
019: (* Function definition
|
||||
020: entry is the first function called
|
||||
021: *)
|
||||
022: entry(arg) := {
|
||||
023: [ integer: input ; integer: expected ; integer: actual ; Boolean: result ]
|
||||
024: input := 7;
|
||||
025: expected := 49;
|
||||
026: actual := square(input);
|
||||
027: result := expected = actual;
|
||||
028: return 0;
|
||||
029: }
|
||||
030:
|
68
tests/carl/NoErrors/selectionSort.alpha
Normal file
68
tests/carl/NoErrors/selectionSort.alpha
Normal file
@ -0,0 +1,68 @@
|
||||
(* Type definitions *)
|
||||
|
||||
type string2int: string -> integer
|
||||
type intArray: 1 -> integer
|
||||
type intArrayXinteger: [ intArray: data; integer: index ]
|
||||
type intArrayXinteger2integer: intArrayXinteger -> integer
|
||||
type intArray2Boolean: intArray -> Boolean
|
||||
|
||||
|
||||
(* Function declarations
|
||||
They use the above type definitions
|
||||
*)
|
||||
function indexOfSmallest: intArrayXinteger2integer
|
||||
function selectionSort: intArray2Boolean
|
||||
function entry : string2int
|
||||
|
||||
(* indexOfSmallest *)
|
||||
indexOfSmallest (* as *) (data, startingIndex) := {
|
||||
[ integer: indexOfSmallestSoFar; integer: i ]
|
||||
indexOfSmallestSoFar := startingIndex;
|
||||
i := 0 ;
|
||||
while (i < data._1 ) {
|
||||
if ( data(i) < data(indexOfSmallestSoFar) )
|
||||
then {
|
||||
indexOfSmallestSoFar := i;
|
||||
}
|
||||
else {
|
||||
i := i;
|
||||
}
|
||||
i := i + 1;
|
||||
}
|
||||
return indexOfSmallestSoFar;
|
||||
}
|
||||
|
||||
|
||||
(* selectionSort *)
|
||||
selectionSort(data) := {
|
||||
[ integer: i ]
|
||||
i := 0 ;
|
||||
while (i < data._1 ) {
|
||||
[ integer: index; integer: temp ]
|
||||
index := indexOfSmallest(data,i);
|
||||
temp := data(index);
|
||||
data(index) := data(i);
|
||||
data(i) := temp;
|
||||
i := i + 1;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
(* Function definition
|
||||
entry is the first function called
|
||||
*)
|
||||
entry(arg) := {
|
||||
[ intArray: data; Boolean: _ ]
|
||||
data := reserve data(8);
|
||||
data(0) := 60;
|
||||
data(1) := 80;
|
||||
data(2) := 10;
|
||||
data(3) := 50;
|
||||
data(4) := 30;
|
||||
data(5) := 40;
|
||||
data(6) := 20;
|
||||
data(7) := 70;
|
||||
_ := selectionSort(data);
|
||||
return 0;
|
||||
}
|
70
tests/carl/NoErrors/selectionSort.alpha.asc
Normal file
70
tests/carl/NoErrors/selectionSort.alpha.asc
Normal file
@ -0,0 +1,70 @@
|
||||
alpha parser, version 0.2 (2023-03-04) - Annotated Source Code for file selectionSort.alpha
|
||||
001: (* Type definitions *)
|
||||
002:
|
||||
003: type string2int: string -> integer
|
||||
004: type intArray: 1 -> integer
|
||||
005: type intArrayXinteger: [ intArray: data; integer: index ]
|
||||
006: type intArrayXinteger2integer: intArrayXinteger -> integer
|
||||
007: type intArray2Boolean: intArray -> Boolean
|
||||
008:
|
||||
009:
|
||||
010: (* Function declarations
|
||||
011: They use the above type definitions
|
||||
012: *)
|
||||
013: function indexOfSmallest: intArrayXinteger2integer
|
||||
014: function selectionSort: intArray2Boolean
|
||||
015: function entry : string2int
|
||||
016:
|
||||
017: (* indexOfSmallest *)
|
||||
018: indexOfSmallest (* as *) (data, startingIndex) := {
|
||||
019: [ integer: indexOfSmallestSoFar; integer: i ]
|
||||
020: indexOfSmallestSoFar := startingIndex;
|
||||
021: i := 0 ;
|
||||
022: while (i < data._1 ) {
|
||||
023: if ( data(i) < data(indexOfSmallestSoFar) )
|
||||
024: then {
|
||||
025: indexOfSmallestSoFar := i;
|
||||
026: }
|
||||
027: else {
|
||||
028: i := i;
|
||||
029: }
|
||||
030: i := i + 1;
|
||||
031: }
|
||||
032: return indexOfSmallestSoFar;
|
||||
033: }
|
||||
034:
|
||||
035:
|
||||
036: (* selectionSort *)
|
||||
037: selectionSort(data) := {
|
||||
038: [ integer: i ]
|
||||
039: i := 0 ;
|
||||
040: while (i < data._1 ) {
|
||||
041: [ integer: index; integer: temp ]
|
||||
042: index := indexOfSmallest(data,i);
|
||||
043: temp := data(index);
|
||||
044: data(index) := data(i);
|
||||
045: data(i) := temp;
|
||||
046: i := i + 1;
|
||||
047: }
|
||||
048: return true;
|
||||
049: }
|
||||
050:
|
||||
051:
|
||||
052: (* Function definition
|
||||
053: entry is the first function called
|
||||
054: *)
|
||||
055: entry(arg) := {
|
||||
056: [ intArray: data; Boolean: _ ]
|
||||
057: data := reserve data(8);
|
||||
058: data(0) := 60;
|
||||
059: data(1) := 80;
|
||||
060: data(2) := 10;
|
||||
061: data(3) := 50;
|
||||
062: data(4) := 30;
|
||||
063: data(5) := 40;
|
||||
064: data(6) := 20;
|
||||
065: data(7) := 70;
|
||||
066: _ := selectionSort(data);
|
||||
067: return 0;
|
||||
068: }
|
||||
069:
|
1
tests/carl/NoErrors/type.array.alpha
Normal file
1
tests/carl/NoErrors/type.array.alpha
Normal file
@ -0,0 +1 @@
|
||||
type A : 1 -> integer
|
3
tests/carl/NoErrors/type.array.alpha.asc
Normal file
3
tests/carl/NoErrors/type.array.alpha.asc
Normal file
@ -0,0 +1,3 @@
|
||||
alpha parser, version 0.2 (2023-03-04) - Annotated Source Code for file type.array.alpha
|
||||
001: type A : 1 -> integer
|
||||
002:
|
2
tests/carl/NoErrors/type.mapping.alpha
Normal file
2
tests/carl/NoErrors/type.mapping.alpha
Normal file
@ -0,0 +1,2 @@
|
||||
type M : integer -> character
|
||||
|
4
tests/carl/NoErrors/type.mapping.alpha.asc
Normal file
4
tests/carl/NoErrors/type.mapping.alpha.asc
Normal file
@ -0,0 +1,4 @@
|
||||
alpha parser, version 0.2 (2023-03-04) - Annotated Source Code for file type.mapping.alpha
|
||||
001: type M : integer -> character
|
||||
002:
|
||||
003:
|
1
tests/carl/NoErrors/type.record.alpha
Normal file
1
tests/carl/NoErrors/type.record.alpha
Normal file
@ -0,0 +1 @@
|
||||
type R : [ integer : i ; character : c ]
|
3
tests/carl/NoErrors/type.record.alpha.asc
Normal file
3
tests/carl/NoErrors/type.record.alpha.asc
Normal file
@ -0,0 +1,3 @@
|
||||
alpha parser, version 0.2 (2023-03-04) - Annotated Source Code for file type.record.alpha
|
||||
001: type R : [ integer : i ; character : c ]
|
||||
002:
|
75
tests/carl/NoErrors/types.alpha
Normal file
75
tests/carl/NoErrors/types.alpha
Normal file
@ -0,0 +1,75 @@
|
||||
(*
|
||||
|
||||
At compiler start-up your program should
|
||||
create symbol table entries for the following
|
||||
built-in types:
|
||||
|
||||
Boolean (1 byte)
|
||||
character (1 byte)
|
||||
integer (4 bytes)
|
||||
address (8 bytes)
|
||||
|
||||
and the following privileged type (it has literals):
|
||||
|
||||
type string: 1 -> character
|
||||
|
||||
Your compiler can define other types during
|
||||
its start-up routine as well, if it is helpful
|
||||
to do so.
|
||||
|
||||
*)
|
||||
|
||||
|
||||
|
||||
type BooleanXBoolean: [Boolean: x; Boolean: y]
|
||||
type characterXcharacter: [character: x; character: y]
|
||||
type integerXinteger: [integer: x; integer: y]
|
||||
|
||||
type Boolean2Boolean: Boolean -> Boolean
|
||||
type integer2integer: integer -> integer
|
||||
|
||||
type character2integer: character -> integer
|
||||
type Boolean2integer: Boolean -> integer
|
||||
type string2integer: string -> integer
|
||||
|
||||
type integerXinteger2integer: integerXinteger -> integer
|
||||
|
||||
type integerXinteger2Boolean: integerXinteger -> Boolean
|
||||
type characterXcharacter2Boolean: characterXcharacter -> Boolean
|
||||
type BooleanXBoolean2Boolean: BooleanXBoolean -> Boolean
|
||||
|
||||
|
||||
type integer2address: integer -> address
|
||||
type address2integer: address -> integer
|
||||
|
||||
|
||||
(* The alpha library functions
|
||||
You will be provided with x86-64 assembly
|
||||
code implementations of these.
|
||||
*)
|
||||
|
||||
external function printInteger: integer2integer
|
||||
external function printCharacter: character2integer
|
||||
external function printBoolean: Boolean2integer
|
||||
|
||||
(*
|
||||
A declaration of the entry point function for your program
|
||||
|
||||
You may assume that when starting this function will behave as if
|
||||
it had been called from the C language main function like this:
|
||||
|
||||
int main(int argc, char * argv[]) {
|
||||
if (argc == 1) {
|
||||
return entry(NULL);
|
||||
}
|
||||
else {
|
||||
return entry(makeAlphaString(argv[1]));
|
||||
}
|
||||
}
|
||||
|
||||
for some suitable definition of makeAlphaString which creates
|
||||
an alpha string representation of its argument C string in memory
|
||||
and returns a pointer to that alpha string.
|
||||
*)
|
||||
|
||||
function entry: string2integer
|
77
tests/carl/NoErrors/types.alpha.asc
Normal file
77
tests/carl/NoErrors/types.alpha.asc
Normal file
@ -0,0 +1,77 @@
|
||||
alpha parser, version 0.2 (2023-03-04) - Annotated Source Code for file types.alpha
|
||||
001: (*
|
||||
001:
|
||||
002: At compiler start-up your program should
|
||||
003: create symbol table entries for the following
|
||||
004: built-in types:
|
||||
005:
|
||||
006: Boolean (1 byte)
|
||||
007: character (1 byte)
|
||||
008: integer (4 bytes)
|
||||
009: address (8 bytes)
|
||||
010:
|
||||
011: and the following privileged type (it has literals):
|
||||
012:
|
||||
013: type string: 1 -> character
|
||||
014:
|
||||
015: Your compiler can define other types during
|
||||
016: its start-up routine as well, if it is helpful
|
||||
017: to do so.
|
||||
018:
|
||||
019: *)
|
||||
021:
|
||||
022:
|
||||
023:
|
||||
024: type BooleanXBoolean: [Boolean: x; Boolean: y]
|
||||
025: type characterXcharacter: [character: x; character: y]
|
||||
026: type integerXinteger: [integer: x; integer: y]
|
||||
027:
|
||||
028: type Boolean2Boolean: Boolean -> Boolean
|
||||
029: type integer2integer: integer -> integer
|
||||
030:
|
||||
031: type character2integer: character -> integer
|
||||
032: type Boolean2integer: Boolean -> integer
|
||||
033: type string2integer: string -> integer
|
||||
034:
|
||||
035: type integerXinteger2integer: integerXinteger -> integer
|
||||
036:
|
||||
037: type integerXinteger2Boolean: integerXinteger -> Boolean
|
||||
038: type characterXcharacter2Boolean: characterXcharacter -> Boolean
|
||||
039: type BooleanXBoolean2Boolean: BooleanXBoolean -> Boolean
|
||||
040:
|
||||
041:
|
||||
042: type integer2address: integer -> address
|
||||
043: type address2integer: address -> integer
|
||||
044:
|
||||
045:
|
||||
046: (* The alpha library functions
|
||||
047: You will be provided with x86-64 assembly
|
||||
048: code implementations of these.
|
||||
049: *)
|
||||
050:
|
||||
051: external function printInteger: integer2integer
|
||||
052: external function printCharacter: character2integer
|
||||
053: external function printBoolean: Boolean2integer
|
||||
054:
|
||||
055: (*
|
||||
056: A declaration of the entry point function for your program
|
||||
057:
|
||||
058: You may assume that when starting this function will behave as if
|
||||
059: it had been called from the C language main function like this:
|
||||
060:
|
||||
061: int main(int argc, char * argv[]) {
|
||||
062: if (argc == 1) {
|
||||
063: return entry(NULL);
|
||||
064: }
|
||||
065: else {
|
||||
066: return entry(makeAlphaString(argv[1]));
|
||||
067: }
|
||||
068: }
|
||||
069:
|
||||
070: for some suitable definition of makeAlphaString which creates
|
||||
071: an alpha string representation of its argument C string in memory
|
||||
072: and returns a pointer to that alpha string.
|
||||
073: *)
|
||||
074:
|
||||
075: function entry: string2integer
|
||||
076:
|
Reference in New Issue
Block a user