summaryrefslogtreecommitdiff
path: root/tools/d2c/d2c_gram.y
diff options
context:
space:
mode:
Diffstat (limited to 'tools/d2c/d2c_gram.y')
-rw-r--r--tools/d2c/d2c_gram.y27
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 */