diff options
Diffstat (limited to 'src/analysis/scan/grammar.y')
-rw-r--r-- | src/analysis/scan/grammar.y | 40 |
1 files changed, 35 insertions, 5 deletions
diff --git a/src/analysis/scan/grammar.y b/src/analysis/scan/grammar.y index 36f6df9..1daa519 100644 --- a/src/analysis/scan/grammar.y +++ b/src/analysis/scan/grammar.y @@ -44,6 +44,7 @@ typedef void *yyscan_t; #include "patterns/customizer.h" #include "patterns/modifier.h" #include "patterns/modifiers/list.h" +#include "patterns/modifiers/pipe.h" #include "patterns/tokens/hex.h" #include "patterns/tokens/plain.h" #include "patterns/tokens/nodes/any.h" @@ -211,6 +212,9 @@ YY_DECL; %token DOT "." %token PIPE "|" +%token MOD_GROUP_O "((" +%token MOD_GROUP_C "))" + %token NONE "none" %token ANY "any" %token ALL "all" @@ -255,7 +259,7 @@ YY_DECL; %type <modifier> modifiers %type <modifier> _modifiers -%type <modifier> chained_modifiers + //%type <modifier> chained_modifiers %type <modifier> mod_stage %type <modifier> modifier %type <modifier> modifier_args @@ -509,7 +513,9 @@ YY_DECL; { $$ = $1; + // if (...) useless + // ex : xxx | { yyy zzz } } ; @@ -518,19 +524,43 @@ YY_DECL; { $$ = $1; } - | "(" chained_modifiers ")" + | _modifiers "|" mod_stage { - $$ = $2; + bool status; + + if (G_IS_SCAN_MODIFIER_PIPE($1)) + $$ = $1; + else + { + $$ = g_scan_modifier_pipe_new(); + g_scan_modifier_pipe_add(G_SCAN_MODIFIER_PIPE($$), $1); + } + + g_scan_modifier_pipe_add(G_SCAN_MODIFIER_PIPE($$), $3); + } ; - chained_modifiers : _modifiers "|" _modifiers +/* + chained_modifiers : modifiers "|" modifiers + { + printf("need chains....\n"); + + $$ = NULL; + + } ; +*/ mod_stage : modifier { $$ = $1; } + | "((" _modifiers "))" + { + $$ = NULL; + YYERROR; /* TODO */ + } | mod_stage modifier { bool status; @@ -562,7 +592,7 @@ YY_DECL; char *_msg; int _ret; - _ret = asprintf(&_msg, _("Unknown modifier: \"%s\""), $1.data); + _ret = asprintf(&_msg, _("Unknown modifier: \"%.*s\""), (int)$1.len, $1.data); if (_ret != -1) { |