Group18 Language Documentation

A statically typed, C-like language compiling to x64 NASM and WebAssembly.

Back to Demo

Introduction

Group18 (g18) is a minimal, educational programming language implemented in Rust that compiles to x86-64 assembly. It demonstrates the complete pipeline of language implementation, from lexical analysis to code generation.

While the native compiler targets x64 NASM assembly, this online demo compiles to WebAssembly (WASM) to run directly in your browser.

Information on this page is sparse and not all-encompassing. Further reading is available and encouraged at the project's repository here.

For any questions, bug reports, or feedback, please contact me via email.

Note: The online WASM compiler is the bane of my existence. By nature, it will not display the informative and well-formatted error messages that the native x86-64 compiler provides. This is a limitation of the WASM environment. Further, If you encounter an issue where code that should compile successfully fails, this is exclusive behavior to the online WASM compiler and will not occur in the native x86-64 compiler. Please contact me in such cases.

Language Rules

  • Entry Point: The entry point of every program is the main() function. It is not strictly required that main() returns a specific type, or even that it returns something at all.
  • Function Declaration: Functions must be declared before they are called (similar to C protos).
  • Scoping: There is no variable shadowing allowed. Variable names must be unique within their accessible scope.
  • Typing: Static strong typing is enforced.
  • Comments: Comments are not supported and provided here as illustrative examples only.

Syntax Guide

Program Structure

A typical Group18 program consists of function definitions, ending with a main function.

fn add(i32s a, i32s b) -> i32s {
    return a + b;
}

fn main() -> i32s {
    i32s result = add(5, 10);
    print(result);
    return 0;
}

Control Structures


for i in 0 to 10 { // Exclusive upper bound
    // Loop body
}

if x > 5 {
    print("Greater");
} else if x == 5 {
    print("Equal");
} else {
    print("Smaller");
}

Data Types