From d1bac978f70b6b2e729b3e03c439d17101a57be8 Mon Sep 17 00:00:00 2001 From: Cyrille Bagard Date: Sun, 22 Oct 2023 20:38:38 +0200 Subject: Replace some tokens by their value. --- src/analysis/scan/grammar.y | 38 +++++++++++++++++++------------------- 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); $$ = *built_rule; } - tags BRACE_IN meta bytes condition BRACE_OUT + tags "{" meta bytes condition "}" { $$ = $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_]* "{" { PUSH_STATE(bytes_regex_quantifier); - return BRACKET_O; + return BRACE_IN; } "," { return COMMA; } "}" { POP_STATE; - return BRACKET_C; + return BRACE_OUT; } -- cgit v0.11.2-87-g4458