diff options
Diffstat (limited to 'src/jq/parse.zig')
| -rw-r--r-- | src/jq/parse.zig | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/jq/parse.zig b/src/jq/parse.zig index 5269ef5..dc9f6b9 100644 --- a/src/jq/parse.zig +++ b/src/jq/parse.zig @@ -10,12 +10,14 @@ pub const ParseError = error{ pub const AstKind = enum { identity, array_index, + object_key, literal, }; pub const Ast = union(AstKind) { identity, array_index: *Ast, + object_key: []const u8, literal: *jv.Value, pub fn kind(self: @This()) AstKind { @@ -42,6 +44,19 @@ pub fn parse(allocator: std.mem.Allocator, tokens: []const Token) !*Ast { return root; } + if (t2.kind() == .identifier) { + i += 1; + const t3 = tokens[i]; + if (t3.kind() != .end) { + return error.InvalidQuery; + } + const root = try allocator.create(Ast); + root.* = .{ + .object_key = t2.identifier, + }; + return root; + } + if (t2.kind() != .bracket_left) { return error.InvalidQuery; } |
