const std = @import("std"); const tok = @import("tokenizer.zig"); const Token = tok.Token; const typ = union { Funct: struct { inputtyp: []*typ, bodytyp: *typ, rettyp: *typ, }, Type: union { Int: u32, Float: f32, Bool: bool, String: []const u8, }, }; var typmap: std.AutoHashMap([]const u8, typ) = undefined; var index: u32 = 0; pub fn parse(allocator: std.mem.Allocator, toks: []Token) void { typmap = std.AutoHashMap([]const u8, typ).init(allocator); parser: switch (toks[0]) { .LPAREN => break :parser typedef(toks), .BUILTIN => |b| break :parser builtin(toks, b), .FUNC => |f| break :parser funcdef(toks, f), } } fn typedef(allocator: std.mem.Allocator, toks: []Token) !Token { index += 1; const name = toks[index]; var inputTyp: typ = undefined; switch (name) { .FUNC => { var inputArr = std.ArrayList(typ){}; while (toks[index] != .RPAREN) : (index += 1) { if (toks[index] != .LARROW) return error{UnexpectedToken}; index += 1; inputArr.append(allocator, toks[index]); // fix this please } }, } while (toks[index] != .PERIOD) : (index += 1) { switch (toks[index]) { } } return toks[index]; } fn builtin(toks: []Token, fun: []const u8) Token { _=fun; _=toks; } fn funcdef(toks: []Token, fun: []const u8) Token { _=fun; _=toks; }