lang: show line where error happened
This commit is contained in:
parent
ab2e8884b8
commit
90bc830a9a
2 changed files with 8 additions and 2 deletions
|
@ -193,7 +193,7 @@ pub const Image = struct {
|
||||||
sseek(out_file, start);
|
sseek(out_file, start);
|
||||||
|
|
||||||
while (i <= end) : (i += buf.len) {
|
while (i <= end) : (i += buf.len) {
|
||||||
std.debug.warn("i={}, buf.len={}, end={}\n", i, buf.len, end);
|
std.debug.warn("\t\ti={}, buf.len={}, end={}\n", i, buf.len, end);
|
||||||
sseek(self.sndfile, i);
|
sseek(self.sndfile, i);
|
||||||
sseek(out_file, i);
|
sseek(out_file, i);
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ pub const ParseError = error{
|
||||||
UnknownCommand,
|
UnknownCommand,
|
||||||
ArgRequired,
|
ArgRequired,
|
||||||
FloatParseFail,
|
FloatParseFail,
|
||||||
|
ParseFail,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const CommandType = enum {
|
pub const CommandType = enum {
|
||||||
|
@ -290,6 +291,7 @@ pub const Lang = struct {
|
||||||
var splitted_it = std.mem.separate(data, ";");
|
var splitted_it = std.mem.separate(data, ";");
|
||||||
try self.fillKeywords();
|
try self.fillKeywords();
|
||||||
var cmds = CommandList.init(self.allocator);
|
var cmds = CommandList.init(self.allocator);
|
||||||
|
var idx: usize = 0;
|
||||||
|
|
||||||
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");
|
||||||
|
@ -324,9 +326,13 @@ pub const Lang = struct {
|
||||||
errdefer self.allocator.destroy(cmd_ptr);
|
errdefer self.allocator.destroy(cmd_ptr);
|
||||||
|
|
||||||
cmd_ptr.* = Command{ .command = ctype, .args = args };
|
cmd_ptr.* = Command{ .command = ctype, .args = args };
|
||||||
try self.validateCommand(cmd_ptr);
|
self.validateCommand(cmd_ptr) catch |err| {
|
||||||
|
std.debug.warn("error at line {}: {}\n", idx, err);
|
||||||
|
return ParseError.ParseFail;
|
||||||
|
};
|
||||||
|
|
||||||
try cmds.append(cmd_ptr);
|
try cmds.append(cmd_ptr);
|
||||||
|
idx += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return cmds;
|
return cmds;
|
||||||
|
|
Loading…
Reference in a new issue