1
0
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:
Nicolas Williams
2014-07-09 00:43:06 -05:00
parent 10477fc2d4
commit 5be80b81eb
2 changed files with 9 additions and 0 deletions

View File

@ -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);
} |

View File

@ -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]