summaryrefslogtreecommitdiff
path: root/src/analysis/scan/grammar.y
diff options
context:
space:
mode:
Diffstat (limited to 'src/analysis/scan/grammar.y')
-rw-r--r--src/analysis/scan/grammar.y94
1 files changed, 58 insertions, 36 deletions
diff --git a/src/analysis/scan/grammar.y b/src/analysis/scan/grammar.y
index 64bcd5b..66d3f87 100644
--- a/src/analysis/scan/grammar.y
+++ b/src/analysis/scan/grammar.y
@@ -112,7 +112,13 @@ YY_DECL;
%token RAW_RULE
%token RULE_NAME
-%token STRINGS CONDITION
+%token META "meta"
+%token STRINGS "strings"
+%token CONDITION "condition"
+
+%token INFO_KEY
+
+
%token BYTES_ID
%token BYTES_ID_COUNTER
@@ -138,7 +144,9 @@ YY_DECL;
-%token BRACE_IN BRACE_OUT ASSIGN COLON
+%token BRACE_IN BRACE_OUT
+%token ASSIGN "="
+%token COLON ":"
%token PLAIN_TEXT
@@ -202,6 +210,7 @@ YY_DECL;
%type <sized_cstring> RULE_NAME
+%type <sized_cstring> INFO_KEY
%type <sized_cstring> BYTES_ID
%type <sized_cstring> BYTES_ID_COUNTER
@@ -293,27 +302,15 @@ YY_DECL;
%%
+ rules : /* empty */
+ | external rules
+ | rule rules { g_content_scanner_add_rule(scanner, $1); }
+ ;
- /*
-
-
-<raw_block>[ \t\n]+ { }
-<raw_block>"{" {
- read_block(temp);
- yylvalp->cstring = temp; return RAW_BLOCK;
- }
-<raw_block>"}" { yy_pop_state(); }
-
- */
-
-
-rules : /* empty */
- | external rules
- | rule rules { g_content_scanner_add_rule(scanner, $1); }
-
- //rule : RAW_RULE RULE_NAME { printf("RULE %s\n", $2); } RAW_BLOCK { printf("BLOCK: %s\n", $4); }
-
+/**
+ * Inclusion d'une règle externe.
+ */
external : "include" PLAIN_TEXT
{
@@ -332,26 +329,51 @@ rules : /* empty */
;
-rule : RAW_RULE RULE_NAME
- {
- //printf("--------built rule '%s'\n", $2.data);
- *built_rule = g_scan_rule_new($2.data);
- $<rule>$ = *built_rule;
- }
- BRACE_IN strings condition BRACE_OUT
- {
- $$ = $<rule>3;
- //printf("RULE %s -> %p\n", $2, $$);
- //printf("end of rule\n");
- }
+/**
+ * Définition de règle.
+ */
+
+ rule : RAW_RULE RULE_NAME
+ {
+ *built_rule = g_scan_rule_new($2.data);
+ $<rule>$ = *built_rule;
+ }
+ BRACE_IN meta strings condition BRACE_OUT
+ {
+ $$ = $<rule>3;
+ }
+ ;
+
+
+/**
+ * Section "meta:" d'une définition de règle.
+ */
+
+ meta : /* empty */
+ | "meta" ":"
+ | "meta" ":" meta_list
+ ;
+ meta_list : meta_info
+ | meta_list meta_info
+ ;
+ meta_info : INFO_KEY "=" "true"
+ | INFO_KEY "=" "false"
+ | INFO_KEY "=" SIGNED_INTEGER
+ | INFO_KEY "=" UNSIGNED_INTEGER
+ | INFO_KEY "=" PLAIN_TEXT
+ | INFO_KEY "=" ESCAPED_TEXT
+ ;
-strings : /* empty */
- | STRINGS COLON bytes_decls
- ;
+/**
+ * Section "bytes:" d'une définition de règle.
+ */
+ strings : /* empty */
+ | STRINGS COLON bytes_decls
+ ;
bytes_decls : str_pattern
{