vig/src/ast.zig

26 lines
497 B
Zig
Raw Normal View History

const std = @import("std");
2019-06-05 23:29:03 +00:00
const tokens = @import("tokens.zig");
const Token = tokens.Token;
pub const NodeList = std.ArrayList(*Node);
pub const NodeType = enum {
Root,
FnDecl,
};
pub const FnDecl = struct {
2019-07-01 18:25:07 +00:00
func_name: Token,
};
pub const Node = union(NodeType) {
Root: NodeList,
FnDecl: FnDecl,
2019-06-05 23:29:03 +00:00
};
pub fn mkRoot(allocator: *std.mem.Allocator) !*Node {
var node = try allocator.create(Node);
node.* = Node{ .Root = NodeList.init(allocator) };
return node;
2019-06-05 23:29:03 +00:00
}