Commit 5d7a33dc by Richard Kenner

Now have 27 shift/reduce conflicts.

(attribute_list): Just make chain of all attributes.
(attrib): Consistently put name as PURPOSE, args, if any, as VALUE.
(structsp): Allow attributes on any struct or union.

From-SVN: r9260
parent d17e26f7
...@@ -30,7 +30,7 @@ ifobjc ...@@ -30,7 +30,7 @@ ifobjc
%expect 35 %expect 35
end ifobjc end ifobjc
ifc ifc
%expect 23 %expect 27
/* These are the 23 conflicts you should get in parse.output; /* These are the 23 conflicts you should get in parse.output;
the state numbers may vary if minor changes in the grammar are made. the state numbers may vary if minor changes in the grammar are made.
...@@ -1090,24 +1090,22 @@ attribute: ...@@ -1090,24 +1090,22 @@ attribute:
attribute_list: attribute_list:
attrib attrib
{ $$ = build_tree_list (NULL_TREE, $1); } { $$ = $1; }
| attribute_list ',' attrib | attribute_list ',' attrib
{ $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); } { $$ = chainon ($1, $3); }
; ;
attrib: attrib:
/* empty */ /* empty */
{ $$ = NULL_TREE; } { $$ = NULL_TREE; }
| any_word | any_word
{ $$ = $1; } { $$ = build_tree_list ($1, NULL_TREE); }
| any_word '(' IDENTIFIER ')' | any_word '(' IDENTIFIER ')'
{ $$ = tree_cons ($1, NULL_TREE, { $$ = build_tree_list ($1, build_tree_list (NULL_TREE, $3)); }
build_tree_list (NULL_TREE, $3)); }
| any_word '(' IDENTIFIER ',' nonnull_exprlist ')' | any_word '(' IDENTIFIER ',' nonnull_exprlist ')'
{ $$ = tree_cons ($1, NULL_TREE, { $$ = build_tree_list ($1, tree_cons (NULL_TREE, $3, $5)); }
tree_cons (NULL_TREE, $3, $5)); }
| any_word '(' nonnull_exprlist ')' | any_word '(' nonnull_exprlist ')'
{ $$ = tree_cons ($1, NULL_TREE, $3); } { $$ = build_tree_list ($1, $3); }
; ;
/* This still leaves out most reserved keywords, /* This still leaves out most reserved keywords,
...@@ -1311,19 +1309,24 @@ structsp: ...@@ -1311,19 +1309,24 @@ structsp:
{ $$ = start_struct (RECORD_TYPE, $2); { $$ = start_struct (RECORD_TYPE, $2);
/* Start scope of tag before parsing components. */ /* Start scope of tag before parsing components. */
} }
component_decl_list '}' component_decl_list '}' maybe_attribute
{ $$ = finish_struct ($<ttype>4, $5); { $$ = finish_struct ($<ttype>4, $5);
decl_attributes ($$, $7, NULL_TREE);
/* Really define the structure. */ /* Really define the structure. */
} }
| STRUCT '{' component_decl_list '}' | STRUCT '{' component_decl_list '}' maybe_attribute
{ $$ = finish_struct (start_struct (RECORD_TYPE, NULL_TREE), { $$ = finish_struct (start_struct (RECORD_TYPE, NULL_TREE),
$3); } $3);
decl_attributes ($$, $5, NULL_TREE);
}
| STRUCT identifier | STRUCT identifier
{ $$ = xref_tag (RECORD_TYPE, $2); } { $$ = xref_tag (RECORD_TYPE, $2); }
| UNION identifier '{' | UNION identifier '{'
{ $$ = start_struct (UNION_TYPE, $2); } { $$ = start_struct (UNION_TYPE, $2); }
component_decl_list '}' component_decl_list '}' maybe_attribute
{ $$ = finish_struct ($<ttype>4, $5); } { $$ = finish_struct ($<ttype>4, $5);
decl_attributes ($$, $5, NULL_TREE);
}
| UNION '{' component_decl_list '}' | UNION '{' component_decl_list '}'
{ $$ = finish_struct (start_struct (UNION_TYPE, NULL_TREE), { $$ = finish_struct (start_struct (UNION_TYPE, NULL_TREE),
$3); } $3); }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment