summaryrefslogtreecommitdiff
path: root/src/main.zig
diff options
context:
space:
mode:
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 => {},
+ }
+ }
+ }
+}