fix command parsing
This commit is contained in:
parent
5d1bcf33ee
commit
1987c4d497
1 changed files with 15 additions and 6 deletions
21
src/lang.zig
21
src/lang.zig
|
@ -479,7 +479,7 @@ pub const CommandList = struct {
|
|||
|
||||
pub fn deinit(self: *Self) void {
|
||||
for (self.list.items) |cmd_ptr| {
|
||||
self.list.allocator.destroy(cmd_ptr);
|
||||
//self.list.allocator.destroy(cmd_ptr);
|
||||
inline for (@typeInfo(Command.Tag).Enum.fields) |field| {
|
||||
if (cmd_ptr.tag == @field(Command.Tag, field.name)) {
|
||||
const actual_tag =
|
||||
|
@ -530,9 +530,9 @@ pub const Lang = struct {
|
|||
}
|
||||
|
||||
fn doError(self: *Lang, comptime fmt: []const u8, args: anytype) void {
|
||||
log.debug("ERROR! at line {}: ", .{self.line});
|
||||
log.debug(fmt, args);
|
||||
log.debug("\n", .{});
|
||||
log.err("ERROR! at line {}: ", .{self.line});
|
||||
log.err(fmt, args);
|
||||
log.err("\n", .{});
|
||||
self.has_error = true;
|
||||
}
|
||||
|
||||
|
@ -655,7 +655,16 @@ pub const Lang = struct {
|
|||
const struct_name = cmd_struct_decl.name;
|
||||
const cmd_struct_type = @field(Command, struct_name);
|
||||
|
||||
switch (@typeInfo(@TypeOf(cmd_struct_type))) {
|
||||
const info_of_info = @typeInfo(@TypeOf(cmd_struct_type));
|
||||
|
||||
switch (info_of_info) {
|
||||
.Type => {},
|
||||
else => continue,
|
||||
}
|
||||
|
||||
const info = @typeInfo(cmd_struct_type);
|
||||
|
||||
switch (info) {
|
||||
.Struct => {},
|
||||
else => continue,
|
||||
}
|
||||
|
@ -677,7 +686,7 @@ pub const Lang = struct {
|
|||
// Attempting to use ComptimeHashMap hits compiler bugs and I'm
|
||||
// not sure if we can map strings to *types* in it.
|
||||
|
||||
if (std.mem.eql(u8, &lowered_command_name, command_string)) {
|
||||
if ((!found) and std.mem.eql(u8, &lowered_command_name, command_string)) {
|
||||
found = true;
|
||||
try self.parseCommandArguments(cmd_struct_type, &tok_it, &cmds);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue