|
| 1 | +// ============================================================================ |
| 2 | +// AST Serializer |
| 3 | +// ============================================================================ |
| 4 | +// |
| 5 | +// Serializes AST nodes to JSON format with comprehensive customization options. |
| 6 | +// |
| 7 | +// FEATURES: |
| 8 | +// • Multiple output formats (JSON, compact, pretty-printed) |
| 9 | +// • Optional span/type/lexeme inclusion |
| 10 | +// • Depth limiting for large trees |
| 11 | +// • Streaming to writer for memory efficiency |
| 12 | +// |
| 13 | +// SECTIONS: |
| 14 | +// • Options & initialization |
| 15 | +// • Core serialization infrastructure |
| 16 | +// • Top-level node serialization |
| 17 | +// • Statement serialization |
| 18 | +// • Expression serialization |
| 19 | +// • Helper serializers |
| 20 | +// • Pattern serializers |
| 21 | +// |
| 22 | +// ============================================================================ |
| 23 | + |
1 | 24 | const std = @import("std"); |
2 | 25 | const ast = @import("../ast.zig"); |
3 | 26 | const AstNode = ast.AstNode; |
@@ -173,6 +196,15 @@ pub const AstSerializer = struct { |
173 | 196 | } |
174 | 197 | } |
175 | 198 |
|
| 199 | + // ======================================================================== |
| 200 | + // TOP-LEVEL NODE SERIALIZATION |
| 201 | + // ======================================================================== |
| 202 | + // serializeContract, serializeFunction, serializeModule, serializeConstant, |
| 203 | + // serializeVariableDecl, serializeStructDecl, serializeEnumDecl, |
| 204 | + // serializeLogDecl, serializeImport, serializeErrorDecl, serializeBlock, |
| 205 | + // serializeTryBlock |
| 206 | + // ======================================================================== |
| 207 | + |
176 | 208 | fn serializeContract(self: *AstSerializer, contract: *const ast.ContractNode, writer: anytype, indent: u32, depth: u32) SerializationError!void { |
177 | 209 | try self.writeField(writer, "type", "Contract", indent + 1, true); |
178 | 210 | try self.writeField(writer, "name", contract.name, indent + 1, false); |
|
0 commit comments