lang: do as many semantic errors as possible before ParseFail

This commit is contained in:
Luna 2019-08-08 20:30:24 -03:00
parent 90bc830a9a
commit a0bf1e2723
1 changed files with 4 additions and 1 deletions

View File

@ -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;
}
};