vig/src/ast.zig

26 lines
502 B
Zig

const std = @import("std");
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 {
func_name: []const u8,
};
pub const Node = union(NodeType) {
Root: NodeList,
FnDecl: FnDecl,
};
pub fn mkRoot(allocator: *std.mem.Allocator) !*Node {
var node = try allocator.create(Node);
node.* = Node{ .Root = NodeList.init(allocator) };
return node;
}