Spec
Types
num | f64 |
int | i64 |
str | string |
bool | boolean |
void | no value |
Keywords
fn | function |
ret | return |
type | type definition |
if | conditional |
let | binding |
call | function call |
ok | success |
err | error |
or | union separator |
Operators
plus | + |
minus | - |
times | * |
over | / |
mod | % |
eq | == |
neq | != |
lt gt lte gte | < > <= >= |
and or not | logical |
Positional
first | param 0 |
second | param 1 |
third | param 2 |
fourth | param 3 |
Numbers
zero one two three four five six seven eight nine ten
Syntax
Function
fn name params...
body
Return
ret value
ret ok value
ret err value
Type
type name fields...
type name ok type or err type
Conditional
if condition statement
Binding
let name value
Call
call function args...
Examples
Math
fn add a b
ret a plus b
fn sub a b
ret a minus b
Calculator
type result ok num or err str
fn calc a b op
if op eq zero ret ok a plus b
if op eq one ret ok a minus b
ret err "unknown"
Function Calls
fn square x
ret x times x
fn hypotenuse a b
let asq call square a
let bsq call square b
ret math sqrt asq plus bsq
Comments
-- this is a comment
# this too
Compilation
NERD → Lexer → Parser → AST → LLVM IR → clang → native