From 5896772fe3c5f01696188ea04957a825ee601b12 Mon Sep 17 00:00:00 2001 From: Florian Westphal Date: Mon, 8 Mar 2021 18:18:33 +0100 Subject: scanner: introduce start condition stack Add a small initial chunk of flex start conditionals. This starts with two low-hanging fruits, numgen and j/symhash. NUMGEN and HASH start conditions are entered from flex when the corresponding expression token is encountered. Flex returns to the INIT condition when the bison parser has seen a complete numgen/hash statement. This intentionally uses a stack rather than BEGIN() to eventually support nested states. The scanner_pop_start_cond() function argument is not used yet, but will need to be used later to deal with nesting. Signed-off-by: Florian Westphal --- include/parser.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'include/parser.h') diff --git a/include/parser.h b/include/parser.h index 9baa3a4d..b2ebd7aa 100644 --- a/include/parser.h +++ b/include/parser.h @@ -26,6 +26,12 @@ struct parser_state { struct list_head *cmds; }; +enum startcond_type { + PARSER_SC_BEGIN, + PARSER_SC_EXPR_HASH, + PARSER_SC_EXPR_NUMGEN, +}; + struct mnl_socket; extern void parser_init(struct nft_ctx *nft, struct parser_state *state, @@ -45,4 +51,6 @@ extern void scanner_push_buffer(void *scanner, const struct input_descriptor *indesc, const char *buffer); +extern void scanner_pop_start_cond(void *scanner, enum startcond_type sc); + #endif /* NFTABLES_PARSER_H */ -- cgit v1.2.3