parser: remove dead code

This commit is contained in:
Luna 2019-08-25 23:55:19 -03:00
parent c0c93183cb
commit 8f7535e14e
2 changed files with 2 additions and 41 deletions

View file

@ -8,7 +8,6 @@ pub const ExprList = std.ArrayList(*Expr);
pub const ParamList = std.ArrayList(ParamDecl); pub const ParamList = std.ArrayList(ParamDecl);
pub const ConstList = std.ArrayList(SingleConst); pub const ConstList = std.ArrayList(SingleConst);
// TODO convert FnCall to something like PrefixOp / InfixOp / SuffixOp
pub const NodeType = enum { pub const NodeType = enum {
Root, Root,
FnDecl, FnDecl,
@ -202,6 +201,8 @@ pub fn mkRoot(allocator: *std.mem.Allocator) !*Node {
return node; return node;
} }
// TODO move those functions to src/ast_print.zig
fn printIdent(ident: usize) void { fn printIdent(ident: usize) void {
var i: usize = 0; var i: usize = 0;
while (i < ident) : (i += 1) { while (i < ident) : (i += 1) {

View file

@ -333,43 +333,6 @@ pub const Parser = struct {
return root; 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 { fn parseFnDecl(self: *@This()) !?*Node {
var param_list = ast.ParamList.init(self.allocator); var param_list = ast.ParamList.init(self.allocator);
errdefer param_list.deinit(); errdefer param_list.deinit();
@ -412,9 +375,6 @@ pub const Parser = struct {
_ = try self.consumeSingle(.Equal); _ = try self.consumeSingle(.Equal);
var expr = try self.parseExpr(); var expr = try self.parseExpr();
// _ = try self.nextToken();
//const const_value = try self.consumeSingle(.Identifier);
try consts.append(ast.SingleConst{ try consts.append(ast.SingleConst{
.name = const_name, .name = const_name,
.expr = expr.Expr, .expr = expr.Expr,