feat: choice expression nodes extended to full content parsing
This commit is contained in:
parent
066369cc13
commit
aad95a75ee
8 changed files with 380 additions and 165 deletions
|
|
@ -782,6 +782,7 @@ fn resolveOutputStream(
|
|||
gpa: std.mem.Allocator,
|
||||
stream: []const OutputCommand,
|
||||
) ![]const u8 {
|
||||
var glue_active = false;
|
||||
var pending_newline = false;
|
||||
var result: std.ArrayListUnmanaged(u8) = .empty;
|
||||
defer result.deinit(gpa);
|
||||
|
|
@ -790,17 +791,20 @@ fn resolveOutputStream(
|
|||
switch (cmd) {
|
||||
.value => |value| {
|
||||
if (pending_newline) {
|
||||
pending_newline = false;
|
||||
try result.append(gpa, '\n');
|
||||
pending_newline = false;
|
||||
}
|
||||
glue_active = false;
|
||||
const str = try Object.String.fromValue(story, value);
|
||||
try result.appendSlice(gpa, str.toSlice());
|
||||
},
|
||||
.line => {
|
||||
if (result.items.len > 0)
|
||||
pending_newline = true;
|
||||
if (!glue_active) pending_newline = true;
|
||||
},
|
||||
.glue => {
|
||||
pending_newline = false;
|
||||
glue_active = true;
|
||||
},
|
||||
.glue => pending_newline = false,
|
||||
}
|
||||
}
|
||||
return result.toOwnedSlice(gpa);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue