diff options
| -rw-r--r-- | grammar/middle-recursion.grm | 2 | ||||
| -rw-r--r-- | src/argument.zig | 17 |
2 files changed, 13 insertions, 6 deletions
diff --git a/grammar/middle-recursion.grm b/grammar/middle-recursion.grm index 71cc71f..ccb8b58 100644 --- a/grammar/middle-recursion.grm +++ b/grammar/middle-recursion.grm @@ -1,3 +1,3 @@ -main -> 'a' main B | B +S -> 'a' S B | B A -> 'ab' B -> A | 'b' diff --git a/src/argument.zig b/src/argument.zig index a9c823d..75bb7bf 100644 --- a/src/argument.zig +++ b/src/argument.zig @@ -143,11 +143,6 @@ pub const Args = union(Mode) { const text = Entry.read_file(check(args.next()), allocator); defer allocator.free(text); - const grammar = Grammar.parse( - "main", - text, - allocator - ) catch |e| help(e); switch (mode) { .recognize => { @@ -162,6 +157,12 @@ pub const Args = union(Mode) { } else help(error.InvalidArgument); } + const grammar = Grammar.parse( + entry, + text, + allocator + ) catch |e| help(e); + return Self { .recognize = .{ .input = input orelse Entry.stdin(), @@ -191,6 +192,12 @@ pub const Args = union(Mode) { } else help(error.InvalidArgument); } + const grammar = Grammar.parse( + entry, + text, + allocator + ) catch |e| help(e); + return Self { .generate = .{ .count = count, |