Commit 4d2f12e
committed
feat: Fix block statement collection in Zyn grammar runtime
- Add blocks storage to TypedAstBuilder for proper block handling
- Fix create_block to store entire TypedBlock instead of just first stmt
- Add get_block helper to retrieve blocks by handle
- Update create_function to properly retrieve body blocks
- Convert zig.zyn to JSON command format (from Rust action blocks)
- Add GetAllChildren command for statement* patterns
- Fix InternedString serialization to output actual string
This fixes the issue where function bodies only captured the first
statement. Now all statements in a block are properly preserved through
the TypedAST pipeline.
Test results:
- return 42 → 42 ✓
- return 2 + 3 * 4 → 14 ✓
- const x = 10; return x; → 10 ✓
- const x = 10; const y = 20; return x + y; → 30 ✓1 parent 133067a commit 4d2f12e
6 files changed
Lines changed: 837 additions & 1222 deletions
File tree
- crates
- typed_ast/src
- zyn_parser/tests
- zyn_peg
- grammars
- src
- zyntax_cli/src/formats
- docs
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
51 | | - | |
52 | | - | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
53 | 59 | | |
54 | 60 | | |
55 | 61 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
23 | 69 | | |
24 | 70 | | |
25 | 71 | | |
| |||
0 commit comments