fix function parameter parsing

- fix struct's err ctx
 - rm err when parsing get exprs and others
This commit is contained in:
Luna 2019-09-20 13:32:35 -03:00
parent 075d2f22a5
commit 126bd476d6

View file

@ -463,12 +463,15 @@ pub const Parser = struct {
while (self.peek().typ != .RightParen) {
const param_name = try self.consumeSingle(.Identifier);
_ = try self.consumeSingle(.Colon);
const param_type = try self.consumeSingle(.Identifier);
try param_list.append(ast.ParamDecl{
.name = param_name,
.typ = param_type,
});
if (self.check(.Comma)) _ = try self.consumeSingle(.Comma);
}
_ = try self.consumeSingle(.RightParen);
@ -547,7 +550,7 @@ pub const Parser = struct {
fn parseStructDecl(self: *@This()) !*Node {
var fields = ast.FieldList.init(self.allocator);
errdefer fields.deinit();
self.setErrContext("struct", name);
self.setErrContext("struct");
_ = try self.consumeSingle(.Struct);
var name = try self.consumeSingle(.Identifier);
@ -1046,7 +1049,8 @@ pub const Parser = struct {
expr = try self.mkGet(expr, name);
}
} else {
return self.tokenError(self.peek(), "Expect expression.");
//return self.tokenError(self.peek(), "Expect expression.");
break;
}
}