.binary => |binary| try parenthesize(allocator, binary.operator.lexeme, &.{ binary.left, binary.right }),
.grouping => |grouping| try parenthesize(allocator, "group", &.{grouping.expression}),
.literal => |literal| switch (literal.value) {
- .nil => "nil",
- .boolean => |boolean| if (boolean) "true" else "false",
- .string => |string| string,
+ .nil => try allocator.dupe(u8, "nil"),
+ .boolean => |boolean| try std.fmt.allocPrint(allocator, "{}", .{boolean}),
+ .string => |string| try allocator.dupe(u8, string),
.number => |number| try std.fmt.allocPrint(allocator, "{}", .{number}),
},
.unary => |unary| try parenthesize(allocator, unary.operator.lexeme, &.{unary.right}),