aboutsummaryrefslogtreecommitdiff
path: root/src/lexer/Lexer.zig
diff options
context:
space:
mode:
authorAnhgelus Morhtuuzh <william@herges.fr>2026-04-17 18:07:11 +0200
committerAnhgelus Morhtuuzh <william@herges.fr>2026-04-17 18:07:11 +0200
commit87e5daf9156583072d9ccb9ff0fa074f65fa6836 (patch)
tree016d7bab36eac1a79b0a252ed8647af5b68bb028 /src/lexer/Lexer.zig
parent256a992e660869d28f5f2fd69bfe59a8ff591989 (diff)
style(): rename alloc into gpa
Diffstat (limited to 'src/lexer/Lexer.zig')
-rw-r--r--src/lexer/Lexer.zig28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/lexer/Lexer.zig b/src/lexer/Lexer.zig
index 2705347..2ccc065 100644
--- a/src/lexer/Lexer.zig
+++ b/src/lexer/Lexer.zig
@@ -18,9 +18,9 @@ pub fn init(content: []const u8) Error!Self {
return .{ .iter = view.iterator() };
}
-pub fn next(self: *Self, alloc: Allocator) Error!?Lexed {
- var acc = try std.ArrayList(u8).initCapacity(alloc, 2);
- errdefer acc.deinit(alloc);
+pub fn next(self: *Self, gpa: Allocator) Error!?Lexed {
+ var acc = try std.ArrayList(u8).initCapacity(gpa, 2);
+ errdefer acc.deinit(gpa);
var current_kind: ?Lexed.Kind = null;
while (self.iter.nextCodepointSlice()) |rune| {
@@ -35,7 +35,7 @@ pub fn next(self: *Self, alloc: Allocator) Error!?Lexed {
const res = self.getCurrentKind(current_kind, rune, acc.items);
current_kind = res.kind;
override_if = res.override_if;
- try acc.appendSlice(alloc, rune);
+ try acc.appendSlice(gpa, rune);
}
// conds here to avoid creating complex condition in while
const next_rune = self.iter.peek(1);
@@ -57,10 +57,10 @@ pub fn next(self: *Self, alloc: Allocator) Error!?Lexed {
}
}
const kind = current_kind orelse {
- acc.deinit(alloc);
+ acc.deinit(gpa);
return null;
};
- return .init(alloc, kind, acc);
+ return .init(gpa, kind, acc);
}
const kindRes = struct {
@@ -149,8 +149,8 @@ fn requiresSpace(k: Lexed.Kind) bool {
};
}
-fn doTest(alloc: Allocator, l: *Self, k: Lexed.Kind, v: []const u8) !void {
- var first = (try l.next(alloc)).?;
+fn doTest(gpa: Allocator, l: *Self, k: Lexed.Kind, v: []const u8) !void {
+ var first = (try l.next(gpa)).?;
defer first.deinit();
std.testing.expect(first.equals(k, v)) catch |err| {
std.debug.print("{}({s})\n", .{ first.kind, first.content.items });
@@ -178,14 +178,14 @@ test "lexer common" {
var arena = std.heap.DebugAllocator(.{}).init;
defer _ = arena.deinit();
- const alloc = arena.allocator();
+ const gpa = arena.allocator();
var l = try init("# hello world :)");
- try doTest(alloc, &l, .title, "#");
- try doTest(alloc, &l, .literal, "hello world ");
- try doTest(alloc, &l, .ref, ":");
- try doTest(alloc, &l, .link, ")");
+ try doTest(gpa, &l, .title, "#");
+ try doTest(gpa, &l, .literal, "hello world ");
+ try doTest(gpa, &l, .ref, ":");
+ try doTest(gpa, &l, .link, ")");
- try expect(try l.next(alloc) == null);
+ try expect(try l.next(gpa) == null);
}