fix body consume
This commit is contained in:
parent
11f810a5f3
commit
cf45f3f3ee
|
@ -130,9 +130,10 @@ pub const Parser = struct {
|
||||||
while (true) {
|
while (true) {
|
||||||
var tok = self.peek();
|
var tok = self.peek();
|
||||||
|
|
||||||
if (tok.ttype == .RightParen) break;
|
switch (tok.ttype) {
|
||||||
if (tok.ttype != .Identifier) {
|
.RightParen => break,
|
||||||
try self.doError("expected identifier, got {}", tok.ttype);
|
.Identifier => {},
|
||||||
|
else => try self.doError("expected identifier, got {}", tok.ttype),
|
||||||
}
|
}
|
||||||
|
|
||||||
var typetok = try self.nextToken();
|
var typetok = try self.nextToken();
|
||||||
|
@ -145,9 +146,11 @@ pub const Parser = struct {
|
||||||
|
|
||||||
std.debug.warn("param! {}\n", param);
|
std.debug.warn("param! {}\n", param);
|
||||||
try param_list.append(param);
|
try param_list.append(param);
|
||||||
|
tok = try self.nextToken();
|
||||||
}
|
}
|
||||||
|
|
||||||
// function body
|
// function body
|
||||||
|
_ = try self.nextToken();
|
||||||
_ = try self.consumeSingle(.LeftBrace);
|
_ = try self.consumeSingle(.LeftBrace);
|
||||||
while (true) {
|
while (true) {
|
||||||
var tok = self.peek();
|
var tok = self.peek();
|
||||||
|
@ -183,7 +186,7 @@ pub const Parser = struct {
|
||||||
if (token.ttype == .EOF) break;
|
if (token.ttype == .EOF) break;
|
||||||
|
|
||||||
var node = try self.processToken(token);
|
var node = try self.processToken(token);
|
||||||
std.debug.warn("{}\n", node.*);
|
std.debug.warn("node: {}\n", node.*);
|
||||||
try root.Root.append(node);
|
try root.Root.append(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue