feat: serialize lex tokens into json

This commit is contained in:
Fernando Araoz 2025-01-22 19:19:37 -05:00
parent d61063b279
commit 890ac41cbe

View File

@ -46,7 +46,15 @@ pub fn tokenize_to_json() !void {
try json_writer.writeAll(","); try json_writer.writeAll(",");
} }
} }
try json_writer.writeAll("]}"); try json_writer.writeAll("],\"tokens\":");
// write tokens as JSON
const tokens_json = try std.json.stringifyAlloc(alloc, tokens.items, .{});
defer alloc.free(tokens_json);
try json_writer.writeAll(tokens_json);
try json_writer.writeAll("}");
try stdout.print("{s}", .{json_arrl.items}); try stdout.print("{s}", .{json_arrl.items});
try bw.flush(); try bw.flush();