Organization + Task 1 objectives t#30

This commit is contained in:
Scarlett
2025-02-24 15:28:46 -05:00
parent c1191c888e
commit 44ddfa41f8
23 changed files with 40 additions and 64 deletions
+1
View File
@@ -0,0 +1 @@
(***)
+1
View File
@@ -0,0 +1 @@
(*(**)*)
+7
View File
@@ -0,0 +1,7 @@
(*(**)*)
(***)
(******)(*\kpp*********)
((*((*))
(***)(*)
(* *)
(***)))))))*(*))))))))*))
+9
View 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
View 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
View 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
View File
@@ -0,0 +1,23 @@
+
-
*
/
\
%
<
>
=
:=
=:
:
=
!
&
|
.
relEASE
release
RELEASE
reserve
RESERVE
reSERVe
+6
View File
@@ -0,0 +1,6 @@
;
:
,
->
->>
-->
+42
View File
@@ -0,0 +1,42 @@
)
a)
)a
)*
*)
(* jellsls
well this seems to work
*)
(
a(
(a
(*
*(
{
a{
{a
{*
*{
}
a}
}a
}*
*}
[
a[
[a
[*
*[
]
a]
]a
]*
*]
+28
View 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
View 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
View File
@@ -0,0 +1,5 @@
45
123
8392
40 40
200 50 21783
+47
View 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
View File
@@ -0,0 +1,10 @@
valid1
Valid2
_valid3
_valid_name_4
VALID
0Invalid
1invalid
"invalid
invalid=
String