authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2023-05-04 16:06:19 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2023-05-04 16:06:19 -07:00
logc4ea6821d39101414a44f0c2caa964fcde4a7e75
treea086bdc15703083ea732a62c18e8579755ef078e
parent9a0006c9365b60df65274b14e26d416798c1341f

let functions disambiguate whether or not theyre raw based on extra '#'


2 files changed, 4 insertions(+), 1 deletions(-)

src/astgen.zig+3
......@@ -51,6 +51,7 @@ pub const Body = []const Value;
5151
5252pub const Fn = struct {
5353 name: string,
54 raw: bool,
5455 args: []const []const string,
5556};
5657
......@@ -145,6 +146,7 @@ const Parser = struct {
145146 }
146147 if (self.tryEatSymbol("{")) {
147148 if (self.tryEatSymbol("#")) {
149 const fraw = self.tryEatSymbol("#");
148150 const w = self.eat(.word);
149151 if (std.meta.stringToEnum(Block.Type, w)) |name| {
150152 const args = self.doArgs();
......@@ -174,6 +176,7 @@ const Parser = struct {
174176 }
175177 return Value{ .function = .{
176178 .name = w,
179 .raw = fraw,
177180 .args = self.doArgs(),
178181 } };
179182 }
src/lib.zig+1-1
......@@ -171,7 +171,7 @@ inline fn do(comptime Ctx: type, alloc: std.mem.Allocator, writer: anytype, comp
171171 const field_name = comptime std.fmt.comptimePrint("{d}", .{i + 2});
172172 @field(args, field_name) = if (comptime std.mem.eql(u8, arg[0], "this")) search(arg[1..], data) else search(arg, ctx);
173173 }
174 const repvalue = astgen.Value{ .replacement = .{ .arms = &.{"this"} } };
174 const repvalue = astgen.Value{ .replacement = .{ .arms = &.{"this"}, .raw = v.raw } };
175175 try @call(.auto, func, args);
176176 try do(Ctx, alloc, writer, repvalue, try list.toOwnedSlice(), ctx, indent, flag1);
177177 return;