aboutsummaryrefslogtreecommitdiff
path: root/src/recognizer.zig
diff options
context:
space:
mode:
authorNathan Reiner <nathan@nathanreiner.xyz>2025-08-27 13:48:12 +0200
committerNathan Reiner <nathan@nathanreiner.xyz>2025-08-27 13:48:12 +0200
commitf37a4aeb0e7d21d7e006a0f54c9dfdbc974b811f (patch)
tree0d4fc1335b445b68e0d2bcda0ccffeec4935658c /src/recognizer.zig
parentae10b7d764d9587ab92a682781f8479107e8dff0 (diff)
first sketch of pexpex
Diffstat (limited to 'src/recognizer.zig')
-rw-r--r--src/recognizer.zig8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/recognizer.zig b/src/recognizer.zig
index 6af7de1..967aba0 100644
--- a/src/recognizer.zig
+++ b/src/recognizer.zig
@@ -113,26 +113,31 @@ pub fn check(
for (input) |character| {
for (processing_queue.items) |base| {
try forward_queue.append(.{ base.state, base });
- try node_cache.put(base.state, base);
+
+ std.debug.print("-----\n", .{});
while (forward_queue.pop()) |checkpoint| {
const pex_node, const last_node = checkpoint;
switch (pex_node.instruction) {
.check => |t| if (t == character) {
+ std.debug.print("check '{}'\n", .{t});
if (pex_node.next) |next| {
const node = try graph.clone(last_node, next);
try next_processing_queue.append(node);
}
},
.@"return" => {
+ std.debug.print("return\n", .{});
for (last_node.parents.items) |parent| {
if (parent.state.next) |next| {
+ std.debug.print("return to {}\n", .{next});
try forward_queue.append(.{next, parent});
}
}
},
.call => |id| {
+ std.debug.print("call <{}>\n", .{id});
const non_terminal = pex.grammar.non_terminal_by_id(id);
for (non_terminal.rules(), pex.blocks[id].heads.items) |child_rule, head| {
if (
@@ -152,6 +157,7 @@ pub fn check(
}
},
.jump => |jump_next| {
+ std.debug.print("jump {any}\n", .{jump_next.items});
if (pex_node.next) |next| {
try forward_queue.append(.{next, last_node});
}