From c091927fe7e9aa778e5a4dc6276af1f45a34d79f Mon Sep 17 00:00:00 2001 From: Scarlett Date: Tue, 15 Apr 2025 14:46:00 -0400 Subject: [PATCH] carl --- tests/carl/Errors/entry.undeclaredType.alpha | 10 +++ .../Errors/entry.undeclaredType.alpha.asc | 16 ++++ tests/carl/Errors/entry.undeclaredVar.alpha | 7 ++ .../carl/Errors/entry.undeclaredVar.alpha.asc | 12 +++ tests/carl/Errors/error.operator.alpha | 14 ++++ tests/carl/Errors/error.operator.alpha.asc | 19 +++++ tests/carl/NoErrors/entry.definition.alpha | 8 ++ .../carl/NoErrors/entry.definition.alpha.asc | 10 +++ .../NoErrors/entry.duplicateDifferent.alpha | 11 +++ .../entry.duplicateDifferent.alpha.asc | 13 ++++ tests/carl/NoErrors/entry.duplicateSame.alpha | 9 +++ .../NoErrors/entry.duplicateSame.alpha.asc | 11 +++ tests/carl/NoErrors/entry.local.alpha | 11 +++ tests/carl/NoErrors/entry.local.alpha.asc | 13 ++++ tests/carl/NoErrors/error.none.alpha | 14 ++++ tests/carl/NoErrors/error.none.alpha.asc | 16 ++++ .../carl/NoErrors/function.declaration.alpha | 3 + .../NoErrors/function.declaration.alpha.asc | 5 ++ tests/carl/NoErrors/function.definition.alpha | 7 ++ .../NoErrors/function.definition.alpha.asc | 9 +++ tests/carl/NoErrors/functionValue.alpha | 73 ++++++++++++++++++ tests/carl/NoErrors/functionValue.alpha.asc | 75 ++++++++++++++++++ tests/carl/NoErrors/sample.good.alpha | 29 +++++++ tests/carl/NoErrors/sample.good.alpha.asc | 31 ++++++++ tests/carl/NoErrors/selectionSort.alpha | 68 ++++++++++++++++ tests/carl/NoErrors/selectionSort.alpha.asc | 70 +++++++++++++++++ tests/carl/NoErrors/type.array.alpha | 1 + tests/carl/NoErrors/type.array.alpha.asc | 3 + tests/carl/NoErrors/type.mapping.alpha | 2 + tests/carl/NoErrors/type.mapping.alpha.asc | 4 + tests/carl/NoErrors/type.record.alpha | 1 + tests/carl/NoErrors/type.record.alpha.asc | 3 + tests/carl/NoErrors/types.alpha | 75 ++++++++++++++++++ tests/carl/NoErrors/types.alpha.asc | 77 +++++++++++++++++++ 34 files changed, 730 insertions(+) create mode 100644 tests/carl/Errors/entry.undeclaredType.alpha create mode 100644 tests/carl/Errors/entry.undeclaredType.alpha.asc create mode 100644 tests/carl/Errors/entry.undeclaredVar.alpha create mode 100644 tests/carl/Errors/entry.undeclaredVar.alpha.asc create mode 100644 tests/carl/Errors/error.operator.alpha create mode 100644 tests/carl/Errors/error.operator.alpha.asc create mode 100644 tests/carl/NoErrors/entry.definition.alpha create mode 100644 tests/carl/NoErrors/entry.definition.alpha.asc create mode 100644 tests/carl/NoErrors/entry.duplicateDifferent.alpha create mode 100644 tests/carl/NoErrors/entry.duplicateDifferent.alpha.asc create mode 100644 tests/carl/NoErrors/entry.duplicateSame.alpha create mode 100644 tests/carl/NoErrors/entry.duplicateSame.alpha.asc create mode 100644 tests/carl/NoErrors/entry.local.alpha create mode 100644 tests/carl/NoErrors/entry.local.alpha.asc create mode 100644 tests/carl/NoErrors/error.none.alpha create mode 100644 tests/carl/NoErrors/error.none.alpha.asc create mode 100644 tests/carl/NoErrors/function.declaration.alpha create mode 100644 tests/carl/NoErrors/function.declaration.alpha.asc create mode 100644 tests/carl/NoErrors/function.definition.alpha create mode 100644 tests/carl/NoErrors/function.definition.alpha.asc create mode 100644 tests/carl/NoErrors/functionValue.alpha create mode 100644 tests/carl/NoErrors/functionValue.alpha.asc create mode 100644 tests/carl/NoErrors/sample.good.alpha create mode 100644 tests/carl/NoErrors/sample.good.alpha.asc create mode 100644 tests/carl/NoErrors/selectionSort.alpha create mode 100644 tests/carl/NoErrors/selectionSort.alpha.asc create mode 100644 tests/carl/NoErrors/type.array.alpha create mode 100644 tests/carl/NoErrors/type.array.alpha.asc create mode 100644 tests/carl/NoErrors/type.mapping.alpha create mode 100644 tests/carl/NoErrors/type.mapping.alpha.asc create mode 100644 tests/carl/NoErrors/type.record.alpha create mode 100644 tests/carl/NoErrors/type.record.alpha.asc create mode 100644 tests/carl/NoErrors/types.alpha create mode 100644 tests/carl/NoErrors/types.alpha.asc diff --git a/tests/carl/Errors/entry.undeclaredType.alpha b/tests/carl/Errors/entry.undeclaredType.alpha new file mode 100644 index 0000000..6b9531f --- /dev/null +++ b/tests/carl/Errors/entry.undeclaredType.alpha @@ -0,0 +1,10 @@ +type M : string -> integer + +function foo : M + +foo (s) := { + [ + int: x + ] + return 0; +} diff --git a/tests/carl/Errors/entry.undeclaredType.alpha.asc b/tests/carl/Errors/entry.undeclaredType.alpha.asc new file mode 100644 index 0000000..cd1d37c --- /dev/null +++ b/tests/carl/Errors/entry.undeclaredType.alpha.asc @@ -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: diff --git a/tests/carl/Errors/entry.undeclaredVar.alpha b/tests/carl/Errors/entry.undeclaredVar.alpha new file mode 100644 index 0000000..6cd5fa7 --- /dev/null +++ b/tests/carl/Errors/entry.undeclaredVar.alpha @@ -0,0 +1,7 @@ +type M : string -> integer + +function entry : M + +entry(s) := { + return x; +} diff --git a/tests/carl/Errors/entry.undeclaredVar.alpha.asc b/tests/carl/Errors/entry.undeclaredVar.alpha.asc new file mode 100644 index 0000000..7c4e6c2 --- /dev/null +++ b/tests/carl/Errors/entry.undeclaredVar.alpha.asc @@ -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: diff --git a/tests/carl/Errors/error.operator.alpha b/tests/carl/Errors/error.operator.alpha new file mode 100644 index 0000000..a7b0691 --- /dev/null +++ b/tests/carl/Errors/error.operator.alpha @@ -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; +} diff --git a/tests/carl/Errors/error.operator.alpha.asc b/tests/carl/Errors/error.operator.alpha.asc new file mode 100644 index 0000000..82f5614 --- /dev/null +++ b/tests/carl/Errors/error.operator.alpha.asc @@ -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: diff --git a/tests/carl/NoErrors/entry.definition.alpha b/tests/carl/NoErrors/entry.definition.alpha new file mode 100644 index 0000000..0003cd5 --- /dev/null +++ b/tests/carl/NoErrors/entry.definition.alpha @@ -0,0 +1,8 @@ +(* type string : 1 -> character *) +type M : string -> integer + +function entry : M + +entry(s) := { + return 0; +} diff --git a/tests/carl/NoErrors/entry.definition.alpha.asc b/tests/carl/NoErrors/entry.definition.alpha.asc new file mode 100644 index 0000000..07dbd42 --- /dev/null +++ b/tests/carl/NoErrors/entry.definition.alpha.asc @@ -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: diff --git a/tests/carl/NoErrors/entry.duplicateDifferent.alpha b/tests/carl/NoErrors/entry.duplicateDifferent.alpha new file mode 100644 index 0000000..5cbd668 --- /dev/null +++ b/tests/carl/NoErrors/entry.duplicateDifferent.alpha @@ -0,0 +1,11 @@ +type M : string -> integer + +function entry : M + +entry(s) := { + [ + integer: x; + character: x + ] + return x; +} diff --git a/tests/carl/NoErrors/entry.duplicateDifferent.alpha.asc b/tests/carl/NoErrors/entry.duplicateDifferent.alpha.asc new file mode 100644 index 0000000..65ae8d8 --- /dev/null +++ b/tests/carl/NoErrors/entry.duplicateDifferent.alpha.asc @@ -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: diff --git a/tests/carl/NoErrors/entry.duplicateSame.alpha b/tests/carl/NoErrors/entry.duplicateSame.alpha new file mode 100644 index 0000000..554b9d8 --- /dev/null +++ b/tests/carl/NoErrors/entry.duplicateSame.alpha @@ -0,0 +1,9 @@ +type M : string -> integer +function entry : M + +entry(s) := { + [ + integer: x; integer: x + ] + return x; +} diff --git a/tests/carl/NoErrors/entry.duplicateSame.alpha.asc b/tests/carl/NoErrors/entry.duplicateSame.alpha.asc new file mode 100644 index 0000000..7861cc6 --- /dev/null +++ b/tests/carl/NoErrors/entry.duplicateSame.alpha.asc @@ -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: diff --git a/tests/carl/NoErrors/entry.local.alpha b/tests/carl/NoErrors/entry.local.alpha new file mode 100644 index 0000000..cff2062 --- /dev/null +++ b/tests/carl/NoErrors/entry.local.alpha @@ -0,0 +1,11 @@ +type M : string -> integer + +function entry : M + +entry(s) := { + [ + integer: x + ] + x := 0; + return x; +} diff --git a/tests/carl/NoErrors/entry.local.alpha.asc b/tests/carl/NoErrors/entry.local.alpha.asc new file mode 100644 index 0000000..e9882d4 --- /dev/null +++ b/tests/carl/NoErrors/entry.local.alpha.asc @@ -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: diff --git a/tests/carl/NoErrors/error.none.alpha b/tests/carl/NoErrors/error.none.alpha new file mode 100644 index 0000000..85aa4f2 --- /dev/null +++ b/tests/carl/NoErrors/error.none.alpha @@ -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; +} diff --git a/tests/carl/NoErrors/error.none.alpha.asc b/tests/carl/NoErrors/error.none.alpha.asc new file mode 100644 index 0000000..9fdcadb --- /dev/null +++ b/tests/carl/NoErrors/error.none.alpha.asc @@ -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: diff --git a/tests/carl/NoErrors/function.declaration.alpha b/tests/carl/NoErrors/function.declaration.alpha new file mode 100644 index 0000000..69f210f --- /dev/null +++ b/tests/carl/NoErrors/function.declaration.alpha @@ -0,0 +1,3 @@ +type M : integer -> integer + +function f : M diff --git a/tests/carl/NoErrors/function.declaration.alpha.asc b/tests/carl/NoErrors/function.declaration.alpha.asc new file mode 100644 index 0000000..fca046a --- /dev/null +++ b/tests/carl/NoErrors/function.declaration.alpha.asc @@ -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: diff --git a/tests/carl/NoErrors/function.definition.alpha b/tests/carl/NoErrors/function.definition.alpha new file mode 100644 index 0000000..b729610 --- /dev/null +++ b/tests/carl/NoErrors/function.definition.alpha @@ -0,0 +1,7 @@ +type M : integer -> integer + +function f : M + +f(x) := { + return x; +} diff --git a/tests/carl/NoErrors/function.definition.alpha.asc b/tests/carl/NoErrors/function.definition.alpha.asc new file mode 100644 index 0000000..e476758 --- /dev/null +++ b/tests/carl/NoErrors/function.definition.alpha.asc @@ -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: diff --git a/tests/carl/NoErrors/functionValue.alpha b/tests/carl/NoErrors/functionValue.alpha new file mode 100644 index 0000000..f521a42 --- /dev/null +++ b/tests/carl/NoErrors/functionValue.alpha @@ -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; +} diff --git a/tests/carl/NoErrors/functionValue.alpha.asc b/tests/carl/NoErrors/functionValue.alpha.asc new file mode 100644 index 0000000..882d558 --- /dev/null +++ b/tests/carl/NoErrors/functionValue.alpha.asc @@ -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: diff --git a/tests/carl/NoErrors/sample.good.alpha b/tests/carl/NoErrors/sample.good.alpha new file mode 100644 index 0000000..8a8b727 --- /dev/null +++ b/tests/carl/NoErrors/sample.good.alpha @@ -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; +} diff --git a/tests/carl/NoErrors/sample.good.alpha.asc b/tests/carl/NoErrors/sample.good.alpha.asc new file mode 100644 index 0000000..a4bfa3a --- /dev/null +++ b/tests/carl/NoErrors/sample.good.alpha.asc @@ -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: diff --git a/tests/carl/NoErrors/selectionSort.alpha b/tests/carl/NoErrors/selectionSort.alpha new file mode 100644 index 0000000..edd2076 --- /dev/null +++ b/tests/carl/NoErrors/selectionSort.alpha @@ -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; +} diff --git a/tests/carl/NoErrors/selectionSort.alpha.asc b/tests/carl/NoErrors/selectionSort.alpha.asc new file mode 100644 index 0000000..2a12877 --- /dev/null +++ b/tests/carl/NoErrors/selectionSort.alpha.asc @@ -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: diff --git a/tests/carl/NoErrors/type.array.alpha b/tests/carl/NoErrors/type.array.alpha new file mode 100644 index 0000000..2b04ba0 --- /dev/null +++ b/tests/carl/NoErrors/type.array.alpha @@ -0,0 +1 @@ +type A : 1 -> integer diff --git a/tests/carl/NoErrors/type.array.alpha.asc b/tests/carl/NoErrors/type.array.alpha.asc new file mode 100644 index 0000000..8e6154d --- /dev/null +++ b/tests/carl/NoErrors/type.array.alpha.asc @@ -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: diff --git a/tests/carl/NoErrors/type.mapping.alpha b/tests/carl/NoErrors/type.mapping.alpha new file mode 100644 index 0000000..8b6bc50 --- /dev/null +++ b/tests/carl/NoErrors/type.mapping.alpha @@ -0,0 +1,2 @@ +type M : integer -> character + diff --git a/tests/carl/NoErrors/type.mapping.alpha.asc b/tests/carl/NoErrors/type.mapping.alpha.asc new file mode 100644 index 0000000..2ce8f0c --- /dev/null +++ b/tests/carl/NoErrors/type.mapping.alpha.asc @@ -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: diff --git a/tests/carl/NoErrors/type.record.alpha b/tests/carl/NoErrors/type.record.alpha new file mode 100644 index 0000000..2c5e9c9 --- /dev/null +++ b/tests/carl/NoErrors/type.record.alpha @@ -0,0 +1 @@ +type R : [ integer : i ; character : c ] diff --git a/tests/carl/NoErrors/type.record.alpha.asc b/tests/carl/NoErrors/type.record.alpha.asc new file mode 100644 index 0000000..848948b --- /dev/null +++ b/tests/carl/NoErrors/type.record.alpha.asc @@ -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: diff --git a/tests/carl/NoErrors/types.alpha b/tests/carl/NoErrors/types.alpha new file mode 100644 index 0000000..0402f95 --- /dev/null +++ b/tests/carl/NoErrors/types.alpha @@ -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 diff --git a/tests/carl/NoErrors/types.alpha.asc b/tests/carl/NoErrors/types.alpha.asc new file mode 100644 index 0000000..8844865 --- /dev/null +++ b/tests/carl/NoErrors/types.alpha.asc @@ -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: