initial commit

This commit is contained in:
2025-11-04 12:57:40 +09:00
commit cacb35ddb2
6 changed files with 37 additions and 0 deletions

0
Makefile Normal file
View File

18
README.md Normal file
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}"

0
include/globals.h Normal file
View File

0
include/lex.h Normal file
View File

0
src/lex.c Normal file
View File

19
test.cval Normal file
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,;
}
};