diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2015-01-10 16:37:34 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2015-01-10 16:37:34 (GMT) |
commit | 8ef66a1e0225c9e00175fbaf3f3038f537de511f (patch) | |
tree | dd7112dd50c02e0ad1565ce7a890991b5e1270c6 /tools/d2c/d2c_gram.y | |
parent | cc3e31eecd90766ae4f0bb391428c5c59567ef4c (diff) |
Extended the grammar to allow hooks inclusion.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@453 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'tools/d2c/d2c_gram.y')
-rw-r--r-- | tools/d2c/d2c_gram.y | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/tools/d2c/d2c_gram.y b/tools/d2c/d2c_gram.y index b1519a1..12eff11 100644 --- a/tools/d2c/d2c_gram.y +++ b/tools/d2c/d2c_gram.y @@ -41,8 +41,6 @@ struct action_tmp }; - - #define register_named_field_in_coder(c, n, l) \ ({ \ encoding_spec *__spec; \ @@ -88,6 +86,15 @@ struct action_tmp register_conversion(__list, f); \ }) +#define register_hook_in_coder(c, t, f) \ + ({ \ + encoding_spec *__spec; \ + instr_hooks *__hooks;; \ + __spec = get_current_encoding_spec(c); \ + __hooks = get_hooks_in_encoding_spec(__spec); \ + register_hook_function(__hooks, t, f); \ + }) + #define add_conditional_rule_to_coder(c, e, a, d) \ ({ \ encoding_spec *__spec; \ @@ -97,11 +104,6 @@ struct action_tmp register_conditional_rule(__rules, e, a, d); \ }) - - - - - } %union { @@ -142,6 +144,8 @@ struct action_tmp %token CONV EQ OP COMMA CP NOT EOR COLON +%token HOOKS + %token RULES IF EXPR_START EQUAL BINVAL IMMVAL EXPR_END AND THEN SEE UNPREDICTABLE @@ -190,6 +194,7 @@ content : /* empty */ | bitfield content | syntax content | conversions content + | hooks content | rules content @@ -250,6 +255,14 @@ conv_arg_field : NAME { $$ = $1; printf(" composed::name '%s'\n", $1); } | BINVAL { $$ = $1; printf(" composed::bin '%s'\n", $1); } +hooks : HOOKS hookings + +hookings : /* empty */ + | hookings hooking + +hooking : NAME EQ NAME { register_hook_in_coder(coder, $1, $3); } + + rules : RULES rules_list rules_list : /* empty */ |