parser: remove dead code
This commit is contained in:
parent
c0c93183cb
commit
8f7535e14e
2 changed files with 2 additions and 41 deletions
|
@ -8,7 +8,6 @@ pub const ExprList = std.ArrayList(*Expr);
|
|||
pub const ParamList = std.ArrayList(ParamDecl);
|
||||
pub const ConstList = std.ArrayList(SingleConst);
|
||||
|
||||
// TODO convert FnCall to something like PrefixOp / InfixOp / SuffixOp
|
||||
pub const NodeType = enum {
|
||||
Root,
|
||||
FnDecl,
|
||||
|
@ -202,6 +201,8 @@ pub fn mkRoot(allocator: *std.mem.Allocator) !*Node {
|
|||
return node;
|
||||
}
|
||||
|
||||
// TODO move those functions to src/ast_print.zig
|
||||
|
||||
fn printIdent(ident: usize) void {
|
||||
var i: usize = 0;
|
||||
while (i < ident) : (i += 1) {
|
||||
|
|
|
@ -333,43 +333,6 @@ pub const Parser = struct {
|
|||
return root;
|
||||
}
|
||||
|
||||
fn functionDecl(self: *Parser) !*ast.Node {
|
||||
|
||||
// function body
|
||||
_ = try self.nextToken();
|
||||
_ = try self.consumeSingle(.LeftBrace);
|
||||
var body = ast.NodeList.init(self.allocator);
|
||||
|
||||
while (true) {
|
||||
var tok = self.peek();
|
||||
if (tok.ttype == .RightBrace) break;
|
||||
|
||||
// TODO statements
|
||||
//var node = try self.processToken(tok);
|
||||
//std.debug.warn("stmt:{}\n", node);
|
||||
//try body.append(node);
|
||||
|
||||
tok = try self.nextToken();
|
||||
}
|
||||
|
||||
_ = try self.consumeSingle(.RightBrace);
|
||||
|
||||
return try self.mkFnDecl(name, param_list);
|
||||
}
|
||||
|
||||
fn processToken(self: *Parser, token: Token) anyerror!*ast.Node {
|
||||
var node = switch (token.ttype) {
|
||||
.Fn => try self.functionDecl(),
|
||||
.Identifier => try self.functionCall(),
|
||||
else => blk: {
|
||||
try self.doError("TODO handle {}\n", token.ttype);
|
||||
return Result.CompileError;
|
||||
},
|
||||
};
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
fn parseFnDecl(self: *@This()) !?*Node {
|
||||
var param_list = ast.ParamList.init(self.allocator);
|
||||
errdefer param_list.deinit();
|
||||
|
@ -412,9 +375,6 @@ pub const Parser = struct {
|
|||
_ = try self.consumeSingle(.Equal);
|
||||
|
||||
var expr = try self.parseExpr();
|
||||
// _ = try self.nextToken();
|
||||
//const const_value = try self.consumeSingle(.Identifier);
|
||||
|
||||
try consts.append(ast.SingleConst{
|
||||
.name = const_name,
|
||||
.expr = expr.Expr,
|
||||
|
|
Loading…
Reference in a new issue