From 79f86e22f4345267f69c460d1530929f616a3e52 Mon Sep 17 00:00:00 2001 From: Michal Marek Date: Sat, 8 Oct 2011 00:48:29 +0200 Subject: [PATCH] --- yaml --- r: 274289 b: refs/heads/master c: b06fcd6c83c231f51a86448bb33c4cd717fefee8 h: refs/heads/master i: 274287: 1f761e0783962db3ac01c21ca9dd60c7ec8b34ce v: v3 --- [refs] | 2 +- trunk/scripts/genksyms/parse.y | 33 +++++++++++++++------------------ 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/[refs] b/[refs] index 6f93fbe2ec06..0dadfb0a4a91 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: cd96ea3a4f2c9c226216c8d8e57fd8f86801515d +refs/heads/master: b06fcd6c83c231f51a86448bb33c4cd717fefee8 diff --git a/trunk/scripts/genksyms/parse.y b/trunk/scripts/genksyms/parse.y index ba5c242866c1..a783ad4e2b51 100644 --- a/trunk/scripts/genksyms/parse.y +++ b/trunk/scripts/genksyms/parse.y @@ -51,6 +51,18 @@ remove_list(struct string_list **pb, struct string_list **pe) free_list(b, e); } +/* Record definition of a struct/union/enum */ +static void record_compound(struct string_list **keyw, + struct string_list **ident, + struct string_list **body, + enum symbol_type type) +{ + struct string_list *b = *body, *i = *ident, *r; + r = copy_node(i); r->tag = type; + r->next = (*keyw)->next; *body = r; (*keyw)->next = NULL; + add_symbol(i->string, type, b, is_extern); +} + %} %token ASM_KEYW @@ -215,26 +227,11 @@ type_specifier: /* Full definitions of an s/u/e. Record it. */ | STRUCT_KEYW IDENT class_body - { struct string_list *s = *$3, *i = *$2, *r; - r = copy_node(i); r->tag = SYM_STRUCT; - r->next = (*$1)->next; *$3 = r; (*$1)->next = NULL; - add_symbol(i->string, SYM_STRUCT, s, is_extern); - $$ = $3; - } + { record_compound($1, $2, $3, SYM_STRUCT); $$ = $3; } | UNION_KEYW IDENT class_body - { struct string_list *s = *$3, *i = *$2, *r; - r = copy_node(i); r->tag = SYM_UNION; - r->next = (*$1)->next; *$3 = r; (*$1)->next = NULL; - add_symbol(i->string, SYM_UNION, s, is_extern); - $$ = $3; - } + { record_compound($1, $2, $3, SYM_UNION); $$ = $3; } | ENUM_KEYW IDENT enum_body - { struct string_list *s = *$3, *i = *$2, *r; - r = copy_node(i); r->tag = SYM_ENUM; - r->next = (*$1)->next; *$3 = r; (*$1)->next = NULL; - add_symbol(i->string, SYM_ENUM, s, is_extern); - $$ = $3; - } + { record_compound($1, $2, $3, SYM_ENUM); $$ = $3; } /* * Anonymous enum definition. Tell add_symbol() to restart its counter. */