Skip to content

Commit ec26bf2

Browse files
committed
continue to polish modules of Ora pipeline
1 parent a4317a7 commit ec26bf2

28 files changed

+1510
-157
lines changed

src/ast/ast_serializer.zig

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,26 @@
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+
124
const std = @import("std");
225
const ast = @import("../ast.zig");
326
const AstNode = ast.AstNode;
@@ -173,6 +196,15 @@ pub const AstSerializer = struct {
173196
}
174197
}
175198

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+
176208
fn serializeContract(self: *AstSerializer, contract: *const ast.ContractNode, writer: anytype, indent: u32, depth: u32) SerializationError!void {
177209
try self.writeField(writer, "type", "Contract", indent + 1, true);
178210
try self.writeField(writer, "name", contract.name, indent + 1, false);

src/ast/ast_visitor.zig

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,24 @@
1+
// ============================================================================
2+
// AST Visitor
3+
// ============================================================================
4+
//
5+
// Generic visitor pattern for traversing AST nodes with flexible strategies.
6+
//
7+
// FEATURES:
8+
// • Comptime-parameterized visitor with custom context
9+
// • Optional visit callbacks for selective traversal
10+
// • Depth-first and breadth-first strategies
11+
// • Specialized visitors (symbol/type collecting)
12+
// • Type-erased AnyVisitor wrapper
13+
//
14+
// USAGE:
15+
// const MyCtx = struct { count: usize };
16+
// var ctx = MyCtx{ .count = 0 };
17+
// var visitor = Visitor(MyCtx, void){ .context = &ctx, .visitFunc = myFn };
18+
// visitor.visit(&node);
19+
//
20+
// ============================================================================
21+
122
const std = @import("std");
223
const ast = @import("../ast.zig");
324

src/ast/type_info.zig

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1+
// ============================================================================
2+
// Type Information System
3+
// ============================================================================
4+
//
5+
// Unified type system providing comprehensive type representation,
6+
// validation, and operations for all AST nodes.
7+
//
8+
// KEY CONCEPTS:
9+
// • TypeInfo: Unified type representation (category + ora_type + source)
10+
// • TypeCategory: High-level classification (Integer, String, Array, etc.)
11+
// • OraType: Specific type details (u8, u256, arrays, maps, 80+ variants)
12+
// • TypeSource: How type was determined (explicit, inferred, unknown)
13+
//
14+
// SECTIONS:
15+
// • TypeInfo core & common types
16+
// • TypeCategory & OraType definitions
17+
// • Type rendering & display
18+
//
19+
// ============================================================================
20+
121
const std = @import("std");
222
const SourceSpan = @import("../ast.zig").SourceSpan;
323

0 commit comments

Comments
 (0)