SMPL is primitive math programming language under development.
All expressions end with a semicolon.
Function main
is entry point.
You can declare a variable by using let
keyword:
let a: int = 2;
Conditional constructs in SMPL are similar to conditional constructs in Rust:
if cond {
// body
}
Also you can use else
branch:
if cond {
// body
} else {
// else body
}
Warning! Language does not yet support else if, attempting to use this syntax will result in an error.
While loop is also similar to while loop in Rust
while cond {
// body
}
Also there is Continue and Break statements;
You can declare a function by using fn
keyword:
fn name(arg1: int, arg2: real) -> bool {
// body
}
Use return statement for exit from function:
fn add(a: real, b: real) -> real {
return a + b;
}
you can see more examples here and formal grammary here
SMPL is typed language, so it have 3 types: real
(f32), int
(i32) and bool
- Compile it:
cargo build --release
- take compiler bin
mv target/release/smplc ./smplc
- compile your file:
./smplc <path> [-o <output binary file name>]