Organization + Task 1 objectives t#30
This commit is contained in:
1
tests/sprint1/test_comment_fix1.alpha
Normal file
1
tests/sprint1/test_comment_fix1.alpha
Normal file
@ -0,0 +1 @@
|
||||
(***)
|
1
tests/sprint1/test_comment_fix2.alpha
Normal file
1
tests/sprint1/test_comment_fix2.alpha
Normal file
@ -0,0 +1 @@
|
||||
(*(**)*)
|
7
tests/sprint1/test_comment_issues.alpha
Normal file
7
tests/sprint1/test_comment_issues.alpha
Normal file
@ -0,0 +1,7 @@
|
||||
(*(**)*)
|
||||
(***)
|
||||
(******)(*\kpp*********)
|
||||
((*((*))
|
||||
(***)(*)
|
||||
(* *)
|
||||
(***)))))))*(*))))))))*))
|
9
tests/sprint1/test_comments.alpha
Normal file
9
tests/sprint1/test_comments.alpha
Normal file
@ -0,0 +1,9 @@
|
||||
(* hello *)
|
||||
(* hello *)
|
||||
(* I'd think this is a legal "string" that contains several \n \t
|
||||
escaped characters, isn't it? *)
|
||||
(* \ *)
|
||||
(* *)
|
||||
(*{COMMENT}+ *)
|
||||
(* * *)
|
||||
(* (hello) *)
|
24
tests/sprint1/test_general_token.alpha
Normal file
24
tests/sprint1/test_general_token.alpha
Normal file
@ -0,0 +1,24 @@
|
||||
This is a test
|
||||
9combined 7okens
|
||||
12345
|
||||
893247892
|
||||
combined'DueToUnknownChar _validtoken __validtoken1 _valid_token2 validToken3_
|
||||
true false
|
||||
null while !wrong if when
|
||||
else type function
|
||||
return external as
|
||||
string _NOte_that_was_not_reserved
|
||||
([)]{}:;,->"\
|
||||
+-*/%
|
||||
<=
|
||||
:=
|
||||
"This is not a valid
|
||||
String"
|
||||
"This is a valid String"
|
||||
!|
|
||||
..
|
||||
(* this is a comment *)
|
||||
(*Not a comment
|
||||
$^&
|
||||
>
|
||||
|
29
tests/sprint1/test_keywords.alpha
Normal file
29
tests/sprint1/test_keywords.alpha
Normal file
@ -0,0 +1,29 @@
|
||||
while
|
||||
While
|
||||
whiLe
|
||||
if
|
||||
IF
|
||||
If
|
||||
iF
|
||||
then
|
||||
Then
|
||||
theN
|
||||
else
|
||||
eLse
|
||||
elSe
|
||||
Else
|
||||
type
|
||||
Type
|
||||
tyPe
|
||||
function
|
||||
Function
|
||||
functioN
|
||||
return
|
||||
Return
|
||||
returN
|
||||
external
|
||||
External
|
||||
exteRnal
|
||||
as
|
||||
As
|
||||
aS
|
23
tests/sprint1/test_operators.alpha
Normal file
23
tests/sprint1/test_operators.alpha
Normal file
@ -0,0 +1,23 @@
|
||||
+
|
||||
-
|
||||
*
|
||||
/
|
||||
\
|
||||
%
|
||||
<
|
||||
>
|
||||
=
|
||||
:=
|
||||
=:
|
||||
:
|
||||
=
|
||||
!
|
||||
&
|
||||
|
|
||||
.
|
||||
relEASE
|
||||
release
|
||||
RELEASE
|
||||
reserve
|
||||
RESERVE
|
||||
reSERVe
|
6
tests/sprint1/test_other_punc.alpha
Normal file
6
tests/sprint1/test_other_punc.alpha
Normal file
@ -0,0 +1,6 @@
|
||||
;
|
||||
:
|
||||
,
|
||||
->
|
||||
->>
|
||||
-->
|
42
tests/sprint1/test_punc_grouping.alpha
Normal file
42
tests/sprint1/test_punc_grouping.alpha
Normal file
@ -0,0 +1,42 @@
|
||||
)
|
||||
a)
|
||||
)a
|
||||
)*
|
||||
*)
|
||||
|
||||
(* jellsls
|
||||
well this seems to work
|
||||
|
||||
|
||||
*)
|
||||
|
||||
(
|
||||
a(
|
||||
(a
|
||||
(*
|
||||
*(
|
||||
|
||||
|
||||
{
|
||||
a{
|
||||
{a
|
||||
{*
|
||||
*{
|
||||
}
|
||||
a}
|
||||
}a
|
||||
}*
|
||||
*}
|
||||
|
||||
|
||||
|
||||
[
|
||||
a[
|
||||
[a
|
||||
[*
|
||||
*[
|
||||
]
|
||||
a]
|
||||
]a
|
||||
]*
|
||||
*]
|
28
tests/sprint1/test_real_alpha_file1.alpha
Normal file
28
tests/sprint1/test_real_alpha_file1.alpha
Normal file
@ -0,0 +1,28 @@
|
||||
type rec: [integer: x; integer: y]
|
||||
type T1: integer -> integer
|
||||
type T2: rec -> integer
|
||||
function foo : T1
|
||||
function bar1 : T2
|
||||
function bar2 : T2
|
||||
foo(x) := {
|
||||
return x * x;
|
||||
}
|
||||
bar1(a) := {
|
||||
return a.x * a.y;
|
||||
}
|
||||
bar2 as (r,s) := {
|
||||
return r * s;
|
||||
}
|
||||
entry(arg) := {
|
||||
[ integer: result ; rec: w]
|
||||
result := foo(5);
|
||||
w := reserve(w); (* see types.alpha – reserve returns a value of type address,
|
||||
which can be assigned to array and record variables
|
||||
*)
|
||||
w.x := 5;
|
||||
w.y := 7;
|
||||
result := bar1(w); (* pass w (a rec type value) to bar1 *)
|
||||
result := bar2(5,7); (* implicitly build a rec type value, assign 5 and 7 to fields x and y, but call them r and s *)
|
||||
|
||||
return 0;
|
||||
}
|
26
tests/sprint1/test_real_alpha_file2.alpha
Normal file
26
tests/sprint1/test_real_alpha_file2.alpha
Normal file
@ -0,0 +1,26 @@
|
||||
(* Type definitions *)
|
||||
type string: 1 -> character
|
||||
type int2int: integer -> integer
|
||||
type string2int: string -> integer
|
||||
(* Function prototypes
|
||||
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) := {
|
||||
input = 7;
|
||||
expected = 49;
|
||||
actual := square(input);
|
||||
rseult := expected = actual;
|
||||
return 0;
|
||||
[ integer: input; integer: expected; integer: actual; boolean: result; string: input ]
|
||||
}
|
5
tests/sprint1/test_simple_int.alpha
Normal file
5
tests/sprint1/test_simple_int.alpha
Normal file
@ -0,0 +1,5 @@
|
||||
45
|
||||
123
|
||||
8392
|
||||
40 40
|
||||
200 50 21783
|
47
tests/sprint1/test_simple_literals.alpha
Normal file
47
tests/sprint1/test_simple_literals.alpha
Normal file
@ -0,0 +1,47 @@
|
||||
"this is a string" 721398 'g' '/n' (* should print 3 tokens before this *)
|
||||
'
|
||||
'
|
||||
12893 "this is not a string (*one valid token before this*)
|
||||
(* spacey comment here
|
||||
over multiple lines
|
||||
will it work? *) false
|
||||
"
|
||||
'''
|
||||
'\'
|
||||
false
|
||||
(**)
|
||||
'''
|
||||
nullfalse
|
||||
"nulltrue
|
||||
null
|
||||
'7'
|
||||
true
|
||||
'189
|
||||
'\t'
|
||||
'"'
|
||||
'/'
|
||||
'\n'
|
||||
'\''
|
||||
'\t'
|
||||
'\\'
|
||||
'n'
|
||||
'\'
|
||||
'fdsf'
|
||||
(*/jnewjno2893u86^ Lots of random characters /n /t '") *)
|
||||
'
|
||||
'
|
||||
' '
|
||||
'''
|
||||
"STRINGwithnotSPaces"
|
||||
' '
|
||||
'\ '
|
||||
"J"
|
||||
""
|
||||
" "
|
||||
\"\"
|
||||
"{SCHAR}"
|
||||
"SCHAR"
|
||||
"[SCHAR]"
|
||||
"FINAL: I'd think this is a legal \"string\" that contains \n \t several escaped characters, isn't it?"
|
||||
"I'd think this is a legal \"string\" that contains several \\n \t escaped characters, isn't it?"
|
||||
nullLike
|
10
tests/sprint1/test_variables.alpha
Normal file
10
tests/sprint1/test_variables.alpha
Normal file
@ -0,0 +1,10 @@
|
||||
valid1
|
||||
Valid2
|
||||
_valid3
|
||||
_valid_name_4
|
||||
VALID
|
||||
0Invalid
|
||||
1invalid
|
||||
"invalid
|
||||
invalid=
|
||||
String
|
Reference in New Issue
Block a user