Nmet is a general purpose statically typed and compiled programming Language that generates x86-64 assembly as Intermediate representation (IR) which can be compiled to binary using nasm. We eventually will move away from nasm and implement our own loader but the current goal is to become self hosted by writing the compiler in itself!

hello_world.nmt

func main() {
	print "Hello World!\n";
}

Getting Started

The Project is in development state and dose not come with a binary package yet and It is Only available for Linux but you can use WSL in windows!

For getting started clone the repository and build the project using Rust toolchain Install Nasm using your package manager or by downloading it from it's official website.

For installing in Gnu/Linux system run the following commands in the root directory of the project:

$ make

or

$ make install

Alternatively you can use Rust Tool Chain to build and run the project.

Guids

In this section we are showcasing different aspects of Nmet syntax

# Starting Point

Every program starts with a function named main. usally this function has no arguments but you can define one with the type list-of-string to gain access to command line arguments.

p.s: Comments are starting with "~" because we hate this character so we made it into a comment

~~ No Arguments
func main() {
	...
}
~~ With Arguments
func main(args @[str,?]) {
	...
}

# Expressions

Expressions are grammars that can be used in every kind of operation; from mathematical to lists and function calls These expressions are just like in other languages.

# Print

Unlike other system level programming languages Nmet comes with an internal print function, This function dose not require Parentheses and can have as many arguments as you supply it to.

print "Hello world!";
print 12 + 6;

# Variable Declare

Every programming languages has a way to abstract away direct memory access with variables. In Nmet we define variables with "var" keyword followed by a name. All types in Nmet are indicated by the at-sign symbol. Adding type to variables is optional as long as you provide an initial value. Nmet also supports const variables which can be declared by adding a colon behind the question mark.

var list @[char,12];
var x @int = 10
~~ auto casting and const
var is_true := true;

# Variable Assignment

Assigning values to a variable is a process which you can transfer result of your processes to a predefined memory In Nmet we have different types of assignments including add and assign or divide and assign which is represented in the code below:

a = 10; ~~ a <- 10
a += 10; ~~ a <- a + 10
a -= 10; ~~ a <- a - 10
a *= 10; ~~ a <- a * 10
a /= 10; ~~ a <- a / 10
a %= 10; ~~ a <- a % 10

# Loops

loops are one of the most important parts of any programming language. Nmet loops are defined using the while keyword followed by a condition which indicates when the looping ends pretenses surrounding the condition is optional.

while a < 10 {
	...
}

# Conditions

if statements allow the user of the programming language to run some parts of the code conditionally. You can use if statements by writing the if keyword followed by the condition and with optional else and else if.

if a < 10 {
	...
} else if a > 10 {
	...
} else {
	...
}

# Inline Asm

because Nmet is a low level language having a way to write in line assembly is essential for the usability of it. Inline assembly codes can be defined in a block marked by asm keyword. each assembly line is surrounded by double quotes. You can use Nmet declared variables inside the assembly lines by using the percentage sign. Make sure to use correct registers for different variable types .

asm {
	"mov rax, %my_u64_variable"
	"inc rax"
}