| ... | ... | @@ -36,9 +36,9 @@ pub fn parse(alloc: std.mem.Allocator, path: string, inreader: anytype) anyerror |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | fn parseElement(alloc: std.mem.Allocator, p: *Parser) anyerror!ValueIndex { |
| 39 | | try parseWs(alloc, p); |
| 39 | try parseWs(p); |
| 40 | 40 | const v = try parseValue(alloc, p); |
| 41 | | parseWs(alloc, p) catch |err| switch (err) { |
| 41 | parseWs(p) catch |err| switch (err) { |
| 42 | 42 | error.EndOfStream => {}, |
| 43 | 43 | else => |e| return e, |
| 44 | 44 | }; |
| ... | ... | @@ -63,21 +63,21 @@ fn parseObject(alloc: std.mem.Allocator, p: *Parser) anyerror!?ValueIndex { |
| 63 | 63 | defer members.deinit(alloc); |
| 64 | 64 | |
| 65 | 65 | while (true) { |
| 66 | | try parseWs(alloc, p); |
| 66 | try parseWs(p); |
| 67 | 67 | if (try p.eatByte('}')) |_| break; |
| 68 | 68 | |
| 69 | 69 | const key = try parseString(alloc, p) orelse return error.JsonExpectedObjectKey; |
| 70 | | try parseWs(alloc, p); |
| 70 | try parseWs(p); |
| 71 | 71 | _ = try p.eatByte(':') orelse return error.JsonExpectedObjectColon; |
| 72 | | try parseWs(alloc, p); |
| 72 | try parseWs(p); |
| 73 | 73 | const value = try parseValue(alloc, p); |
| 74 | 74 | try members.put(alloc, key, value); |
| 75 | | try parseWs(alloc, p); |
| 75 | try parseWs(p); |
| 76 | 76 | _ = try p.eatByte(',') orelse { |
| 77 | 77 | _ = try p.eatByte('}') orelse return error.JsonExpectedTODO; |
| 78 | 78 | break; |
| 79 | 79 | }; |
| 80 | | try parseWs(alloc, p); |
| 80 | try parseWs(p); |
| 81 | 81 | if (try p.eatByte('}')) |_| break; |
| 82 | 82 | } |
| 83 | 83 | return try p.addObject(alloc, &members); |
| ... | ... | @@ -90,17 +90,17 @@ fn parseArray(alloc: std.mem.Allocator, p: *Parser) anyerror!?ValueIndex { |
| 90 | 90 | defer elements.deinit(alloc); |
| 91 | 91 | |
| 92 | 92 | while (true) { |
| 93 | | try parseWs(alloc, p); |
| 93 | try parseWs(p); |
| 94 | 94 | if (try p.eatByte(']')) |_| break; |
| 95 | 95 | |
| 96 | 96 | const elem = try parseValue(alloc, p); |
| 97 | 97 | try elements.append(alloc, elem); |
| 98 | | try parseWs(alloc, p); |
| 98 | try parseWs(p); |
| 99 | 99 | _ = try p.eatByte(',') orelse { |
| 100 | 100 | _ = try p.eatByte(']') orelse return error.JsonExpectedTODO; |
| 101 | 101 | break; |
| 102 | 102 | }; |
| 103 | | try parseWs(alloc, p); |
| 103 | try parseWs(p); |
| 104 | 104 | if (try p.eatByte(']')) |_| break; |
| 105 | 105 | } |
| 106 | 106 | return try p.addArray(alloc, elements.items); |
| ... | ... | @@ -189,8 +189,7 @@ fn parseNumber(alloc: std.mem.Allocator, p: *Parser) anyerror!?ValueIndex { |
| 189 | 189 | return try p.addNumber(alloc, characters.items); |
| 190 | 190 | } |
| 191 | 191 | |
| 192 | | fn parseWs(alloc: std.mem.Allocator, p: *Parser) !void { |
| 193 | | _ = alloc; |
| 192 | fn parseWs(p: *Parser) !void { |
| 194 | 193 | while (true) { |
| 195 | 194 | if (try p.eatByte(0x20)) |_| continue; // space |
| 196 | 195 | if (try p.eatByte(0x0A)) |_| continue; // NL |