additional debug output

This commit is contained in:
Emil Lerch 2025-09-22 15:54:32 -07:00
parent 89a9316320
commit ea0de2f4d2
Signed by: lobo
GPG key ID: A7B62D657EF764F8

View file

@ -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)