summaryrefslogtreecommitdiffstats
path: root/src/parser_bison.y
diff options
context:
space:
mode:
authorCarlos Falgueras García <carlosfg@riseup.net>2016-05-30 18:35:39 +0200
committerPablo Neira Ayuso <pablo@netfilter.org>2016-05-30 19:27:47 +0200
commitab88635f6f71fbacdbcba05e70058d31e70bcd66 (patch)
tree6c93e7b1d67e245bc35688e4f8b263fedb6b3ac4 /src/parser_bison.y
parent1f327272e968a72de2d2a56da69124b40aa38744 (diff)
parser: Consolidate comment production
Use comment_spec both from rule and set element productions. 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.y25
1 files changed, 15 insertions, 10 deletions
diff --git a/src/parser_bison.y b/src/parser_bison.y
index ef10dee2..6f51a49d 100644
--- a/src/parser_bison.y
+++ b/src/parser_bison.y
@@ -440,7 +440,7 @@ static void location_update(struct location *loc, struct location *rhs, int n)
%destructor { close_scope(state); table_free($$); } table_block_alloc
%type <chain> chain_block_alloc chain_block
%destructor { close_scope(state); chain_free($$); } chain_block_alloc
-%type <rule> rule
+%type <rule> rule rule_alloc
%destructor { rule_free($$); } rule
%type <val> set_flag_list set_flag
@@ -1273,11 +1273,7 @@ ruleid_spec : chain_spec handle_spec position_spec
}
;
-comment_spec : /* empty */
- {
- $$ = NULL;
- }
- | COMMENT string
+comment_spec : COMMENT string
{
$$ = $2;
}
@@ -1295,12 +1291,21 @@ ruleset_spec : /* empty */
}
;
-rule : stmt_list comment_spec
+rule : rule_alloc
+ {
+ $$->comment = NULL;
+ }
+ | rule_alloc comment_spec
+ {
+ $$->comment = $2;
+ }
+ ;
+
+rule_alloc : stmt_list
{
struct stmt *i;
$$ = rule_alloc(&@$, NULL);
- $$->comment = $2;
list_for_each_entry(i, $1, list)
$$->num_stmts++;
list_splice_tail($1, &$$->stmts);
@@ -2029,9 +2034,9 @@ set_elem_option : TIMEOUT time_spec
{
$<expr>0->timeout = $2 * 1000;
}
- | COMMENT string
+ | comment_spec
{
- $<expr>0->comment = $2;
+ $<expr>0->comment = $1;
}
;