lang: do as many semantic errors as possible before ParseFail
This commit is contained in:
parent
90bc830a9a
commit
a0bf1e2723
1 changed files with 4 additions and 1 deletions
|
@ -292,6 +292,7 @@ pub const Lang = struct {
|
|||
try self.fillKeywords();
|
||||
var cmds = CommandList.init(self.allocator);
|
||||
var idx: usize = 0;
|
||||
var has_error = false;
|
||||
|
||||
while (splitted_it.next()) |stmt_orig| {
|
||||
var stmt = std.mem.trimRight(u8, stmt_orig, "\n");
|
||||
|
@ -328,13 +329,15 @@ pub const Lang = struct {
|
|||
cmd_ptr.* = Command{ .command = ctype, .args = args };
|
||||
self.validateCommand(cmd_ptr) catch |err| {
|
||||
std.debug.warn("error at line {}: {}\n", idx, err);
|
||||
return ParseError.ParseFail;
|
||||
has_error = true;
|
||||
};
|
||||
|
||||
try cmds.append(cmd_ptr);
|
||||
idx += 1;
|
||||
}
|
||||
|
||||
if (has_error) return ParseError.ParseFail;
|
||||
|
||||
return cmds;
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue