cool things
This commit is contained in:
20
tests/programs/array.alpha
Normal file
20
tests/programs/array.alpha
Normal file
@ -0,0 +1,20 @@
|
||||
#include "std.alpha"
|
||||
|
||||
type main: string -> integer
|
||||
function entry: main
|
||||
|
||||
(* maybe some other type definitions *)
|
||||
|
||||
entry(arg) := {
|
||||
[ string: one_name; string: another_name ]
|
||||
|
||||
one_name := "a string literal";
|
||||
|
||||
another_name := reserve another_name(4);
|
||||
another_name(0) := 'C';
|
||||
another_name(1) := 'a';
|
||||
another_name(2) := 'r';
|
||||
another_name(3) := 'l';
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
#include "std.alpha"
|
||||
|
||||
function entry: string2integer
|
||||
|
||||
entry (arg) := {
|
||||
[integer: x; string: s; character: c; integer: result]
|
||||
|
||||
result := printCharacter('\t');
|
||||
result := printCharacter('t');
|
||||
result := printCharacter('a');
|
||||
result := printCharacter('b');
|
||||
result := printCharacter('\n');
|
||||
result := printCharacter('\\');
|
||||
result := printCharacter('"');
|
||||
result := printCharacter('\'');
|
||||
|
||||
(*s := inS(1);
|
||||
result := printS(s);
|
||||
|
||||
x := inI(1);
|
||||
result := printI(x);
|
||||
|
||||
c := inC(1);
|
||||
result := printC(c);*)
|
||||
|
||||
return 0;
|
||||
}
|
@ -1 +0,0 @@
|
||||
(* TODO: creates a linked list and prints out the chain. *)
|
@ -1,27 +0,0 @@
|
||||
type string: 1 -> character
|
||||
type a_of_s: 1 -> string
|
||||
type main: integer -> integer
|
||||
function entry: main
|
||||
|
||||
(* maybe some other type definitions *)
|
||||
|
||||
entry(arg) := {
|
||||
[ string: one_name; string: another_name; a_of_s: many_names ]
|
||||
one_name := "a string literal";
|
||||
another_name := reserve another_name(4); (* reserve space for an an array of character, with 4 members *)
|
||||
another_name(0) := 'C';
|
||||
another_name(1) := 'a';
|
||||
another_name(2) := 'r';
|
||||
another_name(3) := 'l';
|
||||
many_names := reserve many_names(3);
|
||||
many_names(0) := one_name;
|
||||
many_names(1) := another_name;
|
||||
many_names(2) := reserve many_names(2)(6); (* reserve space for an item of the same type as a_of_s(2), an array of character, with 6 members *)
|
||||
many_names(2)(0) := 'P';
|
||||
many_names(2)(1) := 'a';
|
||||
many_names(2)(2) := 'r';
|
||||
many_names(2)(3) := 't';
|
||||
many_names(2)(4) := 'h';
|
||||
many_names(2)(5) := 'o';
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user