Support .a.[] and .a.[]? each syntax

Fixes #1699
This commit is contained in:
Mattias Wadman authored and Nico Williams committed 2023-07-09 10:08:31 -05:00
1 parent d8072564c2
commit ab1a68144d
3 files changed
+855 -816

No files matched your search

+844 -816
View File
File diff suppressed because it is too large. Load diff
+6
View File
@@ -710,6 +710,12 @@ Term '[' ']' '?' {
Term '[' ']' %prec NONOPT {
$$ = block_join($1, gen_op_simple(EACH));
} |
Term '.' '[' ']' '?' {
$$ = block_join($1, gen_op_simple(EACH_OPT));
} |
Term '.' '[' ']' %prec NONOPT {
$$ = block_join($1, gen_op_simple(EACH));
} |
Term '[' Exp ':' Exp ']' '?' {
$$ = gen_slice_index($1, $3, $5, INDEX_OPT);
} |
+5
View File
@@ -173,6 +173,11 @@ jq: error: Cannot use number (0) as object key at <top-level>, line 1:
[1,null,true,false,"abcdef",{},{"a":1,"b":2},[],[1,2,3,4,5],[1,2]]
[null,"bc",[],[2,3],[2]]
# chaining/suffix-list, with and without dot
map(try .a[] catch ., try .a.[] catch ., .a[]?, .a.[]?)
[{"a": [1,2]}, {"a": 123}]
[1,2,1,2,1,2,1,2,"Cannot iterate over number (123)","Cannot iterate over number (123)"]
#
# Negative array indices
#