A simple programming language, for fun.
The compiler in its current position can parse the following into an AST:
# hi
fn hello_world() {
a = 123 < 546
}
fn goodbye_world() {
b = 4 - 6
a = 57899900 + 243
a + b
}
3 steps of compiling
- Lexing
- Parsing
- Code-Gen
Everything will be transpiled into C for now.
Usage | Notation |
---|---|
definition | = |
concatenation | , |
termination | ; |
alternation | | |
optional | [ ... ] |
repetition | { ... } |
grouping | ( ... ) |
terminal string | " ... " |
terminal string | ' ... ' |
comment | (* ... *) |
special sequence | ? ... ? |
exception | - |
Note that this is not correct yet.
program = { statement }-
statement = "if" paren_expr statement |
"fn" ident paren_ident statement |
"{" { statement } "}" |
expr ";"
paren_ident = "(" { ident } ")"
paren_expr = "(" expr ")"
expr = term |
ident "=" expr |
expr '+' expr |
expr '-' expr |
expr '<' expr
term = ident | literal | paren_expr
ident = { "a".."z" }-
literal = { "0".."9" }-
No for loops. Only recursion.
Only top level members are functions.