Zm-Lang
Zm-Lang is a small, experimental programming language designed for learning compilers, transpiling, and building simple applications. It has a Python-like syntax with optional semicolons, supports arrays, loops, basic expressions, and can transpile to C for native execution.
Features
- Python-like syntax (optional
; for one-liners or C-style preference)
- Transpiles to C code and builds native executables
- Supports:
int and string types
- Arrays of numbers or strings
for loops (range and array iteration)
while loops
- Basic arithmetic:
+, *
- Comparison operators:
<, >, ==, !=
print() builtin
return statements
- Easy to extend and modify
Example
func main(argc: int, argv: any[]): int {
numbers: int[] = [1, 2, 3, 4]
words: string[] = ["zero", "one", "two", "three"]
print("Range loop:")
for i: int in 0..4 {
print(i)
}
print("Array iteration (numbers):")
for n: int in numbers {
print(n)
}
return 0
}
Usage
# Compile and run example.zm
./build.sh
Building Your Own Programs
- Write your code in a
.zm file.
- Use
python3 zmc.py yourfile.zm to transpile to C.
- Compile with
gcc out.c -o example.
- Run
./example.
License
This project is MIT licensed. See LICENSE.md for details.