A tiny statically typed scripting language.
Because I'm a fan of The Magicians and niffin
is a cool name for a language.
The language syntax is based on:
- Nim
- C
- Rust
- Lox
Hello world:
# this is a comment
print("Hello world!");
Constants:
discard 0b110;
discard 0o777;
discard 0x1f;
discard 23;
discard 23.32;
discard 6.02e23;
discard "Hello";
Declarations:
var x = 0;
# vars can be reassigned
x = 1;
let y = 2;
# let bindings cannot be reassigned
# y = 3 # <- error
# proc's can have side effects
proc incX(){
x = x + 1;
}
# fun's are pure functions
fun add(a: int, b: int): int {
return a + b;
}
UFCS:
fun add(a: int, b: int): int {
return a + b;
}
# The following are all equivalent
discard 1.add(2);
discard add(1, 2);
- Lexer
- Parser (in progress)
- Resolver (in progress)
- Type checker
- Virtual machine