initial commit

This commit is contained in:
yenru0 committed 2025-11-04 12:57:40 +09:00
commit cacb35ddb2
6 files changed
+37

No files matched your search

View File
Whitespace-only changes.
+18
View File
@@ -0,0 +1,18 @@
# C-val Compiler
## Lexical Spec
* LBRACK `[`
* RBRACK `]`
* LCURLY `{`
* RCURLY `}`
* ID `[all]`
* SEMI `;`
* COMMA `,`
* ARROW `->`
* COMMENT `#`
* NUM `[0-9]*(.[0-9]+)?`
* RETURN `return`
* IF `if`
* ELSE `else`
* STRING "{any}"
View File
Whitespace-only changes.
View File
Whitespace-only changes.
View File
Whitespace-only changes.
+19
View File
@@ -0,0 +1,19 @@
val int s 3; # global
val [int->int] fib int n {
return if == n 0 {
1
} else {
n * fib
};
};
val [->int] main {
val str line input;
val int n to_int line,;
if < n 0 {
print "ILLEGAL"
} else {
print to_str fib n,;
}
};