Skip to content

DemetryF/smpl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

About SMPL

SMPL is primitive math programming language under development.

Syntax

All expressions end with a semicolon. Function main is entry point.

Variable Declaration

You can declare a variable by using let keyword:

let a: int = 2;

If Statement

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

While loop is also similar to while loop in Rust

while cond {
    // body
}

Also there is Continue and Break statements;

Function Declaration

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

Typing

SMPL is typed language, so it have 3 types: real (f32), int (i32) and bool

Using

  1. Compile it:
cargo build --release
  1. take compiler bin
mv target/release/smplc ./smplc
  1. compile your file:
./smplc <path> [-o <output binary file name>]

Releases

No releases published

Packages

No packages published

Languages