summaryrefslogtreecommitdiff
path: root/src/main.zig
diff options
context:
space:
mode:
authorStefan Weigl-Bosker <stefan@s00.xyz>2024-12-20 17:22:33 -0500
committerStefan Weigl-Bosker <stefan@s00.xyz>2024-12-20 17:22:33 -0500
commit32d0ac56c27719c6fcde70c51238f11cf5f44141 (patch)
treeda490e13f07be4573a0530c184fd873dc9c824dc /src/main.zig
parentdca73fef741a57c8cc1913def98a305c2b709391 (diff)
downloadlg-32d0ac56c27719c6fcde70c51238f11cf5f44141.tar.gz
regex parsing
Diffstat (limited to 'src/main.zig')
-rw-r--r--src/main.zig37
1 files changed, 17 insertions, 20 deletions
diff --git a/src/main.zig b/src/main.zig
index 8964c3c..f28ab18 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -9,26 +9,23 @@ pub fn main() !void {
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 => {},
- }
- }
+
+ const tl = try lexer.scan();
+
+ var it = tl.first;
+ while (it) |node| : (it = node.next) {
+ try stdio.print("{}\n", .{&(node.data)});
}
+
+ const parser = try allocator.create(Regex.Parser);
+
+ parser.* = Regex.Parser.init(&lexer.tokens, &allocator);
+
+ _ = try parser.parseRe();
+
+ lexer.deinit();
+ allocator.destroy(lexer);
+ allocator.destroy(parser);
}