diff options
Diffstat (limited to 'scripts/genksyms/parse.y')
-rw-r--r-- | scripts/genksyms/parse.y | 40 |
1 files changed, 22 insertions, 18 deletions
diff --git a/scripts/genksyms/parse.y b/scripts/genksyms/parse.y index ba5c242866c..23c39998ad8 100644 --- a/scripts/genksyms/parse.y +++ b/scripts/genksyms/parse.y | |||
@@ -51,6 +51,25 @@ 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 | |||
62 | if (i->in_source_file) { | ||
63 | remove_node(keyw); | ||
64 | (*ident)->tag = type; | ||
65 | remove_list(body, ident); | ||
66 | return; | ||
67 | } | ||
68 | r = copy_node(i); r->tag = type; | ||
69 | r->next = (*keyw)->next; *body = r; (*keyw)->next = NULL; | ||
70 | add_symbol(i->string, type, b, is_extern); | ||
71 | } | ||
72 | |||
54 | %} | 73 | %} |
55 | 74 | ||
56 | %token ASM_KEYW | 75 | %token ASM_KEYW |
@@ -215,26 +234,11 @@ type_specifier: | |||
215 | 234 | ||
216 | /* Full definitions of an s/u/e. Record it. */ | 235 | /* Full definitions of an s/u/e. Record it. */ |
217 | | STRUCT_KEYW IDENT class_body | 236 | | STRUCT_KEYW IDENT class_body |
218 | { struct string_list *s = *$3, *i = *$2, *r; | 237 | { 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 | 238 | | UNION_KEYW IDENT class_body |
225 | { struct string_list *s = *$3, *i = *$2, *r; | 239 | { 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 | 240 | | ENUM_KEYW IDENT enum_body |
232 | { struct string_list *s = *$3, *i = *$2, *r; | 241 | { 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 | /* | 242 | /* |
239 | * Anonymous enum definition. Tell add_symbol() to restart its counter. | 243 | * Anonymous enum definition. Tell add_symbol() to restart its counter. |
240 | */ | 244 | */ |