@@ -42,12 +42,12 @@ zyntax compile --grammar <grammar.zyn> --source <file> [OPTIONS]
4242
4343### Compile and Run (JIT)
4444
45- The most common workflow - compile and execute immediately:
45+ The most common workflow - JIT compile and execute immediately:
4646
4747``` bash
4848zyntax compile --grammar crates/zyn_peg/grammars/zig.zyn \
4949 --source examples/hello.zig \
50- --run
50+ --jit
5151```
5252
5353Output:
@@ -62,12 +62,21 @@ result: main() returned: 42
6262| ` --grammar ` | ` -g ` | ZynPEG grammar file (.zyn) | Required |
6363| ` --source ` | ` -s ` | Source file to compile | Required |
6464| ` --output ` | ` -o ` | Output file path | None |
65- | ` --backend ` | ` -b ` | Backend: ` jit ` or ` llvm ` | ` jit ` |
65+ | ` --backend ` | ` -b ` | Backend: ` cranelift ` or ` llvm ` | ` cranelift ` |
6666| ` --opt-level ` | ` -O ` | Optimization: 0-3 | ` 2 ` |
67- | ` --run ` | | Execute after compilation (JIT only) | Off |
67+ | ` --jit ` | | JIT compile and execute immediately | Off |
6868| ` --verbose ` | ` -v ` | Show detailed output | Off |
6969| ` --format ` | ` -f ` | Input format (see below) | ` auto ` |
7070
71+ ### Backends
72+
73+ Zyntax supports two compilation backends:
74+
75+ | Backend | Description | Use Case |
76+ | ---------| -------------| ----------|
77+ | ` cranelift ` | Fast compilation, good code quality | Development, JIT |
78+ | ` llvm ` | Maximum optimization, slower compilation | Production, AOT |
79+
7180### Input Formats
7281
7382The ` --format ` option controls how input is interpreted:
@@ -81,38 +90,45 @@ The `--format` option controls how input is interpreted:
8190
8291### Examples
8392
84- #### Compile and Run
93+ #### JIT Compile and Run
8594
8695``` bash
87- # Simple execution
88- zyntax compile -g zig.zyn -s test.zig --run
96+ # Simple execution with Cranelift (fast)
97+ zyntax compile -g zig.zyn -s test.zig --jit
8998
9099# With verbose output
91- zyntax compile -g zig.zyn -s test.zig --run -v
100+ zyntax compile -g zig.zyn -s test.zig --jit -v
101+
102+ # JIT with LLVM backend (maximum optimization)
103+ zyntax compile -g zig.zyn -s test.zig --backend llvm --jit
92104```
93105
94- #### Compile to Object File (LLVM)
106+ #### AOT Compile to Executable
95107
96108``` bash
97- zyntax compile -g zig.zyn -s main.zig -b llvm -o main.o
109+ # Compile to native executable with Cranelift
110+ zyntax compile -g zig.zyn -s main.zig -o main
111+
112+ # Compile with LLVM for maximum optimization
113+ zyntax compile -g zig.zyn -s main.zig --backend llvm -o main
98114```
99115
100116#### Optimization Levels
101117
102118``` bash
103119# No optimization (fastest compile)
104- zyntax compile -g zig.zyn -s test.zig -O0 --run
120+ zyntax compile -g zig.zyn -s test.zig -O0 --jit
105121
106122# Maximum optimization
107- zyntax compile -g zig.zyn -s test.zig -O3 --run
123+ zyntax compile -g zig.zyn -s test.zig -O3 --jit
108124```
109125
110126#### Compile TypedAST JSON
111127
112128If you have pre-built TypedAST:
113129
114130``` bash
115- zyntax compile program.json --run
131+ zyntax compile program.json --jit
116132```
117133
118134## The ` repl ` Command
@@ -130,7 +146,7 @@ zyntax repl --grammar crates/zyn_peg/grammars/zig.zyn
130146| Option | Short | Description | Default |
131147| --------| -------| -------------| ---------|
132148| ` --grammar ` | ` -g ` | ZynPEG grammar file | Required |
133- | ` --backend ` | ` -b ` | Backend (JIT only) | ` jit ` |
149+ | ` --backend ` | ` -b ` | Backend: ` cranelift ` or ` llvm ` | ` cranelift ` |
134150| ` --opt-level ` | ` -O ` | Optimization: 0-3 | ` 0 ` |
135151| ` --verbose ` | ` -v ` | Show parse details | Off |
136152
@@ -223,7 +239,7 @@ When developing a grammar:
223239zyntax repl -g mygrammar.zyn
224240
225241# Test a complete program
226- zyntax compile -g mygrammar.zyn -s test.mylang --run
242+ zyntax compile -g mygrammar.zyn -s test.mylang --jit
227243```
228244
229245### Testing Workflow
@@ -239,7 +255,7 @@ fn main() i32 {
239255EOF
240256
241257# Run and verify
242- zyntax compile -g zig.zyn -s /tmp/test_arithmetic.zig --run
258+ zyntax compile -g zig.zyn -s /tmp/test_arithmetic.zig --jit
243259# Expected: result: main() returned: 14
244260```
245261
@@ -253,7 +269,7 @@ GRAMMAR="crates/zyn_peg/grammars/zig.zyn"
253269
254270for file in tests/* .zig; do
255271 echo " Testing: $file "
256- zyntax compile -g " $GRAMMAR " -s " $file " --run
272+ zyntax compile -g " $GRAMMAR " -s " $file " --jit
257273 echo " ---"
258274done
259275```
@@ -264,7 +280,7 @@ When something doesn't work:
264280
265281``` bash
266282# Step 1: Check parsing with verbose
267- zyntax compile -g mygrammar.zyn -s broken.mylang -v --run
283+ zyntax compile -g mygrammar.zyn -s broken.mylang -v --jit
268284
269285# Step 2: Simplify the input
270286echo " 1 + 2" | zyntax repl -g mygrammar.zyn -v
@@ -319,7 +335,7 @@ zyntax repl -g mygrammar.zyn
319335When parsing fails unexpectedly:
320336
321337``` bash
322- zyntax compile -g grammar.zyn -s file.src -v --run
338+ zyntax compile -g grammar.zyn -s file.src -v --jit
323339```
324340
325341### 3. Create Minimal Test Cases
@@ -360,7 +376,7 @@ FAIL=0
360376
361377for test in tests/* .mylang; do
362378 expected=" ${test% .mylang} .expected"
363- result=$( zyntax compile -g " $GRAMMAR " -s " $test " --run 2>&1 )
379+ result=$( zyntax compile -g " $GRAMMAR " -s " $test " --jit 2>&1 )
364380
365381 if diff -q <( echo " $result " ) " $expected " > /dev/null; then
366382 echo " ✓ $test "
@@ -383,10 +399,10 @@ echo "Passed: $PASS, Failed: $FAIL"
383399
384400``` bash
385401# Debug logging
386- RUST_LOG=debug zyntax compile -g zig.zyn -s test.zig --run
402+ RUST_LOG=debug zyntax compile -g zig.zyn -s test.zig --jit
387403
388404# Full backtrace on errors
389- RUST_BACKTRACE=1 zyntax compile -g zig.zyn -s test.zig --run
405+ RUST_BACKTRACE=1 zyntax compile -g zig.zyn -s test.zig --jit
390406```
391407
392408## Next Steps
0 commit comments