diff --git a/src/main.zig b/src/main.zig index 6c4e940..87f19e1 100644 --- a/src/main.zig +++ b/src/main.zig @@ -333,7 +333,7 @@ fn processCommand(allocator: std.mem.Allocator, sentence: [:0]const u8, parser: } const object_words = tree.sentenceObject() catch |err| { - std.log.err("Failed to extract object: {}\n", .{err}); + std.log.err("Failed to extract object: {}\nParse tree: {f}", .{ err, tree }); continue; }; defer allocator.free(object_words); @@ -342,6 +342,7 @@ fn processCommand(allocator: std.mem.Allocator, sentence: [:0]const u8, parser: continue; } + std.log.debug("{f}", .{tree}); var aw = std.Io.Writer.Allocating.init(allocator); defer aw.deinit(); const aw_writer = &aw.writer; @@ -353,6 +354,15 @@ fn processCommand(allocator: std.mem.Allocator, sentence: [:0]const u8, parser: } std.log.debug("{s}]", .{aw.written()}); + aw.clearRetainingCapacity(); + try aw_writer.writeAll("Action words: ["); + first = true; + for (action_words) |word| { + try aw_writer.print("{s}\"{s}\"", .{ if (!first) ", " else "", word }); + first = false; + } + std.log.debug("{s}]", .{aw.written()}); + if (parseAction(action_words)) |action| { if (try extractDevice(allocator, object_words, devices)) |entry| { if (builtin.is_test)