diff options
author | Carlos Falgueras García <carlosfg@riseup.net> | 2016-08-23 09:40:45 +0200 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2016-08-23 13:17:41 +0200 |
commit | cec8dde7af3ec0f2e16d6445b14f77a2c357221e (patch) | |
tree | b6904838e28b890a9410f7d015a0d40aab6992b4 /src/parser_bison.y | |
parent | 09d27ff9138e4be38b86499e26ad2d1116dd0f02 (diff) |
src: Simplify parser rule_spec tree
This patch separates the rule identification from the rule localization,
so the logic moves from the evaluator to the parser. This allows to
revert the patch "evaluate: improve rule managment checks"
(4176c7d30c2ff1b3f52468fc9c08b8df83f979a8) and saves a lot of code.
Signed-off-by: Carlos Falgueras García <carlosfg@riseup.net>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/parser_bison.y')
-rw-r--r-- | src/parser_bison.y | 43 |
1 files changed, 21 insertions, 22 deletions
diff --git a/src/parser_bison.y b/src/parser_bison.y index bf436086..dcabb464 100644 --- a/src/parser_bison.y +++ b/src/parser_bison.y @@ -425,15 +425,12 @@ static void location_update(struct location *loc, struct location *rhs, int n) %type <cmd> base_cmd add_cmd replace_cmd create_cmd insert_cmd delete_cmd list_cmd flush_cmd rename_cmd export_cmd monitor_cmd describe_cmd %destructor { cmd_free($$); } base_cmd add_cmd replace_cmd create_cmd insert_cmd delete_cmd list_cmd flush_cmd rename_cmd export_cmd monitor_cmd describe_cmd -%type <handle> table_spec chain_spec chain_identifier ruleid_spec ruleset_spec -%destructor { handle_free(&$$); } table_spec chain_spec chain_identifier ruleid_spec ruleset_spec +%type <handle> table_spec chain_spec chain_identifier ruleid_spec handle_spec position_spec rule_position ruleset_spec +%destructor { handle_free(&$$); } table_spec chain_spec chain_identifier ruleid_spec handle_spec position_spec rule_position ruleset_spec %type <handle> set_spec set_identifier %destructor { handle_free(&$$); } set_spec set_identifier %type <val> family_spec family_spec_explicit chain_policy prio_spec -%type <handle_spec> handle_spec -%type <position_spec> position_spec - %type <string> dev_spec %destructor { xfree($$); } dev_spec @@ -720,11 +717,11 @@ add_cmd : TABLE table_spec close_scope(state); $$ = cmd_alloc(CMD_ADD, CMD_OBJ_CHAIN, &$2, &@$, $5); } - | RULE ruleid_spec rule + | RULE rule_position rule { $$ = cmd_alloc(CMD_ADD, CMD_OBJ_RULE, &$2, &@$, $3); } - | /* empty */ ruleid_spec rule + | /* empty */ rule_position rule { $$ = cmd_alloc(CMD_ADD, CMD_OBJ_RULE, &$1, &@$, $2); } @@ -779,7 +776,7 @@ create_cmd : TABLE table_spec } ; -insert_cmd : RULE ruleid_spec rule +insert_cmd : RULE rule_position rule { $$ = cmd_alloc(CMD_INSERT, CMD_OBJ_RULE, &$2, &@$, $3); } @@ -1252,35 +1249,37 @@ set_identifier : identifier } ; -handle_spec : /* empty */ +handle_spec : HANDLE NUM { memset(&$$, 0, sizeof($$)); + $$.handle.location = @$; + $$.handle.id = $2; } - | HANDLE NUM + ; + +position_spec : POSITION NUM { memset(&$$, 0, sizeof($$)); - $$.location = @$; - $$.id = $2; + $$.position.location = @$; + $$.position.id = $2; } ; -position_spec : /* empty */ +rule_position : chain_spec { - memset(&$$, 0, sizeof($$)); + $$ = $1; } - | POSITION NUM + | chain_spec position_spec { - memset(&$$, 0, sizeof($$)); - $$.location = @$; - $$.id = $2; + handle_merge(&$1, &$2); + $$ = $1; } ; -ruleid_spec : chain_spec handle_spec position_spec +ruleid_spec : chain_spec handle_spec { - $$ = $1; - $$.handle = $2; - $$.position = $3; + handle_merge(&$1, &$2); + $$ = $1; } ; |