ZLang – Minimalist programming language and compiler written in Python.
Produces a single-file executable (z.exe) with no dependencies and cross-platform support. Ideal for learning, experimentation, and rapid prototyping.
Keywords: ZLang, programming language, compiler, Python, single-file executable, interpreter, minimalist, cross-platform.
- Download:
z.exe(single file, no installation needed) - Setup: Run
z.exeor double-click to install to PATH - Compile:
z program.z→ createsprogram.exe
# Quick commands
z.exe # Run compiler
z -v # Check version
z hello.z # Compile to hello.exe
z program.z -f c # Generate C source code
z --help # Show all commands# Build compiler from source
python -m PyInstaller --onefile --name=z --console --clean main.py
# Test
./z
z test.z# Default: compile to executable
z program.z # → program.exe
z program.z -o myapp.exe # → custom executable
# Generate C source code
z program.z -f c # → program.c
z program.z -f c -o output.c # → output.c
# Specify compiler
z program.z -c gcc # Use GCC
z program.z -c clang # Use Clang (default)- ✅ Single-file executable (
z.exe) - ✅ No external dependencies
- ✅ Cross-platform: Windows, Linux, macOS
- ✅ Module system with
IMPORTstatements - ✅ Automatic C compiler detection
- ✅ Path traversal protection
- ✅ Memory-safe operations and cleanup
- ✅ Race condition prevention in update mechanism
- ✅ Input validation and UTF-8 enforcement
- ✅ Colored terminal output
- ✅ Clear progress indicators
- ✅ Helpful error messages with file/line context
- ✅ Performance timing reports
- ✅ Comprehensive error codes
ZLang is a procedural programming language with modern control flow and explicit instructions like LET, ADD, SUB, PRINT.
FN fibonacci(int n) -> int:
IF n <= 1:
RET n
LET int a 0
LET int b 1
LET int fib 0
FOR i 2..n:
ADD a b fib
LET a b
LET b fib
RET b
FN main():
LET int count 10
CALL fibonacci(count) -> result
PRINT result
Output:
55
int,float,double,bool,string- Mutable (
MOV) and immutable (CONST) - Pointer support:
PTR int ptr x - Arrays: fixed-size, dynamic, and empty
ADD,SUB,MUL,DIV,MODINC,DEC
- Functions:
FN name(params): ... RET value - Calls:
CALL func(args) -> result - Conditionals:
IF,ELIF,ELSE - Loops:
FOR,WHILE
IMPORT "file.z"PRINT,PRINTSTRREAD(with type and prompt)ERROR "message"
- Constant folding
- Precompiled regexes
- Identifier caching
- Smart code generation
| File | Purpose |
|---|---|
main.py |
CLI & entry point |
setup_update.py |
PATH installation & updates |
lexer.py |
Tokenizes .z source code |
optimizer.py |
Constant folding & optimization |
codegen.py |
Generates C code |
errors.py |
Error handling & codes |
semantics.py |
Semantic analysis & validation |
Compilation pipeline:
.z source → lexer → optimizer → codegen → C code → [C compiler] → executable
- Windows: MSVC, MinGW-w64, or Clang
- Linux/macOS: GCC or Clang
- Python only needed for building compiler (
z.exe)
See CHANGELOG.md for full version history.
If you like ZLang, please:
- ⭐ Star the repo
- 🍴 Fork & contribute
- 📢 Share with friends and communities
Your support helps make ZLang better! 🚀