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.y61
1 files changed, 30 insertions, 31 deletions
diff --git a/src/analysis/scan/grammar.y b/src/analysis/scan/grammar.y
index ab64ad8..525c5d1 100644
--- a/src/analysis/scan/grammar.y
+++ b/src/analysis/scan/grammar.y
@@ -17,12 +17,12 @@ static int yyerror(GContentScanner *, yyscan_t, GScanRule **, void/*GBytesPatter
typedef void *yyscan_t;
#include "scanner.h"
-#include "conds/counter.h"
+#include "exprs/access.h"
#include "exprs/arithmop.h"
#include "exprs/boolop.h"
#include "exprs/call.h"
#include "exprs/literal.h"
-#include "exprs/str.h"
+#include "exprs/strop.h"
#include "exprs/relop.h"
#include "patterns/tokens/plain.h"
@@ -46,14 +46,16 @@ typedef void *yyscan_t;
%union {
- //char *string; /* Chaîne de caractères #1 */
- const char *cstring; /* Chaîne de caractères #2 */
+ unsigned long long unsigned_integer; /* Valeur entière #1 */
+ signed long long signed_integer; /* Valeur entière #2 */
+ double floating_number; /* Valeur à virgule flottante */
+ sized_string_t sized_cstring; /* Chaîne de caractères */
+ char byte; /* Octet unique */
+
+
+
unsigned long long integer; /* Valeur entière */
- struct {
- const char *cstring; /* Chaîne de caractères #3 */
- size_t len; /* Taille correspondante */
- } sized_cstring;
GScanRule *rule; /* Nouvelle règle à intégrer */
void/*GBytesPattern*/ *pattern; /* Nouveau motif à considérer */
@@ -97,8 +99,6 @@ YY_DECL;
%token BRACE_IN BRACE_OUT ASSIGN COLON
-%token RAW_BLOCK
-
%token PLAIN_STRING
%token MASKED_STRING
@@ -147,8 +147,7 @@ YY_DECL;
%token THEM "them"
-%type <cstring> RULE_NAME
-%type <cstring> RAW_BLOCK
+%type <sized_cstring> RULE_NAME
%type <sized_cstring> IDENTIFIER
@@ -156,7 +155,7 @@ YY_DECL;
%type <integer> INTEGER
-%type <cstring> STRING
+%type <sized_cstring> STRING
%type <rule> rule
@@ -165,7 +164,7 @@ YY_DECL;
%type <expr> cexpression
%type <expr> literal
-%type <expr> callable
+%type <expr> item_chain
%type <args_list> call_args
%type <expr> bool_expr
%type <expr> rel_expr
@@ -214,7 +213,7 @@ rules : /* empty */
rule : RAW_RULE RULE_NAME
{
- *built_rule = g_scan_rule_new($2);
+ *built_rule = g_scan_rule_new($2.data);
$<rule>$ = *built_rule;
}
BRACE_IN strings condition BRACE_OUT
@@ -238,8 +237,8 @@ string_decls : string_decl
string_decl : IDENTIFIER ASSIGN PLAIN_STRING
{
GSearchPattern *__pat;
- __pat = g_plain_bytes_new((uint8_t *)$3.cstring, $3.len);
- g_search_pattern_set_name(__pat, $1.cstring, $1.len);
+ __pat = g_plain_bytes_new((uint8_t *)$3.data, $3.len);
+ g_search_pattern_set_name(__pat, $1.data, $1.len);
g_scan_rule_add_local_variable(*built_rule, __pat);
g_object_unref(G_OBJECT(__pat));
@@ -300,7 +299,7 @@ cexpression : IDENTIFIER
*/
}
| literal { $$ = $1; }
- | callable { $$ = $1; }
+ | item_chain { $$ = $1; }
| bool_expr { $$ = $1; }
| rel_expr { $$ = $1; }
| str_expr { $$ = $1; }
@@ -315,42 +314,42 @@ literal : "true" { $$ = g_literal_expression_new(EVT_BOOLEAN, (bool []){ true })
| INTEGER KB { $$ = g_literal_expression_new(EVT_INTEGER, (unsigned long long []){ $1 * 1024 }); }
| INTEGER MB { $$ = g_literal_expression_new(EVT_INTEGER, (unsigned long long []){ $1 * 1048576 }); }
| INTEGER GB { $$ = g_literal_expression_new(EVT_INTEGER, (unsigned long long []){ $1 * 1073741824 }); }
- | STRING { $$ = g_literal_expression_new(EVT_STRING, $1); }
+ | STRING { $$ = g_literal_expression_new(EVT_STRING, &$1); }
;
-callable : NAME { $$ = g_pending_call_new($1.cstring, $1.len, NULL, 0); }
- | NAME "(" ")" { $$ = g_pending_call_new($1.cstring, $1.len, NULL, 0); }
+item_chain : NAME { $$ = g_named_access_new(&$1); }
+ | NAME "(" ")" { $$ = g_pending_call_new(&$1, NULL, 0); }
| NAME "(" call_args ")"
{
size_t __i;
- $$ = g_pending_call_new($1.cstring, $1.len, $3.args, $3.count);
+ $$ = g_pending_call_new(&$1, $3.args, $3.count);
for (__i = 0; __i < $3.count; __i++)
g_object_unref(G_OBJECT($3.args[__i]));
free($3.args);
}
- | callable "." NAME
+ | item_chain "." NAME
{
GScanExpression *__next;
- __next = g_pending_call_new($3.cstring, $3.len, NULL, 0);
- g_pending_call_attach_next(G_PENDING_CALL($1), G_PENDING_CALL(__next));
+ __next = g_named_access_new(&$3);
+ g_named_access_attach_next(G_NAMED_ACCESS($1), G_NAMED_ACCESS(__next));
$$ = $1;
}
- | callable "." NAME "(" ")"
+ | item_chain "." NAME "(" ")"
{
GScanExpression *__next;
- __next = g_pending_call_new($3.cstring, $3.len, NULL, 0);
- g_pending_call_attach_next(G_PENDING_CALL($1), G_PENDING_CALL(__next));
+ __next = g_pending_call_new(&$3, NULL, 0);
+ g_named_access_attach_next(G_NAMED_ACCESS($1), G_NAMED_ACCESS(__next));
$$ = $1;
}
- | callable "." NAME "(" call_args ")"
+ | item_chain "." NAME "(" call_args ")"
{
GScanExpression *__next;
size_t __i;
- __next = g_pending_call_new($3.cstring, $3.len, $5.args, $5.count);
+ __next = g_pending_call_new(&$3, $5.args, $5.count);
for (__i = 0; __i < $5.count; __i++)
g_object_unref(G_OBJECT($5.args[__i]));
free($5.args);
- g_pending_call_attach_next(G_PENDING_CALL($1), G_PENDING_CALL(__next));
+ g_named_access_attach_next(G_NAMED_ACCESS($1), G_NAMED_ACCESS(__next));
$$ = $1;
}
;