diff options
| author | Nathan Reiner <nathan@nathanreiner.xyz> | 2025-05-15 19:00:08 +0200 |
|---|---|---|
| committer | Nathan Reiner <nathan@nathanreiner.xyz> | 2025-05-15 19:00:08 +0200 |
| commit | 0de78f3adf3dd671560b657b94773c42177040d5 (patch) | |
| tree | 87511330eebee567d6fd938faae10da311e9379b /src | |
| parent | ad668a6cbeb27e6557e71e193582027e291280ca (diff) | |
recognizer: change condition since epsilons are quite rare
Diffstat (limited to 'src')
| -rw-r--r-- | src/recognizer.zig | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/recognizer.zig b/src/recognizer.zig index 05db2c7..696a80a 100644 --- a/src/recognizer.zig +++ b/src/recognizer.zig @@ -147,7 +147,10 @@ pub fn check(grammar: *Grammar, input: []const u8, inner_allocator: std.mem.Allo .non_terminal => |n| { const non_terminal = grammar.non_terminal_by_id(n); for (grammar.non_terminal_by_id(n).rules(), 0..) |child_rule, rule_index| { - if (child_rule.first.is_set(character)) { + if ( + child_rule.first.is_set(character) or + (child_rule.first.is_set(Character.EPSILON) and non_terminal.follows.is_set(character)) + ) { const state = State { .id = n, @@ -163,8 +166,6 @@ pub fn check(grammar: *Grammar, input: []const u8, inner_allocator: std.mem.Allo try node_cache.put(state, next); try forward_queue.append(.{state, next}); } - } else if (child_rule.first.is_set(Character.EPSILON) and non_terminal.follows.is_set(character)) { - @panic("not implemented"); } } }, |