202733edbcf3d80ebd60cf9118b0b762b572527d
Mechanical translation of AstGen.zig into C. Implements: - Container members: comptime, simple_var_decl, test_decl, fn_decl - Expressions: number_literal, string_literal, identifier (with primitive types, integer types, and decl_val/decl_ref resolution), field_access (field_val/field_ptr), address_of, builtin_call (@import), array_type, array_init (with inferred [_] length), array_cat (++), ptr_type - Statement types: assign with _ = expr discard pattern - Test infrastructure: testDecl, addFunc, fullBodyExpr, blockExprStmts, emitDbgNode/emitDbgStmt, rvalueDiscard - Support: GenZir sub-block instruction tracking, result location propagation (RL_NONE/RL_REF/RL_DISCARD), string dedup, import tracking, namespace decl table, lastToken, firstToken 1/5 corpus files pass (test_all.zig). Remaining 4 skip gracefully via has_compile_errors when encountering unimplemented features. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
About
zig0 aspires to be an interpreter of zig 0.15.1 written in C.
This is written with help from LLM:
- Lexer:
- Datastructures 100% human.
- Helper functions 100% human.
- Lexing functions 50/50 human/bot.
- Parser:
- Datastructures 100% human.
- Helper functions 50/50.
- Parser functions 5/95 human/bot.
- AstGen: TBD.
Testing
Quick test:
zig build fmt && zig build
Debugging tips
Test runs infinitely? Build the test program executable:
$ zig build test -Dno-exec
And then run it, capturing the stack trace:
gdb -batch \
-ex "python import threading; threading.Timer(1.0, lambda: gdb.post_event(lambda: gdb.execute('interrupt'))).start()" \
-ex run \
-ex "bt full" \
-ex quit \
zig-out/bin/test
You are welcome to replace -ex "bt full" with anything other of interest.
Languages
Zig
96.3%
C
2.7%
C++
0.6%
Python
0.1%