And other

This commit is contained in:
2025-01-11 18:03:36 +01:00
parent 90edb94f7a
commit 78213df3ff
3 changed files with 213 additions and 218 deletions
+7 -12
View File
@@ -26,20 +26,18 @@ const State = enum {
add_struct, add_struct,
}; };
pub const Parser = struct { pub const Parser = @This();
toker: *Toker, toker: *Toker,
allocator: Allocator, allocator: Allocator,
pub fn init(toker: *Toker, allocator: Allocator) Parser { pub fn init(toker: *Toker, allocator: Allocator) Parser {
return .{ return .{
.allocator = allocator, .allocator = allocator,
.toker = toker, .toker = toker,
}; };
} }
// Rename something better and move it somewhere else pub fn parse(self: *Parser, struct_array: *std.ArrayList(SchemaStruct)) !void {
pub fn parse(self: *Parser, struct_array: *std.ArrayList(SchemaStruct)) !void {
var state: State = .expect_struct_name_OR_end; var state: State = .expect_struct_name_OR_end;
var keep_next = false; var keep_next = false;
@@ -239,7 +237,4 @@ pub const Parser = struct {
else => unreachable, else => unreachable,
}; };
} }
};
// TODO: Some test, weird that there isn't any yet
+8 -8
View File
@@ -55,11 +55,12 @@ pub const ThreadSyncContext = struct {
} }
}; };
pub const ThreadEngine = struct { pub const ThreadEngine = @This();
thread_arena: *std.heap.ThreadSafeAllocator,
thread_pool: *Pool,
pub fn init() ThreadEngine { thread_arena: *std.heap.ThreadSafeAllocator,
thread_pool: *Pool,
pub fn init() ThreadEngine {
thread_arena = std.heap.ThreadSafeAllocator{ thread_arena = std.heap.ThreadSafeAllocator{
.child_allocator = allocator, .child_allocator = allocator,
}; };
@@ -73,9 +74,8 @@ pub const ThreadEngine = struct {
.thread_pool = &thread_pool, .thread_pool = &thread_pool,
.thread_arena = &thread_arena, .thread_arena = &thread_arena,
}; };
} }
pub fn deinit(_: ThreadEngine) void { pub fn deinit(_: ThreadEngine) void {
thread_pool.deinit(); thread_pool.deinit();
} }
};
+4 -4
View File
@@ -1,4 +1,4 @@
pub const Loc = struct { pub const Loc = @This();
start: usize,
end: usize, start: usize,
}; end: usize,