summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhil Sutter <phil@nwl.cc>2021-07-23 18:27:11 +0200
committerPhil Sutter <phil@nwl.cc>2022-03-01 10:54:03 +0100
commit8a7e430ab23b34b22f9788211156c4f32bfe32c2 (patch)
tree80d4dd4657b4b8f8416e6f6e3334084217862d5d
parente554701721cc00771cbd3700e69e9af449c23ff3 (diff)
scanner: monitor: Move to own Scope
Some keywords are shared with list command. Signed-off-by: Phil Sutter <phil@nwl.cc>
-rw-r--r--include/parser.h1
-rw-r--r--src/parser_bison.y3
-rw-r--r--src/scanner.l17
3 files changed, 14 insertions, 7 deletions
diff --git a/include/parser.h b/include/parser.h
index 072fea24..09499f08 100644
--- a/include/parser.h
+++ b/include/parser.h
@@ -46,6 +46,7 @@ enum startcond_type {
PARSER_SC_TYPE,
PARSER_SC_VLAN,
PARSER_SC_CMD_LIST,
+ PARSER_SC_CMD_MONITOR,
PARSER_SC_EXPR_AH,
PARSER_SC_EXPR_COMP,
PARSER_SC_EXPR_DCCP,
diff --git a/src/parser_bison.y b/src/parser_bison.y
index cc739c47..4ca86f73 100644
--- a/src/parser_bison.y
+++ b/src/parser_bison.y
@@ -951,6 +951,7 @@ close_scope_ipsec : { scanner_pop_start_cond(nft->scanner, PARSER_SC_EXPR_IPSEC)
close_scope_list : { scanner_pop_start_cond(nft->scanner, PARSER_SC_CMD_LIST); };
close_scope_limit : { scanner_pop_start_cond(nft->scanner, PARSER_SC_LIMIT); };
close_scope_mh : { scanner_pop_start_cond(nft->scanner, PARSER_SC_EXPR_MH); };
+close_scope_monitor : { scanner_pop_start_cond(nft->scanner, PARSER_SC_CMD_MONITOR); };
close_scope_numgen : { scanner_pop_start_cond(nft->scanner, PARSER_SC_EXPR_NUMGEN); };
close_scope_osf : { scanner_pop_start_cond(nft->scanner, PARSER_SC_EXPR_OSF); };
close_scope_quota : { scanner_pop_start_cond(nft->scanner, PARSER_SC_QUOTA); };
@@ -1055,7 +1056,7 @@ base_cmd : /* empty */ add_cmd { $$ = $1; }
| RENAME rename_cmd { $$ = $2; }
| IMPORT import_cmd { $$ = $2; }
| EXPORT export_cmd { $$ = $2; }
- | MONITOR monitor_cmd { $$ = $2; }
+ | MONITOR monitor_cmd close_scope_monitor { $$ = $2; }
| DESCRIBE describe_cmd { $$ = $2; }
;
diff --git a/src/scanner.l b/src/scanner.l
index 6975d9f2..ea369c07 100644
--- a/src/scanner.l
+++ b/src/scanner.l
@@ -212,6 +212,7 @@ addrstring ({macaddr}|{ip4addr}|{ip6addr})
%s SCANSTATE_TYPE
%s SCANSTATE_VLAN
%s SCANSTATE_CMD_LIST
+%s SCANSTATE_CMD_MONITOR
%s SCANSTATE_EXPR_AH
%s SCANSTATE_EXPR_COMP
%s SCANSTATE_EXPR_DCCP
@@ -289,23 +290,27 @@ addrstring ({macaddr}|{ip4addr}|{ip6addr})
"describe" { return DESCRIBE; }
+<SCANSTATE_CMD_LIST,SCANSTATE_CMD_MONITOR>{
+ "chains" { return CHAINS; }
+ "sets" { return SETS; }
+ "tables" { return TABLES; }
+}
+<SCANSTATE_CMD_MONITOR>{
+ "rules" { return RULES; }
+ "trace" { return TRACE; }
+}
"hook" { return HOOK; }
"device" { return DEVICE; }
"devices" { return DEVICES; }
"table" { return TABLE; }
-"tables" { return TABLES; }
"chain" { return CHAIN; }
-"chains" { return CHAINS; }
"rule" { return RULE; }
-"rules" { return RULES; }
-"sets" { return SETS; }
"set" { return SET; }
"element" { return ELEMENT; }
"map" { return MAP; }
"flowtable" { return FLOWTABLE; }
"handle" { return HANDLE; }
"ruleset" { return RULESET; }
-"trace" { return TRACE; }
"socket" { scanner_push_start_cond(yyscanner, SCANSTATE_EXPR_SOCKET); return SOCKET; }
<SCANSTATE_EXPR_SOCKET>{
@@ -340,7 +345,7 @@ addrstring ({macaddr}|{ip4addr}|{ip6addr})
"rename" { return RENAME; }
"import" { return IMPORT; }
"export" { return EXPORT; }
-"monitor" { return MONITOR; }
+"monitor" { scanner_push_start_cond(yyscanner, SCANSTATE_CMD_MONITOR); return MONITOR; }
"position" { return POSITION; }
"index" { return INDEX; }