mirror of
https://github.com/stedolan/jq.git
synced 2024-05-11 05:55:39 +00:00
Add foreach EXP as $var (INIT; UPDATE)
form
This commit is contained in:
5
parser.y
5
parser.y
@ -243,6 +243,11 @@ Term "as" '$' IDENT '|' Exp {
|
||||
jv_free($5);
|
||||
} |
|
||||
|
||||
"foreach" Term "as" '$' IDENT '(' Exp ';' Exp ')' {
|
||||
$$ = gen_foreach(jv_string_value($5), $2, $7, $9, gen_noop());
|
||||
jv_free($5);
|
||||
} |
|
||||
|
||||
"if" Exp "then" Exp ElseBody {
|
||||
$$ = gen_cond($2, $4, $5);
|
||||
} |
|
||||
|
@ -234,6 +234,10 @@ null
|
||||
[11,22,33,44,55,66,77,88,99]
|
||||
[11,22,33]
|
||||
|
||||
[foreach range(5) as $item (0; $item)]
|
||||
null
|
||||
[0,1,2,3,4]
|
||||
|
||||
[limit(3; .[])]
|
||||
[11,22,33,44,55,66,77,88,99]
|
||||
[11,22,33]
|
||||
|
Reference in New Issue
Block a user