Add label $name | EXP; fix break
This is to fix the problem where `break` is dynamic, not lexical.
With this it should be possible to do this sort of thing:
label $break | inputs | if ... then $break|error else . end
This is a backwards-incompatible change for master, but the previous
`break` hadn't shipped yet.
Still needed:
- testing
This commit is contained in:
1 parent
cbfc0d6130
commit
7dc34b92af
11 files changed
+225
-33
No files matched your search
@@ -37,6 +37,7 @@ struct jq_state {
|
||||
int subexp_nest;
|
||||
int debug_trace_enabled;
|
||||
int initial_execution;
|
||||
unsigned next_label;
|
||||
|
||||
jv attrs;
|
||||
jq_input_cb input_cb;
|
||||
@@ -351,6 +352,11 @@ jv jq_next(jq_state *jq) {
|
||||
break;
|
||||
}
|
||||
|
||||
case GENLABEL: {
|
||||
stack_push(jq, JV_OBJECT(jv_string("__jq"), jv_number(jq->next_label++)));
|
||||
break;
|
||||
}
|
||||
|
||||
case DUP: {
|
||||
jv v = stack_pop(jq);
|
||||
stack_push(jq, jv_copy(v));
|
||||
@@ -838,6 +844,7 @@ jq_state *jq_init(void) {
|
||||
return NULL;
|
||||
|
||||
jq->bc = 0;
|
||||
jq->next_label = 0;
|
||||
|
||||
stack_init(&jq->stk);
|
||||
jq->stk_top = 0;
|
||||
|
||||
Reference in new issue
Block a user