Skip to content

CLI Reference

Derek Snider edited this page Jul 23, 2026 · 2 revisions

CLI Reference

Basic usage

madc <file.mad> [args...]

JIT-compiles and runs the program. Any arguments after the filename are passed as argc/argv to main().

Flags

Flag Description
-v / --verbose Enable debug trace output (tokenizer, parser, compiler)
-o <prog> Compile to a native ELF executable instead of JIT-running (MIR assembles it directly — no external toolchain)
-c [-o file.o] Compile to a relocatable native object; madc file.o runs it as a precompiled cache
-shared [-o file.so] Compile to a shared object (ET_DYN)
-g Debug info — gdb can break/step/inspect JIT'd and native code alike
--emit=c11|mc11 Emit standard C11 (or MC11) source instead of running — transpile madc/C++ programs to portable C for any C toolchain
--std=<std> Language standard: c89/c90/c99/c11/c17/c23, c++NN, or the default madc dialect
-I<dir> Add an include search directory
--project <db.json> Build a multi-file project from a compile_commands.json

Examples

# Run a program
madc hello.mad

# Run with arguments
madc script.mad arg1 arg2

# Debug trace
madc -v hello.mad

# Compile to native executable
madc -o hello hello.mad
./hello

Shebang

Make .mad files directly executable:

#!/usr/bin/env madc
#include <stdio.h>

int main() {
    printf("I'm a script!\n");
    return 0;
}
chmod +x script.mad
./script.mad

OBJ caching

madc caches compiled object files. The first run JIT-compiles your program; subsequent runs load from cache for faster startup. Caching is automatic — no flags needed.

What's next?

Clone this wiki locally