diff options
author | Michal Marek <mmarek@suse.cz> | 2011-10-07 18:48:29 -0400 |
---|---|---|
committer | Michal Marek <mmarek@suse.cz> | 2011-10-11 05:59:19 -0400 |
commit | b06fcd6c83c231f51a86448bb33c4cd717fefee8 (patch) | |
tree | 19271df957cbdb016dd808438a5b6a8966dd4d0c /scripts | |
parent | cd96ea3a4f2c9c226216c8d8e57fd8f86801515d (diff) |
genksyms: Minor parser cleanup
Move the identical logic for recording a struct/union/enum definition to
a function.
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/genksyms/parse.y | 33 |
1 files changed, 15 insertions, 18 deletions
diff --git a/scripts/genksyms/parse.y b/scripts/genksyms/parse.y index ba5c242866c..a783ad4e2b5 100644 --- a/scripts/genksyms/parse.y +++ b/scripts/genksyms/parse.y | |||
@@ -51,6 +51,18 @@ remove_list(struct string_list **pb, struct string_list **pe) | |||
51 | free_list(b, e); | 51 | free_list(b, e); |
52 | } | 52 | } |
53 | 53 | ||
54 | /* Record definition of a struct/union/enum */ | ||
55 | static void record_compound(struct string_list **keyw, | ||
56 | struct string_list **ident, | ||
57 | struct string_list **body, | ||
58 | enum symbol_type type) | ||
59 | { | ||
60 | struct string_list *b = *body, *i = *ident, *r; | ||
61 | r = copy_node(i); r->tag = type; | ||
62 | r->next = (*keyw)->next; *body = r; (*keyw)->next = NULL; | ||
63 | add_symbol(i->string, type, b, is_extern); | ||
64 | } | ||
65 | |||
54 | %} | 66 | %} |
55 | 67 | ||
56 | %token ASM_KEYW | 68 | %token ASM_KEYW |
@@ -215,26 +227,11 @@ type_specifier: | |||
215 | 227 | ||
216 | /* Full definitions of an s/u/e. Record it. */ | 228 | /* Full definitions of an s/u/e. Record it. */ |
217 | | STRUCT_KEYW IDENT class_body | 229 | | STRUCT_KEYW IDENT class_body |
218 | { struct string_list *s = *$3, *i = *$2, *r; | 230 | { record_compound($1, $2, $3, SYM_STRUCT); $$ = $3; } |
219 | r = copy_node(i); r->tag = SYM_STRUCT; | ||
220 | r->next = (*$1)->next; *$3 = r; (*$1)->next = NULL; | ||
221 | add_symbol(i->string, SYM_STRUCT, s, is_extern); | ||
222 | $$ = $3; | ||
223 | } | ||
224 | | UNION_KEYW IDENT class_body | 231 | | UNION_KEYW IDENT class_body |
225 | { struct string_list *s = *$3, *i = *$2, *r; | 232 | { record_compound($1, $2, $3, SYM_UNION); $$ = $3; } |
226 | r = copy_node(i); r->tag = SYM_UNION; | ||
227 | r->next = (*$1)->next; *$3 = r; (*$1)->next = NULL; | ||
228 | add_symbol(i->string, SYM_UNION, s, is_extern); | ||
229 | $$ = $3; | ||
230 | } | ||
231 | | ENUM_KEYW IDENT enum_body | 233 | | ENUM_KEYW IDENT enum_body |
232 | { struct string_list *s = *$3, *i = *$2, *r; | 234 | { record_compound($1, $2, $3, SYM_ENUM); $$ = $3; } |
233 | r = copy_node(i); r->tag = SYM_ENUM; | ||
234 | r->next = (*$1)->next; *$3 = r; (*$1)->next = NULL; | ||
235 | add_symbol(i->string, SYM_ENUM, s, is_extern); | ||
236 | $$ = $3; | ||
237 | } | ||
238 | /* | 235 | /* |
239 | * Anonymous enum definition. Tell add_symbol() to restart its counter. | 236 | * Anonymous enum definition. Tell add_symbol() to restart its counter. |
240 | */ | 237 | */ |