diff options
Diffstat (limited to 'tools/d2c/grammar.y')
-rw-r--r-- | tools/d2c/grammar.y | 50 |
1 files changed, 33 insertions, 17 deletions
diff --git a/tools/d2c/grammar.y b/tools/d2c/grammar.y index 0c79f04..ad6531a 100644 --- a/tools/d2c/grammar.y +++ b/tools/d2c/grammar.y @@ -85,53 +85,55 @@ static void *map_input_data(const char *, size_t *); push_new_encoding_syntax(__spec); \ }) -#define handle_coder_asm(c, r) \ +#define handle_coder_subid(c, r) \ ({ \ encoding_spec *__spec; \ encoding_syntax *__syntax; \ - asm_pattern *__pattern; \ + instr_id *__subid; \ bool __status; \ __spec = get_current_encoding_spec(c); \ __syntax = get_current_encoding_syntax(__spec); \ - __pattern = get_asm_pattern_in_encoding_syntax(__syntax); \ - __status = load_asm_pattern_from_raw_line(__pattern, r); \ + __subid = get_encoding_syntax_subid(__syntax); \ + __status = load_id_from_raw_line(__subid, r); \ if (!__status) YYABORT; \ }) -#define handle_coder_conversions(c, r) \ +#define handle_coder_assertions(c, r) \ ({ \ encoding_spec *__spec; \ encoding_syntax *__syntax; \ - conv_list *__list; \ + disass_assert *__dassert; \ bool __status; \ __spec = get_current_encoding_spec(c); \ __syntax = get_current_encoding_syntax(__spec); \ - __list = get_conversions_in_encoding_syntax(__syntax); \ - __status = load_convs_from_raw_block(__list, r); \ + __dassert = get_assertions_for_encoding_syntax(__syntax); \ + __status = load_assertions_from_raw_block(__dassert, r); \ if (!__status) YYABORT; \ }) -#define handle_coder_assertions(c, r) \ +#define handle_coder_conversions(c, r) \ ({ \ encoding_spec *__spec; \ encoding_syntax *__syntax; \ - disass_assert *__dassert; \ + conv_list *__list; \ bool __status; \ __spec = get_current_encoding_spec(c); \ __syntax = get_current_encoding_syntax(__spec); \ - __dassert = get_assertions_for_encoding_syntax(__syntax); \ - __status = load_assertions_from_raw_block(__dassert, r); \ + __list = get_conversions_in_encoding_syntax(__syntax); \ + __status = load_convs_from_raw_block(__list, r); \ if (!__status) YYABORT; \ }) -#define handle_coder_hooks(c, r) \ +#define handle_coder_asm(c, r) \ ({ \ encoding_spec *__spec; \ - instr_hooks *__hooks;; \ + encoding_syntax *__syntax; \ + asm_pattern *__pattern; \ bool __status; \ __spec = get_current_encoding_spec(c); \ - __hooks = get_hooks_in_encoding_spec(__spec); \ - __status = load_hooks_from_raw_line(__hooks, r); \ + __syntax = get_current_encoding_syntax(__spec); \ + __pattern = get_asm_pattern_in_encoding_syntax(__syntax); \ + __status = load_asm_pattern_from_raw_line(__pattern, r); \ if (!__status) YYABORT; \ }) @@ -148,6 +150,17 @@ static void *map_input_data(const char *, size_t *); if (!__status) YYABORT; \ }) +#define handle_coder_hooks(c, r) \ + ({ \ + encoding_spec *__spec; \ + instr_hooks *__hooks;; \ + bool __status; \ + __spec = get_current_encoding_spec(c); \ + __hooks = get_hooks_in_encoding_spec(__spec); \ + __status = load_hooks_from_raw_line(__hooks, r); \ + if (!__status) YYABORT; \ + }) + } %union { @@ -184,7 +197,7 @@ YY_DECL; %token COPYRIGHT %token TITLE %token INS_NAME INS_SEP INS_DETAILS -%token ID +%token ID SUBID %token DESC %token ENCODING @@ -261,11 +274,14 @@ raw_content : /* empty */ | hooks raw_content raw_syntax : /* empty */ + | subid raw_syntax | assertions raw_syntax | conversions raw_syntax | asm raw_syntax | rules raw_syntax +subid : SUBID RAW_LINE { handle_coder_subid(coder, $2); } + assertions : ASSERT RAW_BLOCK { handle_coder_assertions(coder, $2); } conversions : CONV RAW_BLOCK { handle_coder_conversions(coder, $2); } |