summaryrefslogtreecommitdiff
path: root/src/main.zig
diff options
context:
space:
mode:
authorStefan Weigl-Bosker <stefan@s00.xyz>2024-12-14 18:10:39 -0500
committerStefan Weigl-Bosker <stefan@s00.xyz>2024-12-14 18:10:39 -0500
commit94b86481395cb2d2a594bb98a1380b9ddc8aa900 (patch)
treefb73afee136f0895392e7cc7eee3528c242883a8 /src/main.zig
downloadlg-94b86481395cb2d2a594bb98a1380b9ddc8aa900.tar.gz
inital commit
Diffstat (limited to 'src/main.zig')
-rw-r--r--src/main.zig34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/main.zig b/src/main.zig
new file mode 100644
index 0000000..8964c3c
--- /dev/null
+++ b/src/main.zig
@@ -0,0 +1,34 @@
+const std = @import("std");
+const Regex = @import("regex.zig");
+
+pub fn main() !void {
+ const stdio = std.io.getStdIn().writer();
+ var gpa = std.heap.GeneralPurposeAllocator(.{}){};
+ var allocator = gpa.allocator();
+
+ defer _ = gpa.deinit();
+
+ const lexer = try allocator.create(Regex.Lexer);
+ lexer.* = Regex.Lexer.init("abc|123[a-Z]()+", &allocator);
+ defer allocator.destroy(lexer);
+
+ while (true) {
+ const token = lexer.advance() catch |err| switch (err) {
+ Regex.Lexer.Error.EndOfBuffer => {
+ break;
+ },
+ else => {
+ return err;
+ },
+ };
+
+ try stdio.print("{}\n", .{token});
+
+ if (token.value) |v| {
+ switch (v) {
+ .Class => |*rl| rl.deinit(),
+ else => {},
+ }
+ }
+ }
+}