diff options
-rw-r--r-- | include/parser.h | 2 | ||||
-rw-r--r-- | src/scanner.l | 20 |
2 files changed, 21 insertions, 1 deletions
diff --git a/include/parser.h b/include/parser.h index 9fdebcd1..0c229963 100644 --- a/include/parser.h +++ b/include/parser.h @@ -23,6 +23,8 @@ struct parser_state { struct scope *scopes[SCOPE_NEST_MAX]; unsigned int scope; + unsigned int flex_state_pop; + unsigned int startcond_type; struct list_head *cmds; }; diff --git a/src/scanner.l b/src/scanner.l index c139c01f..936c7c64 100644 --- a/src/scanner.l +++ b/src/scanner.l @@ -1017,11 +1017,29 @@ void scanner_destroy(struct nft_ctx *nft) static void scanner_push_start_cond(void *scanner, enum startcond_type type) { + struct parser_state *state = yyget_extra(scanner); + + state->startcond_type = type; + yy_push_state((int)type, scanner); } void scanner_pop_start_cond(void *scanner, enum startcond_type t) { - (void)yy_top_state(scanner); /* suppress gcc warning wrt. unused function */ + struct parser_state *state = yyget_extra(scanner); + + if (state->startcond_type != t) { + state->flex_state_pop++; + return; /* Can't pop just yet! */ + } + + while (state->flex_state_pop) { + state->flex_state_pop--; + state->startcond_type = yy_top_state(scanner); + yy_pop_state(scanner); + } + + state->startcond_type = yy_top_state(scanner); + yy_pop_state(scanner); } |