✓
Passing This code compiles and runs correctly.
Code
// Test: AST dump to JSON
//
// Parses Koru source code and dumps the AST as JSON.
// This enables tools to inspect parsed structure.
//
// Pure Koru - no Zig procs needed!
~import std/parser
~import std/io
const std = @import("std");
// Sample code to parse
const SAMPLE =
\\~event hello {}
;
// Flow: parse → dump → print (pure Koru!)
~std/parser:parse.source(source: SAMPLE, file_name: "test.kz", allocator: std.heap.page_allocator)
| parsed p |> std/parser:dump.ast(ast: p, allocator: std.heap.page_allocator)
| dumped d |> std/io:print.ln("{{d:s}}")
| dump-error e |> std/io:print.ln("Dump error: {{e:s}}")
| parse-error e |> std/io:print.ln("Parse error: {{e:s}}")
Actual
{
"module_annotations": [
],
"items": [
{
"type": "event_decl",
"name": "hello",
"path": ["hello"],
"module": "test",
"input": {
"fields": [
]
},
"branches": [
],
"location": {
"file": "test.kz",
"line": 1,
"col": 0
}
}
]
}
Expected output
{
"module_annotations": [
],
"items": [
{
"type": "event_decl",
"name": "hello",
"path": ["hello"],
"module": "test",
"input": {
"fields": [
]
},
"branches": [
],
"location": {
"file": "test.kz",
"line": 1,
"col": 0
}
}
]
}
Test Configuration
MUST_RUN