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();
|
try self.fillKeywords();
|
||||||
var cmds = CommandList.init(self.allocator);
|
var cmds = CommandList.init(self.allocator);
|
||||||
var idx: usize = 0;
|
var idx: usize = 0;
|
||||||
|
var has_error = false;
|
||||||
|
|
||||||
while (splitted_it.next()) |stmt_orig| {
|
while (splitted_it.next()) |stmt_orig| {
|
||||||
var stmt = std.mem.trimRight(u8, stmt_orig, "\n");
|
var stmt = std.mem.trimRight(u8, stmt_orig, "\n");
|
||||||
|
@ -328,13 +329,15 @@ pub const Lang = struct {
|
||||||
cmd_ptr.* = Command{ .command = ctype, .args = args };
|
cmd_ptr.* = Command{ .command = ctype, .args = args };
|
||||||
self.validateCommand(cmd_ptr) catch |err| {
|
self.validateCommand(cmd_ptr) catch |err| {
|
||||||
std.debug.warn("error at line {}: {}\n", idx, err);
|
std.debug.warn("error at line {}: {}\n", idx, err);
|
||||||
return ParseError.ParseFail;
|
has_error = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
try cmds.append(cmd_ptr);
|
try cmds.append(cmd_ptr);
|
||||||
idx += 1;
|
idx += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (has_error) return ParseError.ParseFail;
|
||||||
|
|
||||||
return cmds;
|
return cmds;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue