dumb error
This commit is contained in:
parent
ee15bef4e1
commit
5bca03ea6b
36
language.zig
36
language.zig
@ -256,10 +256,10 @@ pub fn getValue(
|
||||
const s = self.skipSlots(tip);
|
||||
tip += s;
|
||||
} else {
|
||||
//for (self.property_map.keys(), self.property_map.values()) |k, v| {
|
||||
//std.debug.print("{}: {s}\n", .{ v.tip, @tagName(self.index.get(k)) });
|
||||
//std.debug.print("tip: {d}\n", .{tip});
|
||||
//}
|
||||
// for (self.property_map.keys(), self.property_map.values()) |k, v| {
|
||||
// std.debug.print("{}: {s}\n", .{ v.tip, @tagName(self.index.get(k)) });
|
||||
// std.debug.print("tip: {d}\n", .{k});
|
||||
// }
|
||||
return error.MissingKey;
|
||||
};
|
||||
return .{ .object = map };
|
||||
@ -296,21 +296,10 @@ pub fn parse(self: *Self, tokenizer: *Tokenizer) !usize {
|
||||
const scope_idx = query.get(query.len - 1);
|
||||
switch (self.index.get(scope_idx)) {
|
||||
.object => |scope| {
|
||||
//std.debug.print("prop: {s} \n", .{token.value.?.string});
|
||||
const pidx = try self.addProperty(allocator, token.value.?.string);
|
||||
const reer = self.index.len;
|
||||
|
||||
var accum: usize = 0;
|
||||
for (query.slice(), 0..) |id, i| {
|
||||
// std.debug.print("once\n", .{});
|
||||
accum += switch (self.index.get(id)) {
|
||||
.object => id + i,
|
||||
.array => id + i,
|
||||
else => unreachable,
|
||||
};
|
||||
}
|
||||
accum += scope.len + 1;
|
||||
self.property_map.putAssumeCapacity(accum, .{ .tip = @enumFromInt(pidx) });
|
||||
// std.debug.print("{s}/{d}\n", .{ token.value.?.string, accum });
|
||||
self.property_map.putAssumeCapacity(reer, .{ .tip = @enumFromInt(pidx) });
|
||||
allocator.free(token.value.?.string);
|
||||
|
||||
self.index.set(scope_idx, .{ .object = ObjectEntry{
|
||||
@ -580,14 +569,15 @@ test getValue {
|
||||
|
||||
const text =
|
||||
\\{
|
||||
\\ "a":"b",
|
||||
\\ "c":"d",
|
||||
\\ "f": {
|
||||
\\ "g": "h"
|
||||
\\ "a":"A",
|
||||
\\ "b":"B",
|
||||
\\ "c": {
|
||||
\\ "d": "D"
|
||||
\\ },
|
||||
\\ "i": "j"
|
||||
\\ "e": "E",
|
||||
\\ "f": [1]
|
||||
\\}
|
||||
; // eg 1: b, 2: c, 3: f, 4: g, 5: i
|
||||
; // 1: a, 2: b, 3: c, 4: d, 5: e, 6: f
|
||||
|
||||
var tokenizer: Tokenizer = try .init(allocator, text);
|
||||
defer tokenizer.deinit();
|
||||
|
Loading…
x
Reference in New Issue
Block a user