diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2023-11-08 07:10:27 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2023-11-08 07:10:27 (GMT) |
commit | 72b6d6efcea936ac806528f3453a3107c7807131 (patch) | |
tree | 648d7e37e0c23243fa72cf1983a2210c70ea6011 /src/analysis/scan/grammar.y | |
parent | f758049c3a8b06a0b35480327dc86c5da548a620 (diff) |
Make the hexadecimal range processing stronger.
Diffstat (limited to 'src/analysis/scan/grammar.y')
-rw-r--r-- | src/analysis/scan/grammar.y | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/src/analysis/scan/grammar.y b/src/analysis/scan/grammar.y index 84eda7a..801898f 100644 --- a/src/analysis/scan/grammar.y +++ b/src/analysis/scan/grammar.y @@ -274,6 +274,7 @@ YY_DECL; %type <pattern> hex_pattern %type <node> hex_tokens +%type <node> _hex_tokens %type <node> hex_token %type <node> hex_range %type <node> hex_choices @@ -726,14 +727,37 @@ YY_DECL; } ; - hex_tokens : hex_token + hex_tokens : _hex_tokens + { + $$ = $1; + + if (G_IS_SCAN_TOKEN_NODE_SEQUENCE($$)) + { + if (g_scan_token_node_sequence_count(G_SCAN_TOKEN_NODE_SEQUENCE($$)) == 1) + { + GScanTokenNode *node; + + node = g_scan_token_node_sequence_get(G_SCAN_TOKEN_NODE_SEQUENCE($$), 0); + + g_object_unref(G_OBJECT($$)); + + $$ = node; + + } + + } + + } + ; + + _hex_tokens : hex_token { if ($1 == NULL) YYERROR; $$ = $1; } - | hex_tokens hex_token + | _hex_tokens hex_token { if ($2 == NULL) YYERROR; @@ -793,7 +817,14 @@ YY_DECL; } | hex_range { + if ($1 == NULL) + { + raise_error(_("Unable to build hexadecimal range")); + YYERROR; + } + $$ = $1; + } | "~" hex_token { |