A simple language inspired by StandardML. In my journey of understanding how compilers works, there is KARM. It's only a project but it's kind of like my baby. Just a little language, with a grammar and a syntax that I made myself.
StandardML Affirmation-based language
- Running on linux (required by
termion >= 3.0.0) rustc >= 1.75.0cargo >= 1.75.0
To submit your code, create a PR on the dev branch, which will be reviewed later on and merged on main if the feature is stable and legitimate.
Please document all your code, especially the structs fields and the functions by providing their specification. You can get inspirations from the actual code.
Caution
This section, especially the grammar, is subject to changes. Here is the BNF of the language's grammar :
program = expr;
expr = let | app | if-expr | interrogative | '(' expr ')';
# Affirmative expr
let = 'let' affirmative 'in' expr;
affirmative = id '=' ( type | fun );
type = 'type' ( product | sum );
fun = [ 'ifx' ] 'fun' [{ id [ ',' id ] }] '->' expr;
app = id [ '(' { id ',' } ')' ];
if-expr = 'if' expr 'then' expr 'else' expr;
interrogative = '?' affirmative;
term = id | literal;
literal = numbers | strings | booleans | chars;let main = print("Hello, World");(The print function will be part of the standard library)
Basic implementation of the fibonacci sequence in Karm :
let fib n = if n <= 1 then n else fib(n - 1) + fib(n - 2);(* Here it's annoying cause `x: Str` should be an affirmation but it has little sense to define something as let x: Str in if x is not defined. Or it could be empty instance. *)
let show x =
if (? x: Str) then print(x)
else if (? x: Int) then printf("{i}", x)
else if (? x: Bool) then printf("{b}", x);