| ... | ... | @@ -14,7 +14,7 @@ const tokenize = @import("./tokenize.zig"); |
| 14 | 14 | const astgen = @import("./astgen.zig"); |
| 15 | 15 | |
| 16 | 16 | pub fn parse(comptime input: []const u8) astgen.Value { |
| 17 | | return astgen.Value{ .element = astgen.do(tokenize.do(input, &.{ '[', '=', ']', '(', ')', '{', '}', '#', '/', '.' })) }; |
| 17 | return astgen.Value{ .element = astgen.do(tokenize.do(input, &.{ '[', '=', ']', '(', ')', '{', '}', '#', '/', '.', '<', '>' })) }; |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | pub fn compile(writer: anytype, comptime value: astgen.Value, data: anytype) !void { |
| ... | ... | @@ -83,20 +83,22 @@ fn do(writer: anytype, comptime value: astgen.Value, data: anytype, ctx: anytype |
| 83 | 83 | .@"if" => { |
| 84 | 84 | comptime assertEqual(v.args.len, 1); |
| 85 | 85 | const x = search(v.args[0], data); |
| 86 | | switch (@typeInfo(@TypeOf(x))) { |
| 87 | | .Bool => if (x) try do(writer, body, data, ctx, indent, flag1), |
| 88 | | .Optional => if (x) |_| try do(writer, body, data, ctx, indent, flag1), |
| 86 | const content = switch (@typeInfo(@TypeOf(x))) { |
| 87 | .Bool => if (x) v.body else v.bttm, |
| 88 | .Optional => if (x) |_| v.body else v.bttm, |
| 89 | 89 | else => unreachable, |
| 90 | | } |
| 90 | }; |
| 91 | try do(writer, body, content, ctx, indent, flag1); |
| 91 | 92 | }, |
| 92 | 93 | .ifnot => { |
| 93 | 94 | comptime assertEqual(v.args.len, 1); |
| 94 | 95 | const x = search(v.args[0], data); |
| 95 | | switch (@typeInfo(@TypeOf(x))) { |
| 96 | | .Bool => if (x) {} else try do(writer, body, data, ctx, indent, flag1), |
| 97 | | .Optional => if (x) |_| {} else try do(writer, body, data, ctx, indent, flag1), |
| 96 | const content = switch (@typeInfo(@TypeOf(x))) { |
| 97 | .Bool => if (x) v.bttm else v.body, |
| 98 | .Optional => if (x) |_| v.bttm else v.body, |
| 98 | 99 | else => unreachable, |
| 99 | | } |
| 100 | }; |
| 101 | try do(writer, body, content, ctx, indent, flag1); |
| 100 | 102 | }, |
| 101 | 103 | .ifequal => { |
| 102 | 104 | comptime assertEqual(v.args.len, 2); |