Compile Haxe to native code via the Zyntax compiler backend.
This is a Reflaxe backend that enables compiling Haxe code to native executables using the Zyntax compiler infrastructure. It translates Haxe's typed AST into Zyntax TypedAST JSON format, which is then compiled to native code via Cranelift JIT or LLVM AOT.
Haxe Source Code
↓
Haxe Typed AST (via Reflaxe)
↓
Zyntax TypedAST JSON (this project)
↓
Zyntax HIR (High-level IR)
↓
Cranelift/LLVM Backend
↓
Native Binary
- Install Haxe (4.0 or later)
- Install Reflaxe framework:
haxelib install reflaxe 4.0.0-beta
- Build the Zyntax compiler (see main project README)
From the reflaxe.zyntax directory:
haxelib dev reflaxe.zyntax .Or install from haxelib (when published):
haxelib install reflaxe.zyntaxAdd to your Haxe build file (.hxml):
-lib reflaxe.zyntax
-D zyntax-output=output
-main MainThen compile:
haxe build.hxmlThis generates TypedAST JSON files in the output/ directory.
After generating JSON files, use the Zyntax compiler:
zyntax compile output/*.json -o my_programMain.hx:
class Main {
static function main() {
trace("Hello from Haxe via Zyntax!");
var result = fibonacci(10);
trace('Fibonacci(10) = $result');
}
static function fibonacci(n: Int): Int {
if (n <= 1) return n;
return fibonacci(n - 1) + fibonacci(n - 2);
}
}Compile:
haxe -lib reflaxe.zyntax -D zyntax-output=out -main Main
zyntax compile out/*.json -o fibonacci
./fibonacciOutput:
Hello from Haxe via Zyntax!
Fibonacci(10) = 55
- ✅ Classes and interfaces
- ✅ Enums and pattern matching
- ✅ Functions and methods
- ✅ Closures/lambdas
- ✅ Generics/type parameters
- ✅ Static typing
- ✅ Basic operators
- ✅ Control flow (if, while, for)
- ✅ Arrays and collections
- ✅ String operations
⚠️ Async/await (partial - via async runtime)⚠️ Macros (compile-time only, not runtime)- ❌ Reflection (not yet supported)
- ❌ Dynamic typing (limited support)
| Haxe Type | Zyntax Type |
|---|---|
Int |
i32 |
Float |
f64 |
Bool |
bool |
String |
String |
Void |
() (unit) |
Array<T> |
Array<T> |
Class<T> |
Nominal type |
Enum<T> |
Enum |
Function |
Function type |
Dynamic |
Dynamic (gradual typing) |
-D zyntax-output=<dir>- Output directory for JSON files (default:zyntax_output)-D zyntax-backend=<jit|aot>- Compilation backend (default:jit)-D zyntax-opt-level=<0-3>- Optimization level (default:2)-D zyntax-target=<triple>- Target triple for cross-compilation
The compiler automatically renames Haxe identifiers that conflict with Rust/Zyntax keywords:
as, async, await, const, fn, impl, let, match, mod, mut, pub, return, self, struct, trait, type, use, where, while, etc.
reflaxe.zyntax/
├── src/
│ └── zyntax/
│ ├── ZyntaxCompiler.hx # Main compiler logic
│ └── ZyntaxCompilerInit.hx # Initialization macro
├── std/ # Haxe standard library overrides
├── extraParams.hxml # Auto-included compiler settings
├── haxelib.json # Package metadata
└── README.md
- Clone the repository
- Set up development mode:
haxelib dev reflaxe.zyntax . - Run tests:
cd tests haxe test.hxml
- No Runtime Reflection: Haxe's runtime reflection is not supported
- Limited Dynamic: Dynamic typing has performance overhead
- Macros: Only compile-time macros work; runtime code generation is not supported
- Platform-Specific APIs: Some Haxe standard library APIs may not be available
Zyntax uses a tiered JIT compilation strategy:
- Baseline Tier - Fast compilation, basic optimization
- Standard Tier - Moderate compilation time, good performance
- Optimized Tier - Aggressive optimization via LLVM
For production builds, use AOT compilation with LLVM backend for maximum performance.
Contributions are welcome! Please see the main Zyntax project for contribution guidelines.
MIT License - See LICENSE file
- Zyntax Compiler - Main compiler project
- Reflaxe Framework - Backend framework
- TypedAST Documentation - IR format specification