diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2023-10-22 18:38:38 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2023-10-22 18:49:10 (GMT) |
commit | d1bac978f70b6b2e729b3e03c439d17101a57be8 (patch) | |
tree | 7e6b17b5b0598569124dc6fcc05da1b15984cb74 /src | |
parent | f044b0444d72e04f0ec65db8ea192043af2a7998 (diff) |
Replace some tokens by their value.
Diffstat (limited to 'src')
-rw-r--r-- | src/analysis/scan/grammar.y | 38 | ||||
-rw-r--r-- | src/analysis/scan/tokens.l | 4 |
2 files changed, 21 insertions, 21 deletions
diff --git a/src/analysis/scan/grammar.y b/src/analysis/scan/grammar.y index 6dfbd75..f603c85 100644 --- a/src/analysis/scan/grammar.y +++ b/src/analysis/scan/grammar.y @@ -118,7 +118,7 @@ YY_DECL; %token INCLUDE "include" -%token RAW_RULE +%token RAW_RULE "rule" %token RULE_IDENTIFIER %token META "meta" @@ -159,7 +159,8 @@ YY_DECL; -%token BRACE_IN BRACE_OUT +%token BRACE_IN "{" +%token BRACE_OUT "}" %token ASSIGN "=" %token COLON ":" @@ -205,8 +206,6 @@ YY_DECL; %token HOOK_O "[" %token HOOK_C "]" -%token BRACKET_O "{" -%token BRACKET_C "}" %token QUESTION "?" %token PAREN_O "(" @@ -363,12 +362,12 @@ YY_DECL; * Définition de règle. */ - rule : rule_flags RAW_RULE RULE_IDENTIFIER + rule : rule_flags "rule" RULE_IDENTIFIER { *built_rule = g_scan_rule_new($1, $3.data); $<rule>$ = *built_rule; } - tags BRACE_IN meta bytes condition BRACE_OUT + tags "{" meta bytes condition "}" { $$ = $<rule>4; } @@ -481,7 +480,7 @@ YY_DECL; * Définition de motif en texte brut. */ - str_pattern : BYTES_ID ASSIGN PLAIN_TEXT modifiers str_flags + str_pattern : BYTES_ID "=" PLAIN_TEXT modifiers str_flags { GScanTokenNode *node; @@ -493,7 +492,7 @@ YY_DECL; g_object_unref(G_OBJECT(node)); } - | BYTES_ID ASSIGN ESCAPED_TEXT modifiers str_flags + | BYTES_ID "=" ESCAPED_TEXT modifiers str_flags { GScanTokenNode *node; @@ -706,12 +705,12 @@ YY_DECL; * Définition de motif en hexadécimal. */ - hex_pattern : BYTES_ID ASSIGN hex_tokens + hex_pattern : BYTES_ID "=" hex_tokens { $$ = g_scan_hex_bytes_new($3, false); g_search_pattern_set_name($$, $1.data, $1.len); } - | BYTES_ID ASSIGN hex_tokens "private" + | BYTES_ID "=" hex_tokens "private" { $$ = g_scan_hex_bytes_new($3, true); g_search_pattern_set_name($$, $1.data, $1.len); @@ -865,7 +864,7 @@ YY_DECL; * Définition de motif sous forme d'expression régulière */ - regex_pattern : BYTES_ID ASSIGN regex_tokens + regex_pattern : BYTES_ID "=" regex_tokens { } @@ -909,7 +908,7 @@ YY_DECL; } ; - _regex_token : DOT + _regex_token : "." { printf("reg dot!\n"); } @@ -971,14 +970,15 @@ YY_DECL; * Définition des conditions. */ - condition : CONDITION COLON cexpression - { - g_scan_rule_set_match_condition(*built_rule, $3); - g_object_unref(G_OBJECT($3)); - } - ; + condition : "condition" ":" cexpression + { + g_scan_rule_set_match_condition(*built_rule, $3); + g_object_unref(G_OBJECT($3)); + } + ; - cexpression : _cexpression { $$ = $1; if ($$ == NULL) { printf("ERROR !!!\n"); YYERROR; } } + cexpression : _cexpression { $$ = $1; if ($$ == NULL) { printf("ERROR !!!\n"); YYERROR; } } + ; _cexpression : literal { $$ = $1; } | chain_items { $$ = $1; } diff --git a/src/analysis/scan/tokens.l b/src/analysis/scan/tokens.l index 64999f2..1174ae7 100644 --- a/src/analysis/scan/tokens.l +++ b/src/analysis/scan/tokens.l @@ -876,14 +876,14 @@ bytes_fuzzy_id [\*A-Za-z_][\*A-Za-z0-9_]* <bytes_regex>"{" { PUSH_STATE(bytes_regex_quantifier); - return BRACKET_O; + return BRACE_IN; } <bytes_regex_quantifier>"," { return COMMA; } <bytes_regex_quantifier>"}" { POP_STATE; - return BRACKET_C; + return BRACE_OUT; } |