This commit adds --parser argument to specify which parser to use to read the file.
(削除) This is only an arg. There isn't any field in the config file to set a specific parser. (削除ここまで)
--parser arg #21
parser-option into master This commit adds --parser argument to specify which parser to use to read the file.
(削除) This is only an arg. There isn't any field in the config file to set a specific parser. (削除ここまで)
@ -35,0 +49,4 @@
list[pos]=split.next().?;
pos+=1;
}
break:vlist;
The parser list should be comptime-generated
@ -67,22 +88,32 @@ pub fn getOptions(args: argparse.ParseResult, stdout: std.fs.File) !DisplayOptio
for(root.ast.fields)|field|{
Maybe it's just me, but I try to avoid OOM panics. I think panics should only be used in two scenarios:
Running out of memory is definitely a state external to the program and should be handled gracefully.
@ -1,19 +1,32 @@
conststd=@import("std");
We should still run matches() and print an error if it's not an appropriate file when a parser is explicitly specified. Otherwise, garbage will be printed.
This will panic. Could you add an else statement that prints an error?
Is something like this okay? Maybe we can print it in red (if color support is enabled).
diff --git a/src/parser.zig b/src/parser.zig
index da609ba..b41498c 100644
--- a/src/parser.zig
+++ b/src/parser.zig
@@ -21,6 +21,9 @@ pub fn getColors(allocator: std.mem.Allocator, reader: std.io.AnyReader, options
if (parser.matches(data)) {
parser.getColors(colors, data);
return colors;
+ } else {
+ std.debug.print("The specified parser doesn't match the file format!\n", .{});
+ std.process.exit(1);
}
}
} else if (parser.matches(data)) {
Yeah, just do that basic print. Maybe wirh an "Error:" prefix. I wanted to unify error reporting, but haven't done so yet. When I do I'll update it :)
No due date set.
No dependencies set.
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?