Skip to content

Pawel-Parma/mtl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mtl

A small experimental compiler front-end written in Zig.

Important

This project uses nominated zig versions
nominated version: 0.16.0-dev.368+2a97e0af6

Build

  1. Install the nominated zig version
  2. Build the project:
zig build

Usage

zig build run -- [options] <file_path>

Options:

  • --help, -h Print help message
  • --version, -v Print version
  • --debug, -d Enable debug mode

When debug mode is enabled Tokens, AST and Scopes will be printed when available.
<file_path> is the entrypoint file.

Example programs

  1. Minimal empty program:

Each entrypoint file requires a public main function.

pub fn main() void {

}
  1. Variable declaration:
pub fn main() void {
    const a: u32 = 12;
    const b: f32 = 12.3;
    const int: type = i32;
    const c: int = 13;
    const d = 14;
    var e: int = 15 + c;
    var f := 16 + e * d;
}
  1. Function declaration:
pub fn main() void {
    const a = add(1, 2);
    return;
}

fn add(a: u8, b: u8) u8 {
    return a + b;
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Contributors

Languages