2019-07-01 18:01:43 +00:00
|
|
|
const std = @import("std");
|
2019-06-05 23:29:03 +00:00
|
|
|
const tokens = @import("tokens.zig");
|
|
|
|
const Token = tokens.Token;
|
|
|
|
|
2019-07-01 18:01:43 +00:00
|
|
|
pub const NodeList = std.ArrayList(*Node);
|
2019-06-05 02:44:27 +00:00
|
|
|
|
2019-07-01 18:01:43 +00:00
|
|
|
pub const NodeType = enum {
|
|
|
|
Root,
|
|
|
|
FnDecl,
|
2019-06-05 02:44:27 +00:00
|
|
|
};
|
|
|
|
|
2019-07-01 18:01:43 +00:00
|
|
|
pub const FnDecl = struct {
|
|
|
|
func_name: []const u8,
|
2019-06-05 02:44:27 +00:00
|
|
|
};
|
|
|
|
|
2019-07-01 18:01:43 +00:00
|
|
|
pub const Node = union(NodeType) {
|
|
|
|
Root: NodeList,
|
|
|
|
FnDecl: FnDecl,
|
2019-06-05 23:29:03 +00:00
|
|
|
};
|
|
|
|
|
2019-07-01 18:01:43 +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
|
|
|
}
|