home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.2J (Developer) / os42jdev.iso / NextDeveloper / Source / GNU / gcc / c-parse.in < prev    next >
Text File  |  1996-11-06  |  83KB  |  3,001 lines

  1. /* YACC parser for C syntax and for Objective C.  -*-c-*-
  2.    Copyright (C) 1987, 88, 89, 92, 93, 94, 1995 Free Software Foundation, Inc.
  3.  
  4. This file is part of GNU CC.
  5.  
  6. GNU CC is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2, or (at your option)
  9. any later version.
  10.  
  11. GNU CC is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with GNU CC; see the file COPYING.  If not, write to
  18. the Free Software Foundation, 59 Temple Place - Suite 330,
  19. Boston, MA 02111-1307, USA.  */
  20.  
  21. /* This file defines the grammar of C and that of Objective C.
  22.    ifobjc ... end ifobjc  conditionals contain code for Objective C only.
  23.    ifc ... end ifc  conditionals contain code for C only.
  24.    Sed commands in Makefile.in are used to convert this file into
  25.    c-parse.y and into objc-parse.y.  */
  26.  
  27. /* To whomever it may concern: I have heard that such a thing was once
  28.    written by AT&T, but I have never seen it.  */
  29.  
  30. ifobjc
  31. %expect 48
  32. end ifobjc
  33. ifc
  34. %expect 34
  35.  
  36. /* These are the 23 conflicts you should get in parse.output;
  37.    the state numbers may vary if minor changes in the grammar are made.
  38.  
  39. State 42 contains 1 shift/reduce conflict.  (Two ways to parse ATTRIBUTE.)
  40. State 44 contains 1 shift/reduce conflict.  (Two ways to recover from error.)
  41. State 103 contains 1 shift/reduce conflict.  (Two ways to recover from error.)
  42. State 110 contains 1 shift/reduce conflict.  (Two ways to parse ATTRIBUTE.)
  43. State 111 contains 1 shift/reduce conflict.  (Two ways to recover from error.)
  44. State 115 contains 1 shift/reduce conflict.  (Two ways to recover from error.)
  45. State 132 contains 1 shift/reduce conflict.  (See comment at component_decl.)
  46. State 180 contains 1 shift/reduce conflict.  (Two ways to parse ATTRIBUTE.)
  47. State 194 contains 2 shift/reduce conflict.  (Four ways to parse this.)
  48. State 202 contains 1 shift/reduce conflict.  (Two ways to recover from error.)
  49. State 214 contains 1 shift/reduce conflict.  (Two ways to recover from error.)
  50. State 220 contains 1 shift/reduce conflict.  (Two ways to recover from error.)
  51. State 304 contains 2 shift/reduce conflicts.  (Four ways to parse this.)
  52. State 335 contains 2 shift/reduce conflicts.  (Four ways to parse this.)
  53. State 347 contains 1 shift/reduce conflict.  (Two ways to parse ATTRIBUTES.)
  54. State 352 contains 1 shift/reduce conflict.  (Two ways to parse ATTRIBUTES.)
  55. State 383 contains 2 shift/reduce conflicts.  (Four ways to parse this.)
  56. State 434 contains 2 shift/reduce conflicts.  (Four ways to parse this.)  */
  57.  
  58. end ifc
  59.  
  60. %{
  61. #include <stdio.h>
  62. #include <errno.h>
  63. #include <setjmp.h>
  64.  
  65. #include "config.h"
  66. #include "tree.h"
  67. #include "input.h"
  68. #include "c-lex.h"
  69. #include "c-tree.h"
  70. #include "flags.h"
  71.  
  72. #ifdef MULTIBYTE_CHARS
  73. #include <stdlib.h>
  74. #include <locale.h>
  75. #endif
  76.  
  77. ifobjc
  78. #include "objc-act.h"
  79. end ifobjc
  80.  
  81. /* Since parsers are distinct for each language, put the language string
  82.    definition here.  */
  83. ifobjc
  84. char *language_string = "GNU Obj-C";
  85. end ifobjc
  86. ifc
  87. char *language_string = "GNU C";
  88. end ifc
  89.  
  90. #ifndef errno
  91. extern int errno;
  92. #endif
  93.  
  94. void yyerror ();
  95.  
  96. /* Like YYERROR but do call yyerror.  */
  97. #define YYERROR1 { yyerror ("syntax error"); YYERROR; }
  98.  
  99. /* Cause the `yydebug' variable to be defined.  */
  100. #define YYDEBUG 1
  101. %}
  102.  
  103. %start program
  104.  
  105. %union {long itype; tree ttype; enum tree_code code;
  106.     char *filename; int lineno; int ends_in_label; }
  107.  
  108. /* All identifiers that are not reserved words
  109.    and are not declared typedefs in the current block */
  110. %token IDENTIFIER
  111.  
  112. /* All identifiers that are declared typedefs in the current block.
  113.    In some contexts, they are treated just like IDENTIFIER,
  114.    but they can also serve as typespecs in declarations.  */
  115. %token TYPENAME
  116.  
  117. /* Reserved words that specify storage class.
  118.    yylval contains an IDENTIFIER_NODE which indicates which one.  */
  119. %token SCSPEC
  120.  
  121. /* Reserved words that specify type.
  122.    yylval contains an IDENTIFIER_NODE which indicates which one.  */
  123. %token TYPESPEC
  124.  
  125. /* Reserved words that qualify type: "const" or "volatile".
  126.    yylval contains an IDENTIFIER_NODE which indicates which one.  */
  127. %token TYPE_QUAL
  128.  
  129. /* Character or numeric constants.
  130.    yylval is the node for the constant.  */
  131. %token CONSTANT
  132.  
  133. /* String constants in raw form.
  134.    yylval is a STRING_CST node.  */
  135. %token STRING
  136.  
  137. /* "...", used for functions with variable arglists.  */
  138. %token ELLIPSIS
  139.  
  140. /* the reserved words */
  141. /* SCO include files test "ASM", so use something else. */
  142. %token SIZEOF ENUM STRUCT UNION IF ELSE WHILE DO FOR SWITCH CASE DEFAULT
  143. %token BREAK CONTINUE RETURN GOTO ASM_KEYWORD TYPEOF ALIGNOF
  144. %token ATTRIBUTE EXTENSION LABEL
  145. %token REALPART IMAGPART
  146.  
  147. /* Add precedence rules to solve dangling else s/r conflict */
  148. %nonassoc IF
  149. %nonassoc ELSE
  150.  
  151. /* Define the operator tokens and their precedences.
  152.    The value is an integer because, if used, it is the tree code
  153.    to use in the expression made from the operator.  */
  154.  
  155. %right <code> ASSIGN '='
  156. %right <code> '?' ':'
  157. %left <code> OROR
  158. %left <code> ANDAND
  159. %left <code> '|'
  160. %left <code> '^'
  161. %left <code> '&'
  162. %left <code> EQCOMPARE
  163. %left <code> ARITHCOMPARE
  164. %left <code> LSHIFT RSHIFT
  165. %left <code> '+' '-'
  166. %left <code> '*' '/' '%'
  167. %right <code> UNARY PLUSPLUS MINUSMINUS
  168. %left HYPERUNARY
  169. %left <code> POINTSAT '.' '(' '['
  170.  
  171. ifwin32
  172. /* Used to specify __declspec(xxx) in Windows.  */
  173. %token DECLSPEC DLL_EXPORT DLL_IMPORT /* THREAD NAKED */
  174. end ifwin32
  175.  
  176. /* The Objective-C keywords.  These are included in C and in
  177.    Objective C, so that the token codes are the same in both.  */
  178. %token INTERFACE IMPLEMENTATION END SELECTOR DEFS ENCODE
  179. %token CLASSNAME PUBLIC PRIVATE PROTECTED PROTOCOL OBJECTNAME CLASS ALIAS
  180.  
  181. /* Objective-C string constants in raw form.
  182.    yylval is an OBJC_STRING_CST node.  */
  183. %token OBJC_STRING
  184.  
  185.  
  186. %type <code> unop
  187.  
  188. %type <ttype> identifier IDENTIFIER TYPENAME CONSTANT expr nonnull_exprlist exprlist
  189. %type <ttype> expr_no_commas cast_expr unary_expr primary string STRING
  190. %type <ttype> typed_declspecs reserved_declspecs
  191. %type <ttype> typed_typespecs reserved_typespecquals
  192. %type <ttype> declmods typespec typespecqual_reserved
  193. %type <ttype> SCSPEC TYPESPEC TYPE_QUAL nonempty_type_quals maybe_type_qual
  194. %type <ttype> initdecls notype_initdecls initdcl notype_initdcl
  195. %type <ttype> init maybeasm
  196. %type <ttype> asm_operands nonnull_asm_operands asm_operand asm_clobbers
  197. %type <ttype> maybe_attribute attributes attribute attribute_list attrib
  198. %type <ttype> any_word
  199.  
  200. %type <ttype> compstmt
  201.  
  202. %type <ttype> declarator
  203. %type <ttype> notype_declarator after_type_declarator
  204. %type <ttype> parm_declarator
  205.  
  206. %type <ttype> structsp component_decl_list component_decl_list2
  207. %type <ttype> component_decl components component_declarator
  208. %type <ttype> enumlist enumerator
  209. %type <ttype> typename absdcl absdcl1 type_quals
  210. %type <ttype> xexpr parms parm identifiers
  211.  
  212. %type <ttype> parmlist parmlist_1 parmlist_2
  213. %type <ttype> parmlist_or_identifiers parmlist_or_identifiers_1
  214. %type <ttype> identifiers_or_typenames
  215.  
  216. %type <itype> setspecs
  217.  
  218. %type <ends_in_label> lineno_stmt_or_label lineno_stmt_or_labels stmt_or_label
  219. ifwin32
  220. %type <ttype> DECLSPEC DLL_EXPORT DLL_IMPORT /* THREAD NAKED */
  221. %type <ttype> declspec
  222. %type <ttype> declspec_attribute
  223. end ifwin32
  224.  
  225. %type <filename> save_filename
  226. %type <lineno> save_lineno
  227.  
  228. ifobjc
  229. /* the Objective-C nonterminals */
  230.  
  231. %type <ttype> ivar_decl_list ivar_decls ivar_decl ivars ivar_declarator
  232. %type <ttype> methoddecl unaryselector keywordselector selector
  233. %type <ttype> keyworddecl receiver objcmessageexpr messageargs
  234. %type <ttype> keywordexpr keywordarglist keywordarg
  235. %type <ttype> myparms myparm optparmlist reservedwords objcselectorexpr
  236. %type <ttype> selectorarg keywordnamelist keywordname objcencodeexpr
  237. %type <ttype> objc_string protocolrefs identifier_list objcprotocolexpr
  238. %type <ttype> CLASSNAME OBJC_STRING OBJECTNAME
  239. %type <ttype> objc_openbracket.expr_no_commas
  240. %type <ttype> objc_return_type_mods
  241. end ifobjc
  242.  
  243. %{
  244. /* Number of statements (loosely speaking) seen so far.  */
  245. static int stmt_count;
  246.  
  247. /* Input file and line number of the end of the body of last simple_if;
  248.    used by the stmt-rule immediately after simple_if returns.  */
  249. static char *if_stmt_file;
  250. static int if_stmt_line;
  251.  
  252. /* List of types and structure classes of the current declaration.  */
  253. static tree current_declspecs;
  254. static tree prefix_attributes = NULL_TREE;
  255.  
  256. /* Stack of saved values of current_declspecs and prefix_attributes.  */
  257. static tree declspec_stack;
  258.  
  259. /* 1 if we explained undeclared var errors.  */
  260. static int undeclared_variable_notice;
  261.  
  262. ifobjc
  263. /* Objective-C specific information */
  264.  
  265. tree objc_interface_context;
  266. tree objc_implementation_context;
  267. tree objc_method_context;
  268. tree objc_ivar_chain;
  269. tree objc_ivar_context;
  270. enum tree_code objc_inherit_code;
  271. int objc_receiver_context;
  272. int objc_public_flag;
  273.  
  274. end ifobjc
  275.  
  276. /* Tell yyparse how to print a token's value, if yydebug is set.  */
  277.  
  278. #define YYPRINT(FILE,YYCHAR,YYLVAL) yyprint(FILE,YYCHAR,YYLVAL)
  279. extern void yyprint ();
  280. %}
  281.  
  282. %%
  283. program: /* empty */
  284.         { if (pedantic)
  285.             pedwarn ("ANSI C forbids an empty source file");
  286.           finish_file ();
  287.         }
  288.     | extdefs
  289.         {
  290.           /* In case there were missing closebraces,
  291.              get us back to the global binding level.  */
  292.           while (! global_bindings_p ())
  293.             poplevel (0, 0, 0);
  294.           finish_file ();
  295.         }
  296.     ;
  297.  
  298. /* the reason for the strange actions in this rule
  299.  is so that notype_initdecls when reached via datadef
  300.  can find a valid list of type and sc specs in $0. */
  301.  
  302. extdefs:
  303.     {$<ttype>$ = NULL_TREE; } extdef
  304.     | extdefs {$<ttype>$ = NULL_TREE; } extdef
  305.     ;
  306.  
  307. extdef:
  308.     fndef
  309.     | datadef
  310. ifobjc
  311.     | objcdef
  312. end ifobjc
  313.     | ASM_KEYWORD '(' expr ')' ';'
  314.         { STRIP_NOPS ($3);
  315.           if ((TREE_CODE ($3) == ADDR_EXPR
  316.                && TREE_CODE (TREE_OPERAND ($3, 0)) == STRING_CST)
  317.               || TREE_CODE ($3) == STRING_CST)
  318.             assemble_asm ($3);
  319.           else
  320.             error ("argument of `asm' is not a constant string"); }
  321.     ;
  322.  
  323. ifwin32
  324. declspec:    DECLSPEC  '(' declspec_attribute ')' {$$ = $3;}
  325.     ;
  326.  
  327. declspec_attribute:
  328.     DLL_EXPORT
  329.     |    DLL_IMPORT
  330. /*    |    THREAD
  331.     |    NAKED    */
  332.     ;
  333. end ifwin32
  334.  
  335. datadef:
  336.       setspecs notype_initdecls ';'
  337.         { if (pedantic)
  338.             error ("ANSI C forbids data definition with no type or storage class");
  339.           else if (!flag_traditional)
  340.             warning ("data definition has no type or storage class"); 
  341.  
  342.           current_declspecs = TREE_VALUE (declspec_stack);
  343.           prefix_attributes = TREE_PURPOSE (declspec_stack);
  344.           declspec_stack = TREE_CHAIN (declspec_stack);
  345.           resume_momentary ($1); }
  346.         | declmods setspecs notype_initdecls ';'
  347.         { current_declspecs = TREE_VALUE (declspec_stack);
  348.           prefix_attributes = TREE_PURPOSE (declspec_stack);
  349.           declspec_stack = TREE_CHAIN (declspec_stack);
  350.           resume_momentary ($2); }
  351.     | typed_declspecs setspecs initdecls ';'
  352.         { current_declspecs = TREE_VALUE (declspec_stack);
  353.           prefix_attributes = TREE_PURPOSE (declspec_stack);
  354.           declspec_stack = TREE_CHAIN (declspec_stack);
  355.           resume_momentary ($2);  }
  356.         | declmods ';'
  357.       { pedwarn ("empty declaration"); }
  358.     | typed_declspecs ';'
  359.       { shadow_tag ($1); }
  360.     | error ';'
  361.     | error '}'
  362.     | ';'
  363.         { if (pedantic)
  364.             pedwarn ("ANSI C does not allow extra `;' outside of a function"); }
  365.     ;
  366.  
  367. fndef:
  368.       typed_declspecs setspecs declarator
  369.         { if (! start_function ($1, $3, prefix_attributes,
  370.                     NULL_TREE, 0))
  371.             YYERROR1;
  372.           reinit_parse_for_function (); }
  373.       xdecls
  374.         { store_parm_decls (); }
  375.       compstmt_or_error
  376.         { finish_function (0); 
  377.           current_declspecs = TREE_VALUE (declspec_stack);
  378.           prefix_attributes = TREE_PURPOSE (declspec_stack);
  379.           declspec_stack = TREE_CHAIN (declspec_stack);
  380.           resume_momentary ($2); }
  381.     | typed_declspecs setspecs declarator error
  382.         { current_declspecs = TREE_VALUE (declspec_stack);
  383.           prefix_attributes = TREE_PURPOSE (declspec_stack);
  384.           declspec_stack = TREE_CHAIN (declspec_stack);
  385.           resume_momentary ($2); }
  386.     | declmods setspecs notype_declarator
  387.         { if (! start_function ($1, $3, prefix_attributes,
  388.                     NULL_TREE, 0))
  389.             YYERROR1;
  390.           reinit_parse_for_function (); }
  391.       xdecls
  392.         { store_parm_decls (); }
  393.       compstmt_or_error
  394.         { finish_function (0); 
  395.           current_declspecs = TREE_VALUE (declspec_stack);
  396.           prefix_attributes = TREE_PURPOSE (declspec_stack);
  397.           declspec_stack = TREE_CHAIN (declspec_stack);
  398.           resume_momentary ($2); }
  399.     | declmods setspecs notype_declarator error
  400.         { current_declspecs = TREE_VALUE (declspec_stack);
  401.           prefix_attributes = TREE_PURPOSE (declspec_stack);
  402.           declspec_stack = TREE_CHAIN (declspec_stack);
  403.           resume_momentary ($2); }
  404.     | setspecs notype_declarator
  405.         { if (! start_function (NULL_TREE, $2,
  406.                     prefix_attributes, NULL_TREE, 0))
  407.             YYERROR1;
  408.           reinit_parse_for_function (); }
  409.       xdecls
  410.         { store_parm_decls (); }
  411.       compstmt_or_error
  412.         { finish_function (0); 
  413.           current_declspecs = TREE_VALUE (declspec_stack);
  414.           prefix_attributes = TREE_PURPOSE (declspec_stack);
  415.           declspec_stack = TREE_CHAIN (declspec_stack);
  416.           resume_momentary ($1); }
  417.     | setspecs notype_declarator error
  418.         { current_declspecs = TREE_VALUE (declspec_stack);
  419.           prefix_attributes = TREE_PURPOSE (declspec_stack);
  420.           declspec_stack = TREE_CHAIN (declspec_stack);
  421.           resume_momentary ($1); }
  422.     ;
  423.  
  424. identifier:
  425.     IDENTIFIER
  426.     | TYPENAME
  427. ifobjc
  428.     | OBJECTNAME
  429.         | CLASSNAME
  430. end ifobjc
  431.     ;
  432.  
  433. unop:     '&'
  434.         { $$ = ADDR_EXPR; }
  435.     | '-'
  436.         { $$ = NEGATE_EXPR; }
  437.     | '+'
  438.         { $$ = CONVERT_EXPR; }
  439.     | PLUSPLUS
  440.         { $$ = PREINCREMENT_EXPR; }
  441.     | MINUSMINUS
  442.         { $$ = PREDECREMENT_EXPR; }
  443.     | '~'
  444.         { $$ = BIT_NOT_EXPR; }
  445.     | '!'
  446.         { $$ = TRUTH_NOT_EXPR; }
  447.     ;
  448.  
  449. expr:    nonnull_exprlist
  450.         { $$ = build_compound_expr ($1); }
  451.     ;
  452.  
  453. exprlist:
  454.       /* empty */
  455.         { $$ = NULL_TREE; }
  456.     | nonnull_exprlist
  457.     ;
  458.  
  459. nonnull_exprlist:
  460.     expr_no_commas
  461.         { $$ = build_tree_list (NULL_TREE, $1); }
  462.     | nonnull_exprlist ',' expr_no_commas
  463.         { chainon ($1, build_tree_list (NULL_TREE, $3)); }
  464.     ;
  465.  
  466. unary_expr:
  467.     primary
  468.     | '*' cast_expr   %prec UNARY
  469.         { $$ = build_indirect_ref ($2, "unary *"); }
  470.     /* __extension__ turns off -pedantic for following primary.  */
  471.     | EXTENSION
  472.         { $<itype>1 = pedantic;
  473.           pedantic = 0; }
  474.       cast_expr      %prec UNARY
  475.         { $$ = $3;
  476.           pedantic = $<itype>1; }
  477.     | unop cast_expr  %prec UNARY
  478.         { $$ = build_unary_op ($1, $2, 0);
  479.           overflow_warning ($$); }
  480.     /* Refer to the address of a label as a pointer.  */
  481.     | ANDAND identifier
  482.         { tree label = lookup_label ($2);
  483.           if (pedantic)
  484.             pedwarn ("ANSI C forbids `&&'");
  485.           if (label == 0)
  486.             $$ = null_pointer_node;
  487.           else
  488.             {
  489.               TREE_USED (label) = 1;
  490.               $$ = build1 (ADDR_EXPR, ptr_type_node, label);
  491.               TREE_CONSTANT ($$) = 1;
  492.             }
  493.         }
  494. /* This seems to be impossible on some machines, so let's turn it off.
  495.    You can use __builtin_next_arg to find the anonymous stack args.
  496.     | '&' ELLIPSIS
  497.         { tree types = TYPE_ARG_TYPES (TREE_TYPE (current_function_decl));
  498.           $$ = error_mark_node;
  499.           if (TREE_VALUE (tree_last (types)) == void_type_node)
  500.             error ("`&...' used in function with fixed number of arguments");
  501.           else
  502.             {
  503.               if (pedantic)
  504.             pedwarn ("ANSI C forbids `&...'");
  505.               $$ = tree_last (DECL_ARGUMENTS (current_function_decl));
  506.               $$ = build_unary_op (ADDR_EXPR, $$, 0);
  507.             } }
  508. */
  509.     | SIZEOF unary_expr  %prec UNARY
  510.         { if (TREE_CODE ($2) == COMPONENT_REF
  511.               && DECL_BIT_FIELD (TREE_OPERAND ($2, 1)))
  512.             error ("`sizeof' applied to a bit-field");
  513.           $$ = c_sizeof (TREE_TYPE ($2)); }
  514.     | SIZEOF '(' typename ')'  %prec HYPERUNARY
  515.         { $$ = c_sizeof (groktypename ($3)); }
  516.     | ALIGNOF unary_expr  %prec UNARY
  517.         { $$ = c_alignof_expr ($2); }
  518.     | ALIGNOF '(' typename ')'  %prec HYPERUNARY
  519.         { $$ = c_alignof (groktypename ($3)); }
  520.     | REALPART cast_expr %prec UNARY
  521.         { $$ = build_unary_op (REALPART_EXPR, $2, 0); }
  522.     | IMAGPART cast_expr %prec UNARY
  523.         { $$ = build_unary_op (IMAGPART_EXPR, $2, 0); }
  524.     ;
  525.  
  526. cast_expr:
  527.     unary_expr
  528.     | '(' typename ')' cast_expr  %prec UNARY
  529.         { tree type = groktypename ($2);
  530.           $$ = build_c_cast (type, $4); }
  531.     | '(' typename ')' '{' 
  532.         { start_init (NULL_TREE, NULL, 0);
  533.           $2 = groktypename ($2);
  534.           really_start_incremental_init ($2); }
  535.       initlist_maybe_comma '}'  %prec UNARY
  536.         { char *name;
  537.           tree result = pop_init_level (0);
  538.           tree type = $2;
  539.           finish_init ();
  540.  
  541.           if (pedantic)
  542.             pedwarn ("ANSI C forbids constructor expressions");
  543.           if (TYPE_NAME (type) != 0)
  544.             {
  545.               if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
  546.             name = IDENTIFIER_POINTER (TYPE_NAME (type));
  547.               else
  548.             name = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type)));
  549.             }
  550.           else
  551.             name = "";
  552.           $$ = result;
  553.           if (TREE_CODE (type) == ARRAY_TYPE && TYPE_SIZE (type) == 0)
  554.             {
  555.               int failure = complete_array_type (type, $$, 1);
  556.               if (failure)
  557.             abort ();
  558.             }
  559.         }
  560.     ;
  561.  
  562. expr_no_commas:
  563.       cast_expr
  564.     | expr_no_commas '+' expr_no_commas
  565.         { $$ = parser_build_binary_op ($2, $1, $3); }
  566.     | expr_no_commas '-' expr_no_commas
  567.         { $$ = parser_build_binary_op ($2, $1, $3); }
  568.     | expr_no_commas '*' expr_no_commas
  569.         { $$ = parser_build_binary_op ($2, $1, $3); }
  570.     | expr_no_commas '/' expr_no_commas
  571.         { $$ = parser_build_binary_op ($2, $1, $3); }
  572.     | expr_no_commas '%' expr_no_commas
  573.         { $$ = parser_build_binary_op ($2, $1, $3); }
  574.     | expr_no_commas LSHIFT expr_no_commas
  575.         { $$ = parser_build_binary_op ($2, $1, $3); }
  576.     | expr_no_commas RSHIFT expr_no_commas
  577.         { $$ = parser_build_binary_op ($2, $1, $3); }
  578.     | expr_no_commas ARITHCOMPARE expr_no_commas
  579.         { $$ = parser_build_binary_op ($2, $1, $3); }
  580.     | expr_no_commas EQCOMPARE expr_no_commas
  581.         { $$ = parser_build_binary_op ($2, $1, $3); }
  582.     | expr_no_commas '&' expr_no_commas
  583.         { $$ = parser_build_binary_op ($2, $1, $3); }
  584.     | expr_no_commas '|' expr_no_commas
  585.         { $$ = parser_build_binary_op ($2, $1, $3); }
  586.     | expr_no_commas '^' expr_no_commas
  587.         { $$ = parser_build_binary_op ($2, $1, $3); }
  588.     | expr_no_commas ANDAND expr_no_commas
  589.         { $$ = parser_build_binary_op (TRUTH_ANDIF_EXPR, $1, $3); }
  590.     | expr_no_commas OROR expr_no_commas
  591.         { $$ = parser_build_binary_op (TRUTH_ORIF_EXPR, $1, $3); }
  592.     | expr_no_commas '?' xexpr ':' expr_no_commas
  593.         { $$ = build_conditional_expr ($1, $3, $5); }
  594.     | expr_no_commas '=' expr_no_commas
  595.         { $$ = build_modify_expr ($1, NOP_EXPR, $3);
  596.           C_SET_EXP_ORIGINAL_CODE ($$, MODIFY_EXPR); }
  597.     | expr_no_commas ASSIGN expr_no_commas
  598.         { $$ = build_modify_expr ($1, $2, $3);
  599.           /* This inhibits warnings in truthvalue_conversion.  */
  600.           C_SET_EXP_ORIGINAL_CODE ($$, ERROR_MARK); }
  601.     ;
  602.  
  603. primary:
  604.     IDENTIFIER
  605.         {
  606.           $$ = lastiddecl;
  607.           if (!$$ || $$ == error_mark_node)
  608.             {
  609.               if (yychar == YYEMPTY)
  610.             yychar = YYLEX;
  611.               if (yychar == '(')
  612.             {
  613. ifobjc
  614.               tree decl;
  615.  
  616.               if (objc_receiver_context
  617.                   && ! (objc_receiver_context
  618.                     && strcmp (IDENTIFIER_POINTER ($1), "super")))
  619.                 /* we have a message to super */
  620.                 $$ = get_super_receiver ();
  621.               else if (objc_method_context
  622.                    && (decl = is_ivar (objc_ivar_chain, $1)))
  623.                 {
  624.                   if (is_private (decl))
  625.                 $$ = error_mark_node;
  626.                   else
  627.                 $$ = build_ivar_reference ($1);
  628.                 }
  629.               else
  630. end ifobjc
  631.                 {
  632.                   /* Ordinary implicit function declaration.  */
  633.                   $$ = implicitly_declare ($1);
  634.                   assemble_external ($$);
  635.                   TREE_USED ($$) = 1;
  636.                 }
  637.             }
  638.               else if (current_function_decl == 0)
  639.             {
  640.               error ("`%s' undeclared here (not in a function)",
  641.                  IDENTIFIER_POINTER ($1));
  642.               $$ = error_mark_node;
  643.             }
  644.               else
  645.             {
  646. ifobjc
  647.               tree decl;
  648.  
  649.                   if (objc_receiver_context
  650.                   && ! strcmp (IDENTIFIER_POINTER ($1), "super"))
  651.                 /* we have a message to super */
  652.                 $$ = get_super_receiver ();
  653.               else if (objc_method_context
  654.                    && (decl = is_ivar (objc_ivar_chain, $1)))
  655.                 {
  656.                   if (is_private (decl))
  657.                 $$ = error_mark_node;
  658.                   else
  659.                 $$ = build_ivar_reference ($1);
  660.                 }
  661.               else
  662. end ifobjc
  663.                 {
  664.                   if (IDENTIFIER_GLOBAL_VALUE ($1) != error_mark_node
  665.                   || IDENTIFIER_ERROR_LOCUS ($1) != current_function_decl)
  666.                 {
  667.                   error ("`%s' undeclared (first use this function)",
  668.                      IDENTIFIER_POINTER ($1));
  669.  
  670.                   if (! undeclared_variable_notice)
  671.                     {
  672.                       error ("(Each undeclared identifier is reported only once");
  673.                       error ("for each function it appears in.)");
  674.                       undeclared_variable_notice = 1;
  675.                     }
  676.                 }
  677.                   $$ = error_mark_node;
  678.                   /* Prevent repeated error messages.  */
  679.                   IDENTIFIER_GLOBAL_VALUE ($1) = error_mark_node;
  680.                   IDENTIFIER_ERROR_LOCUS ($1) = current_function_decl;
  681.                 }
  682.             }
  683.             }
  684.           else if (TREE_TYPE ($$) == error_mark_node)
  685.             $$ = error_mark_node;
  686.           else if (C_DECL_ANTICIPATED ($$))
  687.             {
  688.               /* The first time we see a build-in function used,
  689.              if it has not been declared.  */
  690.               C_DECL_ANTICIPATED ($$) = 0;
  691.               if (yychar == YYEMPTY)
  692.             yychar = YYLEX;
  693.               if (yychar == '(')
  694.             {
  695.               /* Omit the implicit declaration we
  696.                  would ordinarily do, so we don't lose
  697.                  the actual built in type.
  698.                  But print a diagnostic for the mismatch.  */
  699. ifobjc
  700.               if (objc_method_context
  701.                   && is_ivar (objc_ivar_chain, $1))
  702.                 error ("Instance variable `%s' implicitly declared as function",
  703.                    IDENTIFIER_POINTER (DECL_NAME ($$)));
  704.               else
  705. end ifobjc
  706.                 if (TREE_CODE ($$) != FUNCTION_DECL)
  707.                   error ("`%s' implicitly declared as function",
  708.                      IDENTIFIER_POINTER (DECL_NAME ($$)));
  709.               else if ((TYPE_MODE (TREE_TYPE (TREE_TYPE ($$)))
  710.                     != TYPE_MODE (integer_type_node))
  711.                    && (TREE_TYPE (TREE_TYPE ($$))
  712.                        != void_type_node))
  713.                 pedwarn ("type mismatch in implicit declaration for built-in function `%s'",
  714.                      IDENTIFIER_POINTER (DECL_NAME ($$)));
  715.               /* If it really returns void, change that to int.  */
  716.               if (TREE_TYPE (TREE_TYPE ($$)) == void_type_node)
  717.                 TREE_TYPE ($$)
  718.                   = build_function_type (integer_type_node,
  719.                              TYPE_ARG_TYPES (TREE_TYPE ($$)));
  720.             }
  721.               else
  722.             pedwarn ("built-in function `%s' used without declaration",
  723.                  IDENTIFIER_POINTER (DECL_NAME ($$)));
  724.  
  725.               /* Do what we would ordinarily do when a fn is used.  */
  726.               assemble_external ($$);
  727.               TREE_USED ($$) = 1;
  728.             }
  729.           else
  730.             {
  731.               assemble_external ($$);
  732.               TREE_USED ($$) = 1;
  733. ifobjc
  734.               /* we have a definition - still check if iVariable */
  735.  
  736.               if (!objc_receiver_context
  737.               || (objc_receiver_context
  738.                   && strcmp (IDENTIFIER_POINTER ($1), "super")))
  739.                         {
  740.               tree decl;
  741.  
  742.               if (objc_method_context
  743.                   && (decl = is_ivar (objc_ivar_chain, $1)))
  744.                             {
  745.                               if (IDENTIFIER_LOCAL_VALUE ($1))
  746.                                 warning ("local declaration of `%s' hides instance variable",
  747.                                      IDENTIFIER_POINTER ($1));
  748.                               else
  749.                  {
  750.                    if (is_private (decl))
  751.                      $$ = error_mark_node;
  752.                    else
  753.                      $$ = build_ivar_reference ($1);
  754.                  }
  755.                             }
  756.             }
  757.                       else /* we have a message to super */
  758.                 $$ = get_super_receiver ();
  759. end ifobjc
  760.             }
  761.  
  762.           if (TREE_CODE ($$) == CONST_DECL)
  763.             {
  764.               $$ = DECL_INITIAL ($$);
  765.               /* This is to prevent an enum whose value is 0
  766.              from being considered a null pointer constant.  */
  767.               $$ = build1 (NOP_EXPR, TREE_TYPE ($$), $$);
  768.               TREE_CONSTANT ($$) = 1;
  769.             }
  770.         }
  771.     | CONSTANT
  772.     | string
  773.         { $$ = combine_strings ($1); }
  774.     | '(' expr ')'
  775.         { char class = TREE_CODE_CLASS (TREE_CODE ($2));
  776.           if (class == 'e' || class == '1'
  777.               || class == '2' || class == '<')
  778.             C_SET_EXP_ORIGINAL_CODE ($2, ERROR_MARK);
  779.           $$ = $2; }
  780.     | '(' error ')'
  781.         { $$ = error_mark_node; }
  782.     | '('
  783.         { if (current_function_decl == 0)
  784.             {
  785.               error ("braced-group within expression allowed only inside a function");
  786.               YYERROR;
  787.             }
  788.           /* We must force a BLOCK for this level
  789.              so that, if it is not expanded later,
  790.              there is a way to turn off the entire subtree of blocks
  791.              that are contained in it.  */
  792.           keep_next_level ();
  793.           push_iterator_stack ();
  794.           push_label_level ();
  795.           $<ttype>$ = expand_start_stmt_expr (); }
  796.       compstmt ')'
  797.         { tree rtl_exp;
  798.           if (pedantic)
  799.             pedwarn ("ANSI C forbids braced-groups within expressions");
  800.           pop_iterator_stack ();
  801.           pop_label_level ();
  802.           rtl_exp = expand_end_stmt_expr ($<ttype>2);
  803.           /* The statements have side effects, so the group does.  */
  804.           TREE_SIDE_EFFECTS (rtl_exp) = 1;
  805.  
  806.           if (TREE_CODE ($3) == BLOCK)
  807.             {
  808.               /* Make a BIND_EXPR for the BLOCK already made.  */
  809.               $$ = build (BIND_EXPR, TREE_TYPE (rtl_exp),
  810.                   NULL_TREE, rtl_exp, $3);
  811.               /* Remove the block from the tree at this point.
  812.              It gets put back at the proper place
  813.              when the BIND_EXPR is expanded.  */
  814.               delete_block ($3);
  815.             }
  816.           else
  817.             $$ = $3;
  818.         }
  819.     | primary '(' exprlist ')'   %prec '.'
  820.         { $$ = build_function_call ($1, $3); }
  821.     | primary '[' expr ']'   %prec '.'
  822.         { $$ = build_array_ref ($1, $3); }
  823.     | primary '.' identifier
  824.         {
  825. ifobjc
  826.                   if (doing_objc_thang)
  827.                     {
  828.               if (is_public ($1, $3))
  829.             $$ = build_component_ref ($1, $3);
  830.               else
  831.             $$ = error_mark_node;
  832.             }
  833.                   else
  834. end ifobjc
  835.             $$ = build_component_ref ($1, $3);
  836.         }
  837.     | primary POINTSAT identifier
  838.         {
  839.                   tree expr = build_indirect_ref ($1, "->");
  840.  
  841. ifobjc
  842.                   if (doing_objc_thang)
  843.                     {
  844.               if (is_public (expr, $3))
  845.             $$ = build_component_ref (expr, $3);
  846.               else
  847.             $$ = error_mark_node;
  848.             }
  849.                   else
  850. end ifobjc
  851.                     $$ = build_component_ref (expr, $3);
  852.         }
  853.     | primary PLUSPLUS
  854.         { $$ = build_unary_op (POSTINCREMENT_EXPR, $1, 0); }
  855.     | primary MINUSMINUS
  856.         { $$ = build_unary_op (POSTDECREMENT_EXPR, $1, 0); }
  857. ifobjc
  858.     | objcmessageexpr
  859.         { $$ = build_message_expr ($1); }
  860.     | objcselectorexpr
  861.         { $$ = build_selector_expr ($1); }
  862.     | objcprotocolexpr
  863.         { $$ = build_protocol_expr ($1); }
  864.     | objcencodeexpr
  865.         { $$ = build_encode_expr ($1); }
  866.     | objc_string
  867.         { $$ = build_objc_string_object ($1); }
  868. end ifobjc
  869.     ;
  870.  
  871. /* Produces a STRING_CST with perhaps more STRING_CSTs chained onto it.  */
  872. string:
  873.       STRING
  874.     | string STRING
  875.         { $$ = chainon ($1, $2); }
  876.     ;
  877.  
  878. ifobjc
  879. /* Produces an OBJC_STRING_CST with perhaps more OBJC_STRING_CSTs chained
  880.    onto it.  */
  881. objc_string:
  882.       OBJC_STRING
  883.     | objc_string OBJC_STRING
  884.         { $$ = chainon ($1, $2); }
  885.     ;
  886. end ifobjc
  887.  
  888. xdecls:
  889.     /* empty */
  890.     | datadecls
  891.     | datadecls ELLIPSIS
  892.         /* ... is used here to indicate a varargs function.  */
  893.         { c_mark_varargs ();
  894.           if (pedantic)
  895.             pedwarn ("ANSI C does not permit use of `varargs.h'"); }
  896.     ;
  897.  
  898. /* The following are analogous to lineno_decl, decls and decl
  899.    except that they do not allow nested functions.
  900.    They are used for old-style parm decls.  */
  901. lineno_datadecl:
  902.       save_filename save_lineno datadecl
  903.         { }
  904.     ;
  905.  
  906. datadecls:
  907.     lineno_datadecl
  908.     | errstmt
  909.     | datadecls lineno_datadecl
  910.     | lineno_datadecl errstmt
  911.     ;
  912.  
  913. datadecl:
  914.     typed_declspecs setspecs initdecls ';'
  915.         { current_declspecs = TREE_VALUE (declspec_stack);
  916.           prefix_attributes = TREE_PURPOSE (declspec_stack);
  917.           declspec_stack = TREE_CHAIN (declspec_stack);
  918.           resume_momentary ($2); }
  919.     | declmods setspecs notype_initdecls ';'
  920.         { current_declspecs = TREE_VALUE (declspec_stack);    
  921.           prefix_attributes = TREE_PURPOSE (declspec_stack);
  922.           declspec_stack = TREE_CHAIN (declspec_stack);
  923.           resume_momentary ($2); }
  924.     | typed_declspecs ';'
  925.         { shadow_tag_warned ($1, 1);
  926.           pedwarn ("empty declaration"); }
  927.     | declmods ';'
  928.         { pedwarn ("empty declaration"); }
  929.     ;
  930.  
  931. /* This combination which saves a lineno before a decl
  932.    is the normal thing to use, rather than decl itself.
  933.    This is to avoid shift/reduce conflicts in contexts
  934.    where statement labels are allowed.  */
  935. lineno_decl:
  936.       save_filename save_lineno decl
  937.         { }
  938.     ;
  939.  
  940. decls:
  941.     lineno_decl
  942.     | errstmt
  943.     | decls lineno_decl
  944.     | lineno_decl errstmt
  945.     ;
  946.  
  947. /* records the type and storage class specs to use for processing
  948.    the declarators that follow.
  949.    Maintains a stack of outer-level values of current_declspecs,
  950.    for the sake of parm declarations nested in function declarators.  */
  951. setspecs: /* empty */
  952.         { $$ = suspend_momentary ();
  953.           pending_xref_error ();
  954.           declspec_stack = tree_cons (prefix_attributes,
  955.                           current_declspecs,
  956.                           declspec_stack);
  957.           current_declspecs = $<ttype>0; 
  958.           prefix_attributes = NULL_TREE; }
  959.     ;
  960.  
  961. setattrs: /* empty */
  962.         { prefix_attributes = chainon (prefix_attributes, $<ttype>0); }
  963.     ;
  964.  
  965. decl:
  966.     typed_declspecs setspecs initdecls ';'
  967.         { current_declspecs = TREE_VALUE (declspec_stack);
  968.           prefix_attributes = TREE_PURPOSE (declspec_stack);
  969.           declspec_stack = TREE_CHAIN (declspec_stack);
  970.           resume_momentary ($2); }
  971.     | declmods setspecs notype_initdecls ';'
  972.         { current_declspecs = TREE_VALUE (declspec_stack);
  973.           prefix_attributes = TREE_PURPOSE (declspec_stack);
  974.           declspec_stack = TREE_CHAIN (declspec_stack);
  975.           resume_momentary ($2); }
  976.     | typed_declspecs setspecs nested_function
  977.         { current_declspecs = TREE_VALUE (declspec_stack);
  978.           prefix_attributes = TREE_PURPOSE (declspec_stack);
  979.           declspec_stack = TREE_CHAIN (declspec_stack);
  980.           resume_momentary ($2); }
  981.     | declmods setspecs notype_nested_function
  982.         { current_declspecs = TREE_VALUE (declspec_stack);
  983.           prefix_attributes = TREE_PURPOSE (declspec_stack);
  984.           declspec_stack = TREE_CHAIN (declspec_stack);
  985.           resume_momentary ($2); }
  986.     | typed_declspecs ';'
  987.         { shadow_tag ($1); }
  988.     | declmods ';'
  989.         { pedwarn ("empty declaration"); }
  990.     ;
  991.  
  992. /* Declspecs which contain at least one type specifier or typedef name.
  993.    (Just `const' or `volatile' is not enough.)
  994.    A typedef'd name following these is taken as a name to be declared.  */
  995.  
  996. typed_declspecs:
  997.       typespec reserved_declspecs
  998.         { $$ = tree_cons (NULL_TREE, $1, $2); }
  999.     | declmods typespec reserved_declspecs
  1000.         { $$ = chainon ($3, tree_cons (NULL_TREE, $2, $1)); }
  1001.     ;
  1002.  
  1003. reserved_declspecs:  /* empty */
  1004.         { $$ = NULL_TREE; }
  1005.     | reserved_declspecs typespecqual_reserved
  1006.         { $$ = tree_cons (NULL_TREE, $2, $1); }
  1007.     | reserved_declspecs SCSPEC
  1008.         { if (extra_warnings)
  1009.             warning ("`%s' is not at beginning of declaration",
  1010.                  IDENTIFIER_POINTER ($2));
  1011.           $$ = tree_cons (NULL_TREE, $2, $1); }
  1012.     ;
  1013.  
  1014. /* List of just storage classes and type modifiers.
  1015.    A declaration can start with just this, but then it cannot be used
  1016.    to redeclare a typedef-name.  */
  1017.  
  1018. declmods:
  1019.       TYPE_QUAL
  1020.         { $$ = tree_cons (NULL_TREE, $1, NULL_TREE);
  1021.           TREE_STATIC ($$) = 1; }
  1022.     | SCSPEC
  1023.         { $$ = tree_cons (NULL_TREE, $1, NULL_TREE); }
  1024. ifwin32
  1025.     | declspec
  1026.         { $$ = tree_cons (NULL_TREE, $1, NULL_TREE); }
  1027. end ifwin32
  1028.     | declmods TYPE_QUAL
  1029.         { $$ = tree_cons (NULL_TREE, $2, $1);
  1030.           TREE_STATIC ($$) = 1; }
  1031.     | declmods SCSPEC
  1032.         { if (extra_warnings && TREE_STATIC ($1))
  1033.             warning ("`%s' is not at beginning of declaration",
  1034.                  IDENTIFIER_POINTER ($2));
  1035.           $$ = tree_cons (NULL_TREE, $2, $1);
  1036.           TREE_STATIC ($$) = TREE_STATIC ($1); }
  1037. ifwin32
  1038.     | declmods declspec
  1039.         { $$ = tree_cons (NULL_TREE, $2, $1); }
  1040. end ifwin32
  1041.     ;
  1042.  
  1043.  
  1044. /* Used instead of declspecs where storage classes are not allowed
  1045.    (that is, for typenames and structure components).
  1046.    Don't accept a typedef-name if anything but a modifier precedes it.  */
  1047.  
  1048. typed_typespecs:
  1049.       typespec reserved_typespecquals
  1050.         { $$ = tree_cons (NULL_TREE, $1, $2); }
  1051.     | nonempty_type_quals typespec reserved_typespecquals
  1052.         { $$ = chainon ($3, tree_cons (NULL_TREE, $2, $1)); }
  1053.     ;
  1054.  
  1055. reserved_typespecquals:  /* empty */
  1056.         { $$ = NULL_TREE; }
  1057.     | reserved_typespecquals typespecqual_reserved
  1058.         { $$ = tree_cons (NULL_TREE, $2, $1); }
  1059.     ;
  1060.  
  1061. /* A typespec (but not a type qualifier).
  1062.    Once we have seen one of these in a declaration,
  1063.    if a typedef name appears then it is being redeclared.  */
  1064.  
  1065. typespec: TYPESPEC
  1066.     | structsp
  1067.     | TYPENAME
  1068.         { /* For a typedef name, record the meaning, not the name.
  1069.              In case of `foo foo, bar;'.  */
  1070.           $$ = lookup_name ($1); }
  1071. ifobjc
  1072.     | CLASSNAME protocolrefs
  1073.         { $$ = get_static_reference ($1, $2); }
  1074.     | OBJECTNAME protocolrefs
  1075.         { $$ = get_object_reference ($2); }
  1076. end ifobjc
  1077.     | TYPEOF '(' expr ')'
  1078.         { $$ = TREE_TYPE ($3); }
  1079.     | TYPEOF '(' typename ')'
  1080.         { $$ = groktypename ($3); }
  1081.     ;
  1082.  
  1083. /* A typespec that is a reserved word, or a type qualifier.  */
  1084.  
  1085. typespecqual_reserved: TYPESPEC
  1086.     | TYPE_QUAL
  1087.     | structsp
  1088.     ;
  1089.  
  1090. initdecls:
  1091.     initdcl
  1092.     | initdecls ',' initdcl
  1093.     ;
  1094.  
  1095. notype_initdecls:
  1096.     notype_initdcl
  1097.     | notype_initdecls ',' initdcl
  1098.     ;
  1099.  
  1100. maybeasm:
  1101.       /* empty */
  1102.         { $$ = NULL_TREE; }
  1103.     | ASM_KEYWORD '(' string ')'
  1104.         { if (TREE_CHAIN ($3)) $3 = combine_strings ($3);
  1105.           $$ = $3;
  1106.         }
  1107.     ;
  1108.  
  1109. initdcl:
  1110.       declarator maybeasm maybe_attribute '='
  1111.         { $<ttype>$ = start_decl ($1, current_declspecs, 1,
  1112.                       $3, prefix_attributes);
  1113.           start_init ($<ttype>$, $2, global_bindings_p ()); }
  1114.       init
  1115. /* Note how the declaration of the variable is in effect while its init is parsed! */
  1116.         { finish_init ();
  1117.           finish_decl ($<ttype>5, $6, $2); }
  1118.     | declarator maybeasm maybe_attribute
  1119.         { tree d = start_decl ($1, current_declspecs, 0,
  1120.                        $3, prefix_attributes);
  1121.           finish_decl (d, NULL_TREE, $2); 
  1122.                 }
  1123.     ;
  1124.  
  1125. notype_initdcl:
  1126.       notype_declarator maybeasm maybe_attribute '='
  1127.         { $<ttype>$ = start_decl ($1, current_declspecs, 1,
  1128.                       $3, prefix_attributes);
  1129.           start_init ($<ttype>$, $2, global_bindings_p ()); }
  1130.       init
  1131. /* Note how the declaration of the variable is in effect while its init is parsed! */
  1132.         { finish_init ();
  1133.           decl_attributes ($<ttype>5, $3, prefix_attributes);
  1134.           finish_decl ($<ttype>5, $6, $2); }
  1135.     | notype_declarator maybeasm maybe_attribute
  1136.         { tree d = start_decl ($1, current_declspecs, 0,
  1137.                        $3, prefix_attributes);
  1138.           finish_decl (d, NULL_TREE, $2); }
  1139.     ;
  1140. /* the * rules are dummies to accept the Apollo extended syntax
  1141.    so that the header files compile. */
  1142. maybe_attribute:
  1143.       /* empty */
  1144.           { $$ = NULL_TREE; }
  1145.     | attributes
  1146.         { $$ = $1; }
  1147.     ;
  1148.  
  1149. attributes:
  1150.       attribute
  1151.         { $$ = $1; }
  1152.     | attributes attribute
  1153.         { $$ = chainon ($1, $2); }
  1154.     ;
  1155.  
  1156. attribute:
  1157.       ATTRIBUTE '(' '(' attribute_list ')' ')'
  1158.         { $$ = $4; }
  1159.     ;
  1160.  
  1161. attribute_list:
  1162.       attrib
  1163.         { $$ = $1; }
  1164.     | attribute_list ',' attrib
  1165.         { $$ = chainon ($1, $3); }
  1166.     ;
  1167.  
  1168. attrib:
  1169.     /* empty */
  1170.         { $$ = NULL_TREE; }
  1171.     | any_word
  1172.         { $$ = build_tree_list ($1, NULL_TREE); }
  1173.     | any_word '(' IDENTIFIER ')'
  1174.         { $$ = build_tree_list ($1, build_tree_list (NULL_TREE, $3)); }
  1175.     | any_word '(' IDENTIFIER ',' nonnull_exprlist ')'
  1176.         { $$ = build_tree_list ($1, tree_cons (NULL_TREE, $3, $5)); }
  1177.     | any_word '(' exprlist ')'
  1178.         { $$ = build_tree_list ($1, $3); }
  1179.     ;
  1180.  
  1181. /* This still leaves out most reserved keywords,
  1182.    shouldn't we include them?  */
  1183.  
  1184. any_word:
  1185.       identifier
  1186.     | SCSPEC
  1187.     | TYPESPEC
  1188.     | TYPE_QUAL
  1189.     ;
  1190.  
  1191. /* Initializers.  `init' is the entry point.  */
  1192.  
  1193. init:
  1194.     expr_no_commas
  1195.     | '{'
  1196.         { really_start_incremental_init (NULL_TREE);
  1197.           /* Note that the call to clear_momentary
  1198.              is in process_init_element.  */
  1199.           push_momentary (); }
  1200.       initlist_maybe_comma '}'
  1201.         { $$ = pop_init_level (0);
  1202.           if ($$ == error_mark_node
  1203.               && ! (yychar == STRING || yychar == CONSTANT))
  1204.             pop_momentary ();
  1205.           else
  1206.             pop_momentary_nofree (); }
  1207.  
  1208.     | error
  1209.         { $$ = error_mark_node; }
  1210.     ;
  1211.  
  1212. /* `initlist_maybe_comma' is the guts of an initializer in braces.  */
  1213. initlist_maybe_comma:
  1214.       /* empty */
  1215.         { if (pedantic)
  1216.             pedwarn ("ANSI C forbids empty initializer braces"); }
  1217.     | initlist1 maybecomma
  1218.     ;
  1219.  
  1220. initlist1:
  1221.       initelt
  1222.     | initlist1 ',' initelt
  1223.     ;
  1224.  
  1225. /* `initelt' is a single element of an initializer.
  1226.    It may use braces.  */
  1227. initelt:
  1228.     expr_no_commas
  1229.         { process_init_element ($1); }
  1230.     | '{' 
  1231.         { push_init_level (0); }
  1232.       initlist_maybe_comma '}'
  1233.         { process_init_element (pop_init_level (0)); }
  1234.     | error
  1235.     /* These are for labeled elements.  The syntax for an array element
  1236.        initializer conflicts with the syntax for an Objective-C message,
  1237.        so don't include these productions in the Objective-C grammar.  */
  1238. ifc
  1239.     | '[' expr_no_commas ELLIPSIS expr_no_commas ']' '='
  1240.         { set_init_index ($2, $4); }
  1241.       initelt
  1242.     | '[' expr_no_commas ']' '='
  1243.         { set_init_index ($2, NULL_TREE); }
  1244.       initelt
  1245.     | '[' expr_no_commas ']'
  1246.         { set_init_index ($2, NULL_TREE); }
  1247.       initelt
  1248. end ifc
  1249. ifobjc
  1250.     | objc_openbracket.expr_no_commas ELLIPSIS expr_no_commas ']' '='
  1251.         { set_init_index ($1, $3); }
  1252.       initelt
  1253.     | objc_openbracket.expr_no_commas ']' '='
  1254.         { set_init_index ($1, NULL_TREE); }
  1255.       initelt
  1256.     | objc_openbracket.expr_no_commas ']'
  1257.         { set_init_index ($1, NULL_TREE); }
  1258.       initelt
  1259. end ifobjc
  1260.     | identifier ':'
  1261.         { set_init_label ($1); }
  1262.       initelt
  1263.     | '.' identifier '='
  1264.         { set_init_label ($2); }
  1265.       initelt
  1266.     ;
  1267.  
  1268. nested_function:
  1269.       declarator
  1270.         { push_c_function_context ();
  1271.           if (! start_function (current_declspecs, $1,
  1272.                     prefix_attributes, NULL_TREE, 1))
  1273.             {
  1274.               pop_c_function_context ();
  1275.               YYERROR1;
  1276.             }
  1277.           reinit_parse_for_function (); }
  1278.        xdecls
  1279.         { store_parm_decls (); }
  1280. /* This used to use compstmt_or_error.
  1281.    That caused a bug with input `f(g) int g {}',
  1282.    where the use of YYERROR1 above caused an error
  1283.    which then was handled by compstmt_or_error.
  1284.    There followed a repeated execution of that same rule,
  1285.    which called YYERROR1 again, and so on.  */
  1286.       compstmt
  1287.         { finish_function (1);
  1288.           pop_c_function_context (); }
  1289.     ;
  1290.  
  1291. notype_nested_function:
  1292.       notype_declarator
  1293.         { push_c_function_context ();
  1294.           if (! start_function (current_declspecs, $1,
  1295.                     prefix_attributes, NULL_TREE, 1))
  1296.             {
  1297.               pop_c_function_context ();
  1298.               YYERROR1;
  1299.             }
  1300.           reinit_parse_for_function (); }
  1301.       xdecls
  1302.         { store_parm_decls (); }
  1303. /* This used to use compstmt_or_error.
  1304.    That caused a bug with input `f(g) int g {}',
  1305.    where the use of YYERROR1 above caused an error
  1306.    which then was handled by compstmt_or_error.
  1307.    There followed a repeated execution of that same rule,
  1308.    which called YYERROR1 again, and so on.  */
  1309.       compstmt
  1310.         { finish_function (1);
  1311.           pop_c_function_context (); }
  1312.     ;
  1313.  
  1314. /* Any kind of declarator (thus, all declarators allowed
  1315.    after an explicit typespec).  */
  1316.  
  1317. declarator:
  1318.       after_type_declarator
  1319.     | notype_declarator
  1320.     ;
  1321.  
  1322. /* A declarator that is allowed only after an explicit typespec.  */
  1323.  
  1324. after_type_declarator:
  1325.       '(' after_type_declarator ')'
  1326.         { $$ = $2; }
  1327.     | after_type_declarator '(' parmlist_or_identifiers  %prec '.'
  1328.         { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
  1329. /*    | after_type_declarator '(' error ')'  %prec '.'
  1330.         { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
  1331.           poplevel (0, 0, 0); }  */
  1332.     | after_type_declarator '[' expr ']'  %prec '.'
  1333.         { $$ = build_nt (ARRAY_REF, $1, $3); }
  1334.     | after_type_declarator '[' ']'  %prec '.'
  1335.         { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
  1336.     | '*' type_quals after_type_declarator  %prec UNARY
  1337.         { $$ = make_pointer_declarator ($2, $3); }
  1338.     | attributes setattrs after_type_declarator
  1339.         { $$ = $3; }
  1340.     | TYPENAME
  1341. ifobjc
  1342.     | OBJECTNAME
  1343. end ifobjc
  1344.     ;
  1345.  
  1346. /* Kinds of declarator that can appear in a parameter list
  1347.    in addition to notype_declarator.  This is like after_type_declarator
  1348.    but does not allow a typedef name in parentheses as an identifier
  1349.    (because it would conflict with a function with that typedef as arg).  */
  1350.  
  1351. parm_declarator:
  1352.       parm_declarator '(' parmlist_or_identifiers  %prec '.'
  1353.         { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
  1354. /*    | parm_declarator '(' error ')'  %prec '.'
  1355.         { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
  1356.           poplevel (0, 0, 0); }  */
  1357.     | parm_declarator '[' expr ']'  %prec '.'
  1358.         { $$ = build_nt (ARRAY_REF, $1, $3); }
  1359.     | parm_declarator '[' ']'  %prec '.'
  1360.         { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
  1361.     | '*' type_quals parm_declarator  %prec UNARY
  1362.         { $$ = make_pointer_declarator ($2, $3); }
  1363.     | attributes setattrs parm_declarator
  1364.         { $$ = $3; }
  1365.     | TYPENAME
  1366. ifobjc
  1367.     | OBJECTNAME
  1368. end ifobjc
  1369.     ;
  1370.  
  1371. /* A declarator allowed whether or not there has been
  1372.    an explicit typespec.  These cannot redeclare a typedef-name.  */
  1373.  
  1374. notype_declarator:
  1375.       notype_declarator '(' parmlist_or_identifiers  %prec '.'
  1376.         { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
  1377. /*    | notype_declarator '(' error ')'  %prec '.'
  1378.         { $$ = build_nt (CALL_EXPR, $1, NULL_TREE, NULL_TREE);
  1379.           poplevel (0, 0, 0); }  */
  1380.     | '(' notype_declarator ')'
  1381.         { $$ = $2; }
  1382.     | '*' type_quals notype_declarator  %prec UNARY
  1383.         { $$ = make_pointer_declarator ($2, $3); }
  1384. ifwin32
  1385.     | type_quals '*' notype_declarator  %prec UNARY    
  1386.         { $$ = make_pointer_declarator ($1, $3); }
  1387. end ifwin32
  1388.     | notype_declarator '[' expr ']'  %prec '.'
  1389.         { $$ = build_nt (ARRAY_REF, $1, $3); }
  1390.     | notype_declarator '[' ']'  %prec '.'
  1391.         { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
  1392.     | attributes setattrs notype_declarator
  1393.         { $$ = $3; }
  1394.     | IDENTIFIER
  1395.     ;
  1396.  
  1397. structsp:
  1398.       STRUCT identifier '{'
  1399.         { $$ = start_struct (RECORD_TYPE, $2);
  1400.           /* Start scope of tag before parsing components.  */
  1401.         }
  1402.       component_decl_list '}' maybe_attribute 
  1403.         { $$ = finish_struct ($<ttype>4, $5, $7); }
  1404.     | STRUCT '{' component_decl_list '}' maybe_attribute
  1405.         { $$ = finish_struct (start_struct (RECORD_TYPE, NULL_TREE),
  1406.                       $3, $5);
  1407.         }
  1408.     | STRUCT identifier
  1409.         { $$ = xref_tag (RECORD_TYPE, $2); }
  1410.     | UNION identifier '{'
  1411.         { $$ = start_struct (UNION_TYPE, $2); }
  1412.       component_decl_list '}' maybe_attribute
  1413.         { $$ = finish_struct ($<ttype>4, $5, $7); }
  1414.     | UNION '{' component_decl_list '}' maybe_attribute
  1415.         { $$ = finish_struct (start_struct (UNION_TYPE, NULL_TREE),
  1416.                       $3, $5);
  1417.         }
  1418.     | UNION identifier
  1419.         { $$ = xref_tag (UNION_TYPE, $2); }
  1420.     | ENUM identifier '{'
  1421.         { $<itype>3 = suspend_momentary ();
  1422.           $$ = start_enum ($2); }
  1423.       enumlist maybecomma_warn '}' maybe_attribute
  1424.         { $$ = finish_enum ($<ttype>4, nreverse ($5), $8);
  1425.           resume_momentary ($<itype>3); }
  1426.     | ENUM '{'
  1427.         { $<itype>2 = suspend_momentary ();
  1428.           $$ = start_enum (NULL_TREE); }
  1429.       enumlist maybecomma_warn '}' maybe_attribute
  1430.         { $$ = finish_enum ($<ttype>3, nreverse ($4), $7);
  1431.           resume_momentary ($<itype>2); }
  1432.     | ENUM identifier
  1433.         { $$ = xref_tag (ENUMERAL_TYPE, $2); }
  1434.     ;
  1435.  
  1436. maybecomma:
  1437.       /* empty */
  1438.     | ','
  1439.     ;
  1440.  
  1441. maybecomma_warn:
  1442.       /* empty */
  1443.     | ','
  1444.         { if (pedantic) pedwarn ("comma at end of enumerator list"); }
  1445.     ;
  1446.  
  1447. component_decl_list:
  1448.       component_decl_list2
  1449.         { $$ = $1; }
  1450.     | component_decl_list2 component_decl
  1451.         { $$ = chainon ($1, $2);
  1452.           pedwarn ("no semicolon at end of struct or union"); }
  1453.     ;
  1454.  
  1455. component_decl_list2:    /* empty */
  1456.         { $$ = NULL_TREE; }
  1457.     | component_decl_list2 component_decl ';'
  1458.         { $$ = chainon ($1, $2); }
  1459.     | component_decl_list2 ';'
  1460.         { if (pedantic)
  1461.             pedwarn ("extra semicolon in struct or union specified"); }
  1462. ifobjc
  1463.     /* foo(sizeof(struct{ @defs(ClassName)})); */
  1464.     | DEFS '(' CLASSNAME ')'
  1465.         {
  1466.           tree interface = lookup_interface ($3);
  1467.  
  1468.           if (interface)
  1469.             $$ = get_class_ivars (interface);
  1470.           else
  1471.             {
  1472.               error ("Cannot find interface declaration for `%s'",
  1473.                  IDENTIFIER_POINTER ($3));
  1474.               $$ = NULL_TREE;
  1475.             }
  1476.         }
  1477. end ifobjc
  1478.     ;
  1479.  
  1480. /* There is a shift-reduce conflict here, because `components' may
  1481.    start with a `typename'.  It happens that shifting (the default resolution)
  1482.    does the right thing, because it treats the `typename' as part of
  1483.    a `typed_typespecs'.
  1484.  
  1485.    It is possible that this same technique would allow the distinction
  1486.    between `notype_initdecls' and `initdecls' to be eliminated.
  1487.    But I am being cautious and not trying it.  */
  1488.  
  1489. component_decl:
  1490.       typed_typespecs setspecs components
  1491.         { $$ = $3;
  1492.           current_declspecs = TREE_VALUE (declspec_stack);
  1493.           prefix_attributes = TREE_PURPOSE (declspec_stack);
  1494.           declspec_stack = TREE_CHAIN (declspec_stack);
  1495.           resume_momentary ($2); }
  1496.     | typed_typespecs
  1497.         { if (pedantic)
  1498.             pedwarn ("ANSI C forbids member declarations with no members");
  1499.           shadow_tag($1);
  1500.           $$ = NULL_TREE; }
  1501.     | nonempty_type_quals setspecs components
  1502.         { $$ = $3;
  1503.           current_declspecs = TREE_VALUE (declspec_stack);
  1504.           prefix_attributes = TREE_PURPOSE (declspec_stack);
  1505.           declspec_stack = TREE_CHAIN (declspec_stack);
  1506.           resume_momentary ($2); }
  1507.     | nonempty_type_quals
  1508.         { if (pedantic)
  1509.             pedwarn ("ANSI C forbids member declarations with no members");
  1510.           shadow_tag($1);
  1511.           $$ = NULL_TREE; }
  1512.     | error
  1513.         { $$ = NULL_TREE; }
  1514.     ;
  1515.  
  1516. components:
  1517.       component_declarator
  1518.     | components ',' component_declarator
  1519.         { $$ = chainon ($1, $3); }
  1520.     ;
  1521.  
  1522. component_declarator:
  1523.       save_filename save_lineno declarator maybe_attribute
  1524.         { $$ = grokfield ($1, $2, $3, current_declspecs, NULL_TREE);
  1525.           decl_attributes ($$, $4, prefix_attributes); }
  1526.     | save_filename save_lineno
  1527.       declarator ':' expr_no_commas maybe_attribute
  1528.         { $$ = grokfield ($1, $2, $3, current_declspecs, $5);
  1529.           decl_attributes ($$, $6, prefix_attributes); }
  1530.     | save_filename save_lineno ':' expr_no_commas maybe_attribute
  1531.         { $$ = grokfield ($1, $2, NULL_TREE, current_declspecs, $4);
  1532.           decl_attributes ($$, $5, prefix_attributes); }
  1533.     ;
  1534.  
  1535. /* We chain the enumerators in reverse order.
  1536.    They are put in forward order where enumlist is used.
  1537.    (The order used to be significant, but no longer is so.
  1538.    However, we still maintain the order, just to be clean.)  */
  1539.  
  1540. enumlist:
  1541.       enumerator
  1542.     | enumlist ',' enumerator
  1543.         { if ($1 == error_mark_node)
  1544.             $$ = $1;
  1545.           else
  1546.             $$ = chainon ($3, $1); }
  1547.     | error
  1548.         { $$ = error_mark_node; }
  1549.     ;
  1550.  
  1551.  
  1552. enumerator:
  1553.       identifier
  1554.         { $$ = build_enumerator ($1, NULL_TREE); }
  1555.     | identifier '=' expr_no_commas
  1556.         { $$ = build_enumerator ($1, $3); }
  1557.     ;
  1558.  
  1559. typename:
  1560.     typed_typespecs absdcl
  1561.         { $$ = build_tree_list ($1, $2); }
  1562.     | nonempty_type_quals absdcl
  1563.         { $$ = build_tree_list ($1, $2); }
  1564.     ;
  1565.  
  1566. absdcl:   /* an absolute declarator */
  1567.     /* empty */
  1568.         { $$ = NULL_TREE; }
  1569.     | absdcl1
  1570.     ;
  1571.  
  1572. nonempty_type_quals:
  1573.       TYPE_QUAL
  1574.         { $$ = tree_cons (NULL_TREE, $1, NULL_TREE); }
  1575.     | nonempty_type_quals TYPE_QUAL
  1576.         { $$ = tree_cons (NULL_TREE, $2, $1); }
  1577.     ;
  1578.  
  1579. type_quals:
  1580.       /* empty */
  1581.         { $$ = NULL_TREE; }
  1582.     | type_quals TYPE_QUAL
  1583.         { $$ = tree_cons (NULL_TREE, $2, $1); }
  1584.     ;
  1585.  
  1586. absdcl1:  /* a nonempty absolute declarator */
  1587.       '(' absdcl1 ')'
  1588.         { $$ = $2; }
  1589.       /* `(typedef)1' is `int'.  */
  1590.     | '*' type_quals absdcl1  %prec UNARY
  1591.         { $$ = make_pointer_declarator ($2, $3); }
  1592.     | '*' type_quals  %prec UNARY
  1593.         { $$ = make_pointer_declarator ($2, NULL_TREE); }
  1594.     | absdcl1 '(' parmlist  %prec '.'
  1595.         { $$ = build_nt (CALL_EXPR, $1, $3, NULL_TREE); }
  1596.     | absdcl1 '[' expr ']'  %prec '.'
  1597.         { $$ = build_nt (ARRAY_REF, $1, $3); }
  1598.     | absdcl1 '[' ']'  %prec '.'
  1599.         { $$ = build_nt (ARRAY_REF, $1, NULL_TREE); }
  1600.     | '(' parmlist  %prec '.'
  1601.         { $$ = build_nt (CALL_EXPR, NULL_TREE, $2, NULL_TREE); }
  1602.     | '[' expr ']'  %prec '.'
  1603.         { $$ = build_nt (ARRAY_REF, NULL_TREE, $2); }
  1604.     | '[' ']'  %prec '.'
  1605.         { $$ = build_nt (ARRAY_REF, NULL_TREE, NULL_TREE); }
  1606.     | attributes setattrs absdcl1
  1607.         { $$ = $3; }
  1608.     ;
  1609.  
  1610. /* at least one statement, the first of which parses without error.  */
  1611. /* stmts is used only after decls, so an invalid first statement
  1612.    is actually regarded as an invalid decl and part of the decls.  */
  1613.  
  1614. stmts:
  1615.     lineno_stmt_or_labels
  1616.         {
  1617.           if (pedantic && $1)
  1618.             pedwarn ("ANSI C forbids label at end of compound statement");
  1619.         }
  1620.     ;
  1621.  
  1622. lineno_stmt_or_labels:
  1623.       lineno_stmt_or_label
  1624.     | lineno_stmt_or_labels lineno_stmt_or_label
  1625.         { $$ = $2; }
  1626.     | lineno_stmt_or_labels errstmt
  1627.         { $$ = 0; }
  1628.     ;
  1629.  
  1630. xstmts:
  1631.     /* empty */
  1632.     | stmts
  1633.     ;
  1634.  
  1635. errstmt:  error ';'
  1636.     ;
  1637.  
  1638. pushlevel:  /* empty */
  1639.         { emit_line_note (input_filename, lineno);
  1640.           pushlevel (0);
  1641.           clear_last_expr ();
  1642.           push_momentary ();
  1643.           expand_start_bindings (0);
  1644. ifobjc
  1645.           if (objc_method_context)
  1646.             add_objc_decls ();
  1647. end ifobjc
  1648.         }
  1649.     ;
  1650.  
  1651. /* Read zero or more forward-declarations for labels
  1652.    that nested functions can jump to.  */
  1653. maybe_label_decls:
  1654.       /* empty */
  1655.     | label_decls
  1656.         { if (pedantic)
  1657.             pedwarn ("ANSI C forbids label declarations"); }
  1658.     ;
  1659.  
  1660. label_decls:
  1661.       label_decl
  1662.     | label_decls label_decl
  1663.     ;
  1664.  
  1665. label_decl:
  1666.       LABEL identifiers_or_typenames ';'
  1667.         { tree link;
  1668.           for (link = $2; link; link = TREE_CHAIN (link))
  1669.             {
  1670.               tree label = shadow_label (TREE_VALUE (link));
  1671.               C_DECLARED_LABEL_FLAG (label) = 1;
  1672.               declare_nonlocal_label (label);
  1673.             }
  1674.         }
  1675.     ;
  1676.  
  1677. /* This is the body of a function definition.
  1678.    It causes syntax errors to ignore to the next openbrace.  */
  1679. compstmt_or_error:
  1680.       compstmt
  1681.         {}
  1682.     | error compstmt
  1683.     ;
  1684.  
  1685. compstmt: '{' '}'
  1686.         { $$ = convert (void_type_node, integer_zero_node); }
  1687.     | '{' pushlevel maybe_label_decls decls xstmts '}'
  1688.         { emit_line_note (input_filename, lineno);
  1689.           expand_end_bindings (getdecls (), 1, 0);
  1690.           $$ = poplevel (1, 1, 0);
  1691.           if (yychar == CONSTANT || yychar == STRING)
  1692.             pop_momentary_nofree ();
  1693.           else
  1694.             pop_momentary (); }
  1695.     | '{' pushlevel maybe_label_decls error '}'
  1696.         { emit_line_note (input_filename, lineno);
  1697.           expand_end_bindings (getdecls (), kept_level_p (), 0);
  1698.           $$ = poplevel (kept_level_p (), 0, 0);
  1699.           if (yychar == CONSTANT || yychar == STRING)
  1700.             pop_momentary_nofree ();
  1701.           else
  1702.             pop_momentary (); }
  1703.     | '{' pushlevel maybe_label_decls stmts '}'
  1704.         { emit_line_note (input_filename, lineno);
  1705.           expand_end_bindings (getdecls (), kept_level_p (), 0);
  1706.           $$ = poplevel (kept_level_p (), 0, 0);
  1707.           if (yychar == CONSTANT || yychar == STRING)
  1708.             pop_momentary_nofree ();
  1709.           else
  1710.             pop_momentary (); }
  1711.     ;
  1712.  
  1713. /* Value is number of statements counted as of the closeparen.  */
  1714. simple_if:
  1715.       if_prefix lineno_labeled_stmt
  1716. /* Make sure expand_end_cond is run once
  1717.    for each call to expand_start_cond.
  1718.    Otherwise a crash is likely.  */
  1719.     | if_prefix error
  1720.     ;
  1721.  
  1722. if_prefix:
  1723.       IF '(' expr ')'
  1724.         { emit_line_note ($<filename>-1, $<lineno>0);
  1725.           expand_start_cond (truthvalue_conversion ($3), 0);
  1726.           $<itype>$ = stmt_count;
  1727.           if_stmt_file = $<filename>-1;
  1728.           if_stmt_line = $<lineno>0;
  1729.           position_after_white_space (); }
  1730.     ;
  1731.  
  1732. /* This is a subroutine of stmt.
  1733.    It is used twice, once for valid DO statements
  1734.    and once for catching errors in parsing the end test.  */
  1735. do_stmt_start:
  1736.       DO
  1737.         { stmt_count++;
  1738.           emit_line_note ($<filename>-1, $<lineno>0);
  1739.           /* See comment in `while' alternative, above.  */
  1740.           emit_nop ();
  1741.           expand_start_loop_continue_elsewhere (1);
  1742.           position_after_white_space (); }
  1743.       lineno_labeled_stmt WHILE
  1744.         { expand_loop_continue_here (); }
  1745.     ;
  1746.  
  1747. save_filename:
  1748.         { $$ = input_filename; }
  1749.     ;
  1750.  
  1751. save_lineno:
  1752.         { $$ = lineno; }
  1753.     ;
  1754.  
  1755. lineno_labeled_stmt:
  1756.       save_filename save_lineno stmt
  1757.         { }
  1758. /*    | save_filename save_lineno error
  1759.         { }
  1760. */
  1761.     | save_filename save_lineno label lineno_labeled_stmt
  1762.         { }
  1763.     ;
  1764.  
  1765. lineno_stmt_or_label:
  1766.       save_filename save_lineno stmt_or_label
  1767.         { $$ = $3; }
  1768.     ;
  1769.  
  1770. stmt_or_label:
  1771.       stmt
  1772.         { $$ = 0; }
  1773.     | label
  1774.         { $$ = 1; }
  1775.     ;
  1776.  
  1777. /* Parse a single real statement, not including any labels.  */
  1778. stmt:
  1779.       compstmt
  1780.         { stmt_count++; }
  1781.         | all_iter_stmt 
  1782.     | expr ';'
  1783.         { stmt_count++;
  1784.           emit_line_note ($<filename>-1, $<lineno>0);
  1785. /* It appears that this should not be done--that a non-lvalue array
  1786.    shouldn't get an error if the value isn't used.
  1787.    Section 3.2.2.1 says that an array lvalue gets converted to a pointer
  1788.    if it appears as a top-level expression,
  1789.    but says nothing about non-lvalue arrays.  */
  1790. #if 0
  1791.           /* Call default_conversion to get an error
  1792.              on referring to a register array if pedantic.  */
  1793.           if (TREE_CODE (TREE_TYPE ($1)) == ARRAY_TYPE
  1794.               || TREE_CODE (TREE_TYPE ($1)) == FUNCTION_TYPE)
  1795.             $1 = default_conversion ($1);
  1796. #endif
  1797.           iterator_expand ($1);
  1798.           clear_momentary (); }
  1799.     | simple_if ELSE
  1800.         { expand_start_else ();
  1801.           $<itype>1 = stmt_count;
  1802.           position_after_white_space (); }
  1803.       lineno_labeled_stmt
  1804.         { expand_end_cond ();
  1805.           if (extra_warnings && stmt_count == $<itype>1)
  1806.             warning ("empty body in an else-statement"); }
  1807.     | simple_if %prec IF
  1808.         { expand_end_cond ();
  1809.           /* This warning is here instead of in simple_if, because we
  1810.              do not want a warning if an empty if is followed by an
  1811.              else statement.  Increment stmt_count so we don't
  1812.              give a second error if this is a nested `if'.  */
  1813.           if (extra_warnings && stmt_count++ == $<itype>1)
  1814.             warning_with_file_and_line (if_stmt_file, if_stmt_line,
  1815.                         "empty body in an if-statement"); }
  1816. /* Make sure expand_end_cond is run once
  1817.    for each call to expand_start_cond.
  1818.    Otherwise a crash is likely.  */
  1819.     | simple_if ELSE error
  1820.         { expand_end_cond (); }
  1821.     | WHILE
  1822.         { stmt_count++;
  1823.           emit_line_note ($<filename>-1, $<lineno>0);
  1824.           /* The emit_nop used to come before emit_line_note,
  1825.              but that made the nop seem like part of the preceding line.
  1826.              And that was confusing when the preceding line was
  1827.              inside of an if statement and was not really executed.
  1828.              I think it ought to work to put the nop after the line number.
  1829.              We will see.  --rms, July 15, 1991.  */
  1830.           emit_nop (); }
  1831.       '(' expr ')'
  1832.         { /* Don't start the loop till we have succeeded
  1833.              in parsing the end test.  This is to make sure
  1834.              that we end every loop we start.  */
  1835.           expand_start_loop (1);
  1836.           emit_line_note (input_filename, lineno);
  1837.           expand_exit_loop_if_false (NULL_PTR,
  1838.                          truthvalue_conversion ($4));
  1839.           position_after_white_space (); }
  1840.       lineno_labeled_stmt
  1841.         { expand_end_loop (); }
  1842.     | do_stmt_start
  1843.       '(' expr ')' ';'
  1844.         { emit_line_note (input_filename, lineno);
  1845.           expand_exit_loop_if_false (NULL_PTR,
  1846.                          truthvalue_conversion ($3));
  1847.           expand_end_loop ();
  1848.           clear_momentary (); }
  1849. /* This rule is needed to make sure we end every loop we start.  */
  1850.     | do_stmt_start error
  1851.         { expand_end_loop ();
  1852.           clear_momentary (); }
  1853.     | FOR
  1854.       '(' xexpr ';'
  1855.         { stmt_count++;
  1856.           emit_line_note ($<filename>-1, $<lineno>0);
  1857.           /* See comment in `while' alternative, above.  */
  1858.           emit_nop ();
  1859.           if ($3) c_expand_expr_stmt ($3);
  1860.           /* Next step is to call expand_start_loop_continue_elsewhere,
  1861.              but wait till after we parse the entire for (...).
  1862.              Otherwise, invalid input might cause us to call that
  1863.              fn without calling expand_end_loop.  */
  1864.         }
  1865.       xexpr ';'
  1866.         /* Can't emit now; wait till after expand_start_loop...  */
  1867.         { $<lineno>7 = lineno;
  1868.           $<filename>$ = input_filename; }
  1869.       xexpr ')'
  1870.         { 
  1871.           /* Start the loop.  Doing this after parsing
  1872.              all the expressions ensures we will end the loop.  */
  1873.           expand_start_loop_continue_elsewhere (1);
  1874.           /* Emit the end-test, with a line number.  */
  1875.           emit_line_note ($<filename>8, $<lineno>7);
  1876.           if ($6)
  1877.             expand_exit_loop_if_false (NULL_PTR,
  1878.                            truthvalue_conversion ($6));
  1879.           /* Don't let the tree nodes for $9 be discarded by
  1880.              clear_momentary during the parsing of the next stmt.  */
  1881.           push_momentary ();
  1882.           $<lineno>7 = lineno;
  1883.           $<filename>8 = input_filename;
  1884.           position_after_white_space (); }
  1885.       lineno_labeled_stmt
  1886.         { /* Emit the increment expression, with a line number.  */
  1887.           emit_line_note ($<filename>8, $<lineno>7);
  1888.           expand_loop_continue_here ();
  1889.           if ($9)
  1890.             c_expand_expr_stmt ($9);
  1891.           if (yychar == CONSTANT || yychar == STRING)
  1892.             pop_momentary_nofree ();
  1893.           else
  1894.             pop_momentary ();
  1895.           expand_end_loop (); }
  1896.     | SWITCH '(' expr ')'
  1897.         { stmt_count++;
  1898.           emit_line_note ($<filename>-1, $<lineno>0);
  1899.           c_expand_start_case ($3);
  1900.           /* Don't let the tree nodes for $3 be discarded by
  1901.              clear_momentary during the parsing of the next stmt.  */
  1902.           push_momentary ();
  1903.           position_after_white_space (); }
  1904.       lineno_labeled_stmt
  1905.         { expand_end_case ($3);
  1906.           if (yychar == CONSTANT || yychar == STRING)
  1907.             pop_momentary_nofree ();
  1908.           else
  1909.             pop_momentary (); }
  1910.     | BREAK ';'
  1911.         { stmt_count++;
  1912.           emit_line_note ($<filename>-1, $<lineno>0);
  1913.           if ( ! expand_exit_something ())
  1914.             error ("break statement not within loop or switch"); }
  1915.     | CONTINUE ';'
  1916.         { stmt_count++;
  1917.           emit_line_note ($<filename>-1, $<lineno>0);
  1918.           if (! expand_continue_loop (NULL_PTR))
  1919.             error ("continue statement not within a loop"); }
  1920.     | RETURN ';'
  1921.         { stmt_count++;
  1922.           emit_line_note ($<filename>-1, $<lineno>0);
  1923.           c_expand_return (NULL_TREE); }
  1924.     | RETURN expr ';'
  1925.         { stmt_count++;
  1926.           emit_line_note ($<filename>-1, $<lineno>0);
  1927.           c_expand_return ($2); }
  1928.     | ASM_KEYWORD maybe_type_qual '(' expr ')' ';'
  1929.         { stmt_count++;
  1930.           emit_line_note ($<filename>-1, $<lineno>0);
  1931.           STRIP_NOPS ($4);
  1932.           if ((TREE_CODE ($4) == ADDR_EXPR
  1933.                && TREE_CODE (TREE_OPERAND ($4, 0)) == STRING_CST)
  1934.               || TREE_CODE ($4) == STRING_CST)
  1935.             expand_asm ($4);
  1936.           else
  1937.             error ("argument of `asm' is not a constant string"); }
  1938.     /* This is the case with just output operands.  */
  1939.     | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ')' ';'
  1940.         { stmt_count++;
  1941.           emit_line_note ($<filename>-1, $<lineno>0);
  1942.           c_expand_asm_operands ($4, $6, NULL_TREE, NULL_TREE,
  1943.                      $2 == ridpointers[(int)RID_VOLATILE],
  1944.                      input_filename, lineno); }
  1945.     /* This is the case with input operands as well.  */
  1946.     | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ':' asm_operands ')' ';'
  1947.         { stmt_count++;
  1948.           emit_line_note ($<filename>-1, $<lineno>0);
  1949.           c_expand_asm_operands ($4, $6, $8, NULL_TREE,
  1950.                      $2 == ridpointers[(int)RID_VOLATILE],
  1951.                      input_filename, lineno); }
  1952.     /* This is the case with clobbered registers as well.  */
  1953.     | ASM_KEYWORD maybe_type_qual '(' expr ':' asm_operands ':'
  1954.         asm_operands ':' asm_clobbers ')' ';'
  1955.         { stmt_count++;
  1956.           emit_line_note ($<filename>-1, $<lineno>0);
  1957.           c_expand_asm_operands ($4, $6, $8, $10,
  1958.                      $2 == ridpointers[(int)RID_VOLATILE],
  1959.                      input_filename, lineno); }
  1960.     | GOTO identifier ';'
  1961.         { tree decl;
  1962.           stmt_count++;
  1963.           emit_line_note ($<filename>-1, $<lineno>0);
  1964.           decl = lookup_label ($2);
  1965.           if (decl != 0)
  1966.             {
  1967.               TREE_USED (decl) = 1;
  1968.               expand_goto (decl);
  1969.             }
  1970.         }
  1971.     | GOTO '*' expr ';'
  1972.         { stmt_count++;
  1973.           emit_line_note ($<filename>-1, $<lineno>0);
  1974.           expand_computed_goto (convert (ptr_type_node, $3)); }
  1975.     | ';'
  1976.     ;
  1977.  
  1978. all_iter_stmt:
  1979.       all_iter_stmt_simple
  1980. /*    | all_iter_stmt_with_decl */
  1981.     ;
  1982.  
  1983. all_iter_stmt_simple:
  1984.       FOR '(' primary ')' 
  1985.       {
  1986.         /* The value returned by this action is  */
  1987.         /*      1 if everything is OK */ 
  1988.         /*      0 in case of error or already bound iterator */
  1989.  
  1990.         $<itype>$ = 0;
  1991.         if (TREE_CODE ($3) != VAR_DECL)
  1992.           error ("invalid `for (ITERATOR)' syntax");
  1993.         else if (! ITERATOR_P ($3))
  1994.           error ("`%s' is not an iterator",
  1995.              IDENTIFIER_POINTER (DECL_NAME ($3)));
  1996.         else if (ITERATOR_BOUND_P ($3))
  1997.           error ("`for (%s)' inside expansion of same iterator",
  1998.              IDENTIFIER_POINTER (DECL_NAME ($3)));
  1999.         else
  2000.           {
  2001.         $<itype>$ = 1;
  2002.         iterator_for_loop_start ($3);
  2003.           }
  2004.       }
  2005.       lineno_labeled_stmt
  2006.       {
  2007.         if ($<itype>5)
  2008.           iterator_for_loop_end ($3);
  2009.       }
  2010.  
  2011. /*  This really should allow any kind of declaration,
  2012.     for generality.  Fix it before turning it back on.
  2013.  
  2014. all_iter_stmt_with_decl:
  2015.       FOR '(' ITERATOR pushlevel setspecs iterator_spec ')' 
  2016.       {
  2017. */        /* The value returned by this action is  */
  2018.         /*      1 if everything is OK */ 
  2019.         /*      0 in case of error or already bound iterator */
  2020. /*
  2021.         iterator_for_loop_start ($6);
  2022.       }
  2023.       lineno_labeled_stmt
  2024.       {
  2025.         iterator_for_loop_end ($6);
  2026.         emit_line_note (input_filename, lineno);
  2027.         expand_end_bindings (getdecls (), 1, 0);
  2028.         $<ttype>$ = poplevel (1, 1, 0);
  2029.         if (yychar == CONSTANT || yychar == STRING)
  2030.           pop_momentary_nofree ();
  2031.         else
  2032.           pop_momentary ();        
  2033.       }
  2034. */
  2035.  
  2036. /* Any kind of label, including jump labels and case labels.
  2037.    ANSI C accepts labels only before statements, but we allow them
  2038.    also at the end of a compound statement.  */
  2039.  
  2040. label:      CASE expr_no_commas ':'
  2041.         { register tree value = check_case_value ($2);
  2042.           register tree label
  2043.             = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
  2044.  
  2045.           stmt_count++;
  2046.  
  2047.           if (value != error_mark_node)
  2048.             {
  2049.               tree duplicate;
  2050.               int success = pushcase (value, convert_and_check,
  2051.                           label, &duplicate);
  2052.               if (success == 1)
  2053.             error ("case label not within a switch statement");
  2054.               else if (success == 2)
  2055.             {
  2056.               error ("duplicate case value");
  2057.               error_with_decl (duplicate, "this is the first entry for that value");
  2058.             }
  2059.               else if (success == 3)
  2060.             warning ("case value out of range");
  2061.               else if (success == 5)
  2062.             error ("case label within scope of cleanup or variable array");
  2063.             }
  2064.           position_after_white_space (); }
  2065.     | CASE expr_no_commas ELLIPSIS expr_no_commas ':'
  2066.         { register tree value1 = check_case_value ($2);
  2067.           register tree value2 = check_case_value ($4);
  2068.           register tree label
  2069.             = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
  2070.  
  2071.           stmt_count++;
  2072.  
  2073.           if (value1 != error_mark_node && value2 != error_mark_node)
  2074.             {
  2075.               tree duplicate;
  2076.               int success = pushcase_range (value1, value2,
  2077.                             convert_and_check, label,
  2078.                             &duplicate);
  2079.               if (success == 1)
  2080.             error ("case label not within a switch statement");
  2081.               else if (success == 2)
  2082.             {
  2083.               error ("duplicate case value");
  2084.               error_with_decl (duplicate, "this is the first entry for that value");
  2085.             }
  2086.               else if (success == 3)
  2087.             warning ("case value out of range");
  2088.               else if (success == 4)
  2089.             warning ("empty case range");
  2090.               else if (success == 5)
  2091.             error ("case label within scope of cleanup or variable array");
  2092.             }
  2093.           position_after_white_space (); }
  2094.     | DEFAULT ':'
  2095.         {
  2096.           tree duplicate;
  2097.           register tree label
  2098.             = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
  2099.           int success = pushcase (NULL_TREE, 0, label, &duplicate);
  2100.           stmt_count++;
  2101.           if (success == 1)
  2102.             error ("default label not within a switch statement");
  2103.           else if (success == 2)
  2104.             {
  2105.               error ("multiple default labels in one switch");
  2106.               error_with_decl (duplicate, "this is the first default label");
  2107.             }
  2108.           position_after_white_space (); }
  2109.     | identifier ':'
  2110.         { tree label = define_label (input_filename, lineno, $1);
  2111.           stmt_count++;
  2112.           emit_nop ();
  2113.           if (label)
  2114.             expand_label (label);
  2115.           position_after_white_space (); }
  2116.     ;
  2117.  
  2118. /* Either a type-qualifier or nothing.  First thing in an `asm' statement.  */
  2119.  
  2120. maybe_type_qual:
  2121.     /* empty */
  2122.         { emit_line_note (input_filename, lineno);
  2123.           $$ = NULL_TREE; }
  2124.     | TYPE_QUAL
  2125.         { emit_line_note (input_filename, lineno); }
  2126.     ;
  2127.  
  2128. xexpr:
  2129.     /* empty */
  2130.         { $$ = NULL_TREE; }
  2131.     | expr
  2132.     ;
  2133.  
  2134. /* These are the operands other than the first string and colon
  2135.    in  asm ("addextend %2,%1": "=dm" (x), "0" (y), "g" (*x))  */
  2136. asm_operands: /* empty */
  2137.         { $$ = NULL_TREE; }
  2138.     | nonnull_asm_operands
  2139.     ;
  2140.  
  2141. nonnull_asm_operands:
  2142.       asm_operand
  2143.     | nonnull_asm_operands ',' asm_operand
  2144.         { $$ = chainon ($1, $3); }
  2145.     ;
  2146.  
  2147. asm_operand:
  2148.       STRING '(' expr ')'
  2149.         { $$ = build_tree_list ($1, $3); }
  2150.     ;
  2151.  
  2152. asm_clobbers:
  2153.       string
  2154.         { $$ = tree_cons (NULL_TREE, combine_strings ($1), NULL_TREE); }
  2155.     | asm_clobbers ',' string
  2156.         { $$ = tree_cons (NULL_TREE, combine_strings ($3), $1); }
  2157.     ;
  2158.  
  2159. /* This is what appears inside the parens in a function declarator.
  2160.    Its value is a list of ..._TYPE nodes.  */
  2161. parmlist:
  2162.         { pushlevel (0);
  2163.           clear_parm_order ();
  2164.           declare_parm_level (0); }
  2165.       parmlist_1
  2166.         { $$ = $2;
  2167.           parmlist_tags_warning ();
  2168.           poplevel (0, 0, 0); }
  2169.     ;
  2170.  
  2171. parmlist_1:
  2172.       parmlist_2 ')'
  2173.     | parms ';'
  2174.         { tree parm;
  2175.           if (pedantic)
  2176.             pedwarn ("ANSI C forbids forward parameter declarations");
  2177.           /* Mark the forward decls as such.  */
  2178.           for (parm = getdecls (); parm; parm = TREE_CHAIN (parm))
  2179.             TREE_ASM_WRITTEN (parm) = 1;
  2180.           clear_parm_order (); }
  2181.       parmlist_1
  2182.         { $$ = $4; }
  2183.     | error ')'
  2184.         { $$ = tree_cons (NULL_TREE, NULL_TREE, NULL_TREE); }
  2185.     ;
  2186.  
  2187. /* This is what appears inside the parens in a function declarator.
  2188.    Is value is represented in the format that grokdeclarator expects.  */
  2189. parmlist_2:  /* empty */
  2190.         { $$ = get_parm_info (0); }
  2191.     | ELLIPSIS
  2192.         { $$ = get_parm_info (0);
  2193.           /* Gcc used to allow this as an extension.  However, it does
  2194.              not work for all targets, and thus has been disabled.
  2195.              Also, since func (...) and func () are indistinguishable,
  2196.              it caused problems with the code in expand_builtin which
  2197.              tries to verify that BUILT_IN_NEXT_ARG is being used
  2198.              correctly.  */
  2199.           error ("ANSI C requires a named argument before `...'");
  2200.         }
  2201.     | parms
  2202.         { $$ = get_parm_info (1); }
  2203.     | parms ',' ELLIPSIS
  2204.         { $$ = get_parm_info (0); }
  2205.     ;
  2206.  
  2207. parms:
  2208.     parm
  2209.         { push_parm_decl ($1); }
  2210.     | parms ',' parm
  2211.         { push_parm_decl ($3); }
  2212.     ;
  2213.  
  2214. /* A single parameter declaration or parameter type name,
  2215.    as found in a parmlist.  */
  2216. parm:
  2217.       typed_declspecs setspecs parm_declarator maybe_attribute
  2218.         { $$ = build_tree_list (build_tree_list (current_declspecs,
  2219.                              $3),
  2220.                     build_tree_list (prefix_attributes,
  2221.                              $4));
  2222.           current_declspecs = TREE_VALUE (declspec_stack);
  2223.           prefix_attributes = TREE_PURPOSE (declspec_stack);
  2224.           declspec_stack = TREE_CHAIN (declspec_stack);
  2225.           resume_momentary ($2); }
  2226.     | typed_declspecs setspecs notype_declarator maybe_attribute
  2227.         { $$ = build_tree_list (build_tree_list (current_declspecs,
  2228.                              $3),
  2229.                     build_tree_list (prefix_attributes,
  2230.                              $4)); 
  2231.           current_declspecs = TREE_VALUE (declspec_stack);
  2232.           prefix_attributes = TREE_PURPOSE (declspec_stack);
  2233.           declspec_stack = TREE_CHAIN (declspec_stack);
  2234.           resume_momentary ($2); }
  2235.     | typed_declspecs setspecs absdcl maybe_attribute
  2236.         { $$ = build_tree_list (build_tree_list (current_declspecs,
  2237.                              $3),
  2238.                     build_tree_list (prefix_attributes,
  2239.                              $4));
  2240.           current_declspecs = TREE_VALUE (declspec_stack);
  2241.           prefix_attributes = TREE_PURPOSE (declspec_stack);
  2242.           declspec_stack = TREE_CHAIN (declspec_stack);
  2243.           resume_momentary ($2); }
  2244.     | declmods setspecs notype_declarator maybe_attribute
  2245.         { $$ = build_tree_list (build_tree_list (current_declspecs,
  2246.                              $3),
  2247.                     build_tree_list (prefix_attributes,
  2248.                              $4));
  2249.           current_declspecs = TREE_VALUE (declspec_stack);
  2250.           prefix_attributes = TREE_PURPOSE (declspec_stack);
  2251.           declspec_stack = TREE_CHAIN (declspec_stack);
  2252.           resume_momentary ($2);  }
  2253.  
  2254.     | declmods setspecs absdcl maybe_attribute
  2255.         { $$ = build_tree_list (build_tree_list (current_declspecs,
  2256.                              $3),
  2257.                     build_tree_list (prefix_attributes,
  2258.                              $4));
  2259.           current_declspecs = TREE_VALUE (declspec_stack);
  2260.           prefix_attributes = TREE_PURPOSE (declspec_stack);
  2261.           declspec_stack = TREE_CHAIN (declspec_stack);
  2262.           resume_momentary ($2);  }
  2263.     ;
  2264.  
  2265. /* This is used in a function definition
  2266.    where either a parmlist or an identifier list is ok.
  2267.    Its value is a list of ..._TYPE nodes or a list of identifiers.  */
  2268. parmlist_or_identifiers:
  2269.         { pushlevel (0);
  2270.           clear_parm_order ();
  2271.           declare_parm_level (1); }
  2272.       parmlist_or_identifiers_1
  2273.         { $$ = $2;
  2274.           parmlist_tags_warning ();
  2275.           poplevel (0, 0, 0); }
  2276.     ;
  2277.  
  2278. parmlist_or_identifiers_1:
  2279.       parmlist_1
  2280.     | identifiers ')'
  2281.         { tree t;
  2282.           for (t = $1; t; t = TREE_CHAIN (t))
  2283.             if (TREE_VALUE (t) == NULL_TREE)
  2284.               error ("`...' in old-style identifier list");
  2285.           $$ = tree_cons (NULL_TREE, NULL_TREE, $1); }
  2286.     ;
  2287.  
  2288. /* A nonempty list of identifiers.  */
  2289. identifiers:
  2290.     IDENTIFIER
  2291.         { $$ = build_tree_list (NULL_TREE, $1); }
  2292.     | identifiers ',' IDENTIFIER
  2293.         { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
  2294.     ;
  2295.  
  2296. /* A nonempty list of identifiers, including typenames.  */
  2297. identifiers_or_typenames:
  2298.     identifier
  2299.         { $$ = build_tree_list (NULL_TREE, $1); }
  2300.     | identifiers_or_typenames ',' identifier
  2301.         { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
  2302.     ;
  2303.  
  2304. ifobjc
  2305. /* Objective-C productions.  */
  2306.  
  2307. objcdef:
  2308.       classdef
  2309.     | classdecl
  2310.     | aliasdecl
  2311.     | protocoldef
  2312.     | methoddef
  2313.     | END
  2314.         {
  2315.           if (objc_implementation_context)
  2316.                     {
  2317.               finish_class (objc_implementation_context);
  2318.               objc_ivar_chain = NULL_TREE;
  2319.               objc_implementation_context = NULL_TREE;
  2320.             }
  2321.           else
  2322.             warning ("`@end' must appear in an implementation context");
  2323.         }
  2324.     ;
  2325.  
  2326. /* A nonempty list of identifiers.  */
  2327. identifier_list:
  2328.     identifier
  2329.         { $$ = build_tree_list (NULL_TREE, $1); }
  2330.     | identifier_list ',' identifier
  2331.         { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
  2332.     ;
  2333.  
  2334. classdecl:
  2335.       CLASS identifier_list ';'
  2336.         {
  2337.           objc_declare_class ($2);
  2338.         }
  2339.  
  2340. aliasdecl:
  2341.       ALIAS identifier identifier ';'
  2342.         {
  2343.           objc_declare_alias ($2, $3);
  2344.         }
  2345.  
  2346. classdef:
  2347.       INTERFACE identifier protocolrefs '{'
  2348.         {
  2349.           objc_interface_context = objc_ivar_context
  2350.             = start_class (CLASS_INTERFACE_TYPE, $2, NULL_TREE, $3);
  2351.                   objc_public_flag = 0;
  2352.         }
  2353.       ivar_decl_list '}'
  2354.         {
  2355.                   continue_class (objc_interface_context);
  2356.         }
  2357.       methodprotolist
  2358.       END
  2359.         {
  2360.           finish_class (objc_interface_context);
  2361.           objc_interface_context = NULL_TREE;
  2362.         }
  2363.  
  2364.     | INTERFACE identifier protocolrefs
  2365.         {
  2366.           objc_interface_context
  2367.             = start_class (CLASS_INTERFACE_TYPE, $2, NULL_TREE, $3);
  2368.                   continue_class (objc_interface_context);
  2369.         }
  2370.       methodprotolist
  2371.       END
  2372.         {
  2373.           finish_class (objc_interface_context);
  2374.           objc_interface_context = NULL_TREE;
  2375.         }
  2376.  
  2377.     | INTERFACE identifier ':' identifier protocolrefs '{'
  2378.         {
  2379.           objc_interface_context = objc_ivar_context
  2380.             = start_class (CLASS_INTERFACE_TYPE, $2, $4, $5);
  2381.                   objc_public_flag = 0;
  2382.         }
  2383.       ivar_decl_list '}'
  2384.         {
  2385.                   continue_class (objc_interface_context);
  2386.         }
  2387.       methodprotolist
  2388.       END
  2389.         {
  2390.           finish_class (objc_interface_context);
  2391.           objc_interface_context = NULL_TREE;
  2392.         }
  2393.  
  2394.     | INTERFACE identifier ':' identifier protocolrefs
  2395.         {
  2396.           objc_interface_context
  2397.             = start_class (CLASS_INTERFACE_TYPE, $2, $4, $5);
  2398.                   continue_class (objc_interface_context);
  2399.         }
  2400.       methodprotolist
  2401.       END
  2402.         {
  2403.           finish_class (objc_interface_context);
  2404.           objc_interface_context = NULL_TREE;
  2405.         }
  2406.  
  2407.     | IMPLEMENTATION identifier '{'
  2408.         {
  2409.           objc_implementation_context = objc_ivar_context
  2410.             = start_class (CLASS_IMPLEMENTATION_TYPE, $2, NULL_TREE, NULL_TREE);
  2411.                   objc_public_flag = 0;
  2412.         }
  2413.       ivar_decl_list '}'
  2414.         {
  2415.                   objc_ivar_chain
  2416.             = continue_class (objc_implementation_context);
  2417.         }
  2418.  
  2419.     | IMPLEMENTATION identifier
  2420.         {
  2421.           objc_implementation_context
  2422.             = start_class (CLASS_IMPLEMENTATION_TYPE, $2, NULL_TREE, NULL_TREE);
  2423.                   objc_ivar_chain
  2424.             = continue_class (objc_implementation_context);
  2425.         }
  2426.  
  2427.     | IMPLEMENTATION identifier ':' identifier '{'
  2428.         {
  2429.           objc_implementation_context = objc_ivar_context
  2430.             = start_class (CLASS_IMPLEMENTATION_TYPE, $2, $4, NULL_TREE);
  2431.                   objc_public_flag = 0;
  2432.         }
  2433.       ivar_decl_list '}'
  2434.         {
  2435.                   objc_ivar_chain
  2436.             = continue_class (objc_implementation_context);
  2437.         }
  2438.  
  2439.     | IMPLEMENTATION identifier ':' identifier
  2440.         {
  2441.           objc_implementation_context
  2442.             = start_class (CLASS_IMPLEMENTATION_TYPE, $2, $4, NULL_TREE);
  2443.                   objc_ivar_chain
  2444.             = continue_class (objc_implementation_context);
  2445.         }
  2446.  
  2447.     | INTERFACE identifier '(' identifier ')' protocolrefs
  2448.         {
  2449.           objc_interface_context
  2450.             = start_class (CATEGORY_INTERFACE_TYPE, $2, $4, $6);
  2451.                   continue_class (objc_interface_context);
  2452.         }
  2453.       methodprotolist
  2454.       END
  2455.         {
  2456.           finish_class (objc_interface_context);
  2457.           objc_interface_context = NULL_TREE;
  2458.         }
  2459.  
  2460.     | IMPLEMENTATION identifier '(' identifier ')'
  2461.         {
  2462.           objc_implementation_context
  2463.             = start_class (CATEGORY_IMPLEMENTATION_TYPE, $2, $4, NULL_TREE);
  2464.                   objc_ivar_chain
  2465.             = continue_class (objc_implementation_context);
  2466.         }
  2467.     ;
  2468.  
  2469. protocoldef:
  2470.       PROTOCOL identifier protocolrefs
  2471.         {
  2472.           // remember_protocol_qualifiers ();
  2473.           objc_interface_context
  2474.             = start_protocol(PROTOCOL_INTERFACE_TYPE, $2, $3);
  2475.         }
  2476.       methodprotolist END
  2477.         {
  2478.           // forget_protocol_qualifiers();
  2479.           finish_protocol(objc_interface_context);
  2480.           objc_interface_context = NULL_TREE;
  2481.         }
  2482.     | PROTOCOL identifier_list ';'
  2483.         {
  2484.           objc_declare_protocols ($2);
  2485.         }
  2486.     ;
  2487.  
  2488. protocolrefs:
  2489.       /* empty */
  2490.         {
  2491.           $$ = NULL_TREE;
  2492.         }
  2493.     | ARITHCOMPARE identifier_list ARITHCOMPARE
  2494.         {
  2495.           if ($1 == LT_EXPR && $3 == GT_EXPR)
  2496.             $$ = $2;
  2497.           else
  2498.             YYERROR1;
  2499.         }
  2500.     ;
  2501.  
  2502. ivar_decl_list:
  2503.           ivar_decl_list visibility_spec ivar_decls
  2504.         | ivar_decls
  2505.         ;
  2506.  
  2507. visibility_spec:
  2508.       PRIVATE { objc_public_flag = 2; }
  2509.     | PROTECTED { objc_public_flag = 0; }
  2510.     | PUBLIC { objc_public_flag = 1; }
  2511.     ;
  2512.  
  2513. ivar_decls:
  2514.           /* empty */
  2515.         {
  2516.                   $$ = NULL_TREE;
  2517.                 }
  2518.     | ivar_decls ivar_decl ';'
  2519.     | ivar_decls ';'
  2520.         {
  2521.                   if (pedantic)
  2522.             pedwarn ("extra semicolon in struct or union specified");
  2523.                 }
  2524.     ;
  2525.  
  2526.  
  2527. /* There is a shift-reduce conflict here, because `components' may
  2528.    start with a `typename'.  It happens that shifting (the default resolution)
  2529.    does the right thing, because it treats the `typename' as part of
  2530.    a `typed_typespecs'.
  2531.  
  2532.    It is possible that this same technique would allow the distinction
  2533.    between `notype_initdecls' and `initdecls' to be eliminated.
  2534.    But I am being cautious and not trying it.  */
  2535.  
  2536. ivar_decl:
  2537.     typed_typespecs setspecs ivars
  2538.             { $$ = $3;
  2539.           current_declspecs = TREE_VALUE (declspec_stack);
  2540.           prefix_attributes = TREE_PURPOSE (declspec_stack);
  2541.           declspec_stack = TREE_CHAIN (declspec_stack);
  2542.           resume_momentary ($2); }
  2543.     | nonempty_type_quals setspecs ivars
  2544.         { $$ = $3;
  2545.           current_declspecs = TREE_VALUE (declspec_stack);
  2546.           prefix_attributes = TREE_PURPOSE (declspec_stack);
  2547.           declspec_stack = TREE_CHAIN (declspec_stack);
  2548.           resume_momentary ($2); }
  2549.     | error
  2550.         { $$ = NULL_TREE; }
  2551.     ;
  2552.  
  2553. ivars:
  2554.       /* empty */
  2555.         { $$ = NULL_TREE; }
  2556.     | ivar_declarator
  2557.     | ivars ',' ivar_declarator
  2558.     ;
  2559.  
  2560. ivar_declarator:
  2561.       declarator
  2562.         {
  2563.           $$ = add_instance_variable (objc_ivar_context,
  2564.                           objc_public_flag,
  2565.                           $1, current_declspecs,
  2566.                           NULL_TREE);
  2567.                 }
  2568.     | declarator ':' expr_no_commas
  2569.         {
  2570.           $$ = add_instance_variable (objc_ivar_context,
  2571.                           objc_public_flag,
  2572.                           $1, current_declspecs, $3);
  2573.                 }
  2574.     | ':' expr_no_commas
  2575.         {
  2576.           $$ = add_instance_variable (objc_ivar_context,
  2577.                           objc_public_flag,
  2578.                           NULL_TREE,
  2579.                           current_declspecs, $2);
  2580.                 }
  2581.     ;
  2582.  
  2583. methoddef:
  2584.       '+'
  2585.         {
  2586.           remember_protocol_qualifiers ();
  2587.           if (objc_implementation_context)
  2588.             objc_inherit_code = CLASS_METHOD_DECL;
  2589.                   else
  2590.             fatal ("method definition not in class context");
  2591.         }
  2592.       methoddecl
  2593.         {
  2594.           forget_protocol_qualifiers ();
  2595.           add_class_method (objc_implementation_context, $3);
  2596.           start_method_def ($3);
  2597.           objc_method_context = $3;
  2598.         }
  2599.       optarglist
  2600.         {
  2601.           continue_method_def ();
  2602.         }
  2603.       compstmt_or_error
  2604.         {
  2605.           finish_method_def ();
  2606.           objc_method_context = NULL_TREE;
  2607.         }
  2608.  
  2609.     | '-'
  2610.         {
  2611.           remember_protocol_qualifiers ();
  2612.           if (objc_implementation_context)
  2613.             objc_inherit_code = INSTANCE_METHOD_DECL;
  2614.                   else
  2615.             fatal ("method definition not in class context");
  2616.         }
  2617.       methoddecl
  2618.         {
  2619.           forget_protocol_qualifiers ();
  2620.           add_instance_method (objc_implementation_context, $3);
  2621.           start_method_def ($3);
  2622.           objc_method_context = $3;
  2623.         }
  2624.       optarglist
  2625.         {
  2626.           continue_method_def ();
  2627.         }
  2628.       compstmt_or_error
  2629.         {
  2630.           finish_method_def ();
  2631.           objc_method_context = NULL_TREE;
  2632.         }
  2633.     ;
  2634.  
  2635. /* the reason for the strange actions in this rule
  2636.  is so that notype_initdecls when reached via datadef
  2637.  can find a valid list of type and sc specs in $0. */
  2638.  
  2639. methodprotolist:
  2640.       /* empty  */
  2641.     | {$<ttype>$ = NULL_TREE; } methodprotolist2
  2642.     ;
  2643.  
  2644. methodprotolist2:         /* eliminates a shift/reduce conflict */
  2645.        methodproto
  2646.     |  datadef
  2647.     | methodprotolist2 methodproto
  2648.     | methodprotolist2 {$<ttype>$ = NULL_TREE; } datadef
  2649.     ;
  2650.  
  2651. semi_or_error:
  2652.       ';'
  2653.     | error
  2654.     ;
  2655.  
  2656. methodproto:
  2657.       '+'
  2658.         {
  2659.           remember_protocol_qualifiers ();
  2660.           objc_inherit_code = CLASS_METHOD_DECL;
  2661.         }
  2662.       methoddecl
  2663.         {
  2664.           forget_protocol_qualifiers ();
  2665.           add_class_method (objc_interface_context, $3);
  2666.         }
  2667.       semi_or_error
  2668.  
  2669.     | '-'
  2670.         {
  2671.           remember_protocol_qualifiers ();
  2672.           objc_inherit_code = INSTANCE_METHOD_DECL;
  2673.         }
  2674.       methoddecl
  2675.         {
  2676.           forget_protocol_qualifiers ();
  2677.           add_instance_method (objc_interface_context, $3);
  2678.         }
  2679.       semi_or_error
  2680.     ;
  2681.  
  2682. objc_return_type_mods:
  2683.     SCSPEC
  2684.         { $$ = tree_cons (NULL_TREE, $1, NULL_TREE); }
  2685.     | objc_return_type_mods SCSPEC
  2686.         { $$ = tree_cons (NULL_TREE, $2, $1); }
  2687.     ;
  2688.  
  2689. methoddecl:
  2690.       '(' typename ')' unaryselector
  2691.         {
  2692.           $$ = build_method_decl (objc_inherit_code, $2, $4, NULL_TREE, NULL_TREE);
  2693.         }
  2694.  
  2695.     | '(' objc_return_type_mods typename ')' unaryselector
  2696.         {
  2697.           $$ = build_method_decl (objc_inherit_code, $3, $5, NULL_TREE, $2);
  2698.         }
  2699.  
  2700.     | unaryselector
  2701.         {
  2702.           $$ = build_method_decl (objc_inherit_code, NULL_TREE, $1, NULL_TREE, NULL_TREE);
  2703.         }
  2704.  
  2705.     | '(' typename ')' keywordselector optparmlist
  2706.         {
  2707.           $$ = build_method_decl (objc_inherit_code, $2, $4, $5, NULL_TREE);
  2708.         }
  2709.  
  2710.     | '(' objc_return_type_mods typename ')' keywordselector optparmlist
  2711.         {
  2712.           $$ = build_method_decl (objc_inherit_code, $3, $5, $6, $2);
  2713.         }
  2714.  
  2715.     | keywordselector optparmlist
  2716.         {
  2717.           $$ = build_method_decl (objc_inherit_code, NULL_TREE, $1, $2, NULL_TREE);
  2718.         }
  2719.     ;
  2720.  
  2721. /* "optarglist" assumes that start_method_def has already been called...
  2722.    if it is not, the "xdecls" will not be placed in the proper scope */
  2723.  
  2724. optarglist:
  2725.       /* empty */
  2726.     | ';' myxdecls
  2727.     ;
  2728.  
  2729. /* to get around the following situation: "int foo (int a) int b; {}" that
  2730.    is synthesized when parsing "- a:a b:b; id c; id d; { ... }" */
  2731.  
  2732. myxdecls:
  2733.       /* empty */
  2734.     | mydecls
  2735.     ;
  2736.  
  2737. mydecls:
  2738.     mydecl
  2739.     | errstmt
  2740.     | mydecls mydecl
  2741.     | mydecl errstmt
  2742.     ;
  2743.  
  2744. mydecl:
  2745.     typed_declspecs setspecs myparms ';'
  2746.         { current_declspecs = TREE_VALUE (declspec_stack);
  2747.           prefix_attributes = TREE_PURPOSE (declspec_stack);
  2748.           declspec_stack = TREE_CHAIN (declspec_stack);
  2749.           resume_momentary ($2); }
  2750.     | typed_declspecs ';'
  2751.         { shadow_tag ($1); }
  2752.     | declmods ';'
  2753.         { pedwarn ("empty declaration"); }
  2754.     ;
  2755.  
  2756. myparms:
  2757.     myparm
  2758.         { push_parm_decl ($1); }
  2759.     | myparms ',' myparm
  2760.         { push_parm_decl ($3); }
  2761.     ;
  2762.  
  2763. /* A single parameter declaration or parameter type name,
  2764.    as found in a parmlist. DOES NOT ALLOW AN INITIALIZER OR ASMSPEC */
  2765.  
  2766. myparm:
  2767.       parm_declarator maybe_attribute
  2768.         { $$ = build_tree_list (build_tree_list (current_declspecs,
  2769.                              $1),
  2770.                     build_tree_list (prefix_attributes,
  2771.                              $2)); }
  2772.     | notype_declarator maybe_attribute
  2773.         { $$ = build_tree_list (build_tree_list (current_declspecs,
  2774.                              $1),
  2775.                     build_tree_list (prefix_attributes,
  2776.                              $2)); }
  2777.     | absdcl maybe_attribute
  2778.         { $$ = build_tree_list (build_tree_list (current_declspecs,
  2779.                              $1),
  2780.                     build_tree_list (prefix_attributes,
  2781.                              $2)); }
  2782.     ;
  2783.  
  2784. optparmlist:
  2785.       /* empty */
  2786.         {
  2787.               $$ = NULL_TREE;
  2788.         }
  2789.     | ',' ELLIPSIS
  2790.         {
  2791.           /* oh what a kludge! */
  2792.           $$ = (tree)1;
  2793.         }
  2794.     | ','
  2795.         {
  2796.           pushlevel (0);
  2797.         }
  2798.       parmlist_2
  2799.         {
  2800.             /* returns a tree list node generated by get_parm_info */
  2801.           $$ = $3;
  2802.           poplevel (0, 0, 0);
  2803.         }
  2804.     ;
  2805.  
  2806. unaryselector:
  2807.       selector
  2808.     ;
  2809.  
  2810. keywordselector:
  2811.       keyworddecl
  2812.  
  2813.     | keywordselector keyworddecl
  2814.         {
  2815.           $$ = chainon ($1, $2);
  2816.         }
  2817.     ;
  2818.  
  2819. selector:
  2820.       IDENTIFIER
  2821.         | TYPENAME
  2822.       | OBJECTNAME
  2823.     | reservedwords
  2824.     ;
  2825.  
  2826. reservedwords:
  2827.       ENUM { $$ = get_identifier (token_buffer); }
  2828.     | STRUCT { $$ = get_identifier (token_buffer); }
  2829.     | UNION { $$ = get_identifier (token_buffer); }
  2830.     | IF { $$ = get_identifier (token_buffer); }
  2831.     | ELSE { $$ = get_identifier (token_buffer); }
  2832.     | WHILE { $$ = get_identifier (token_buffer); }
  2833.     | DO { $$ = get_identifier (token_buffer); }
  2834.     | FOR { $$ = get_identifier (token_buffer); }
  2835.     | SWITCH { $$ = get_identifier (token_buffer); }
  2836.     | CASE { $$ = get_identifier (token_buffer); }
  2837.     | DEFAULT { $$ = get_identifier (token_buffer); }
  2838.     | BREAK { $$ = get_identifier (token_buffer); }
  2839.     | CONTINUE { $$ = get_identifier (token_buffer); }
  2840.     | RETURN  { $$ = get_identifier (token_buffer); }
  2841.     | GOTO { $$ = get_identifier (token_buffer); }
  2842.     | ASM_KEYWORD { $$ = get_identifier (token_buffer); }
  2843.         | SIZEOF { $$ = get_identifier (token_buffer); }
  2844.     | TYPEOF { $$ = get_identifier (token_buffer); }
  2845.     | ALIGNOF { $$ = get_identifier (token_buffer); }
  2846.     | TYPESPEC | TYPE_QUAL
  2847.     ;
  2848.  
  2849. keyworddecl:
  2850.       selector ':' '(' typename ')' identifier
  2851.         {
  2852.           $$ = build_keyword_decl ($1, $4, $6);
  2853.         }
  2854.  
  2855.     | selector ':' identifier
  2856.         {
  2857.           $$ = build_keyword_decl ($1, NULL_TREE, $3);
  2858.         }
  2859.  
  2860.     | ':' '(' typename ')' identifier
  2861.         {
  2862.           $$ = build_keyword_decl (NULL_TREE, $3, $5);
  2863.         }
  2864.  
  2865.     | ':' identifier
  2866.         {
  2867.           $$ = build_keyword_decl (NULL_TREE, NULL_TREE, $2);
  2868.         }
  2869.     ;
  2870.  
  2871. messageargs:
  2872.       selector
  2873.         | keywordarglist
  2874.     ;
  2875.  
  2876. keywordarglist:
  2877.       keywordarg
  2878.     | keywordarglist keywordarg
  2879.         {
  2880.           $$ = chainon ($1, $2);
  2881.         }
  2882.     ;
  2883.  
  2884.  
  2885. keywordexpr:
  2886.       nonnull_exprlist
  2887.         {
  2888.           if (TREE_CHAIN ($1) == NULL_TREE)
  2889.             /* just return the expr., remove a level of indirection */
  2890.             $$ = TREE_VALUE ($1);
  2891.                   else
  2892.             /* we have a comma expr., we will collapse later */
  2893.             $$ = $1;
  2894.         }
  2895.     ;
  2896.  
  2897. keywordarg:
  2898.       selector ':' keywordexpr
  2899.         {
  2900.           $$ = build_tree_list ($1, $3);
  2901.         }
  2902.     | ':' keywordexpr
  2903.         {
  2904.           $$ = build_tree_list (NULL_TREE, $2);
  2905.         }
  2906.     ;
  2907.  
  2908. receiver:
  2909.       expr_no_commas
  2910.     | CLASSNAME
  2911.         {
  2912.           $$ = get_class_reference ($1);
  2913.         }
  2914.     ;
  2915.  
  2916. objc_openbracket.expr_no_commas:
  2917.       '['
  2918.         { objc_receiver_context = 1; }
  2919.       receiver
  2920.         { 
  2921.           objc_receiver_context = 0; 
  2922.           $$ = $3; 
  2923.             }
  2924.     ;
  2925.  
  2926. objcmessageexpr:
  2927.       objc_openbracket.expr_no_commas
  2928.       messageargs ']'
  2929.         {
  2930.           /* build nonnull_exprlist */
  2931.           $1 = build_tree_list (NULL_TREE, $1);
  2932.           /* build expr */
  2933.           $1 = build_compound_expr ($1);
  2934.           $$ = build_tree_list ($1, $2);
  2935.         }
  2936.       | objc_openbracket.expr_no_commas
  2937.         ',' nonnull_exprlist
  2938.         {
  2939.           /* make $1 a nonnull_exprlist */
  2940.           $1 = build_tree_list (NULL_TREE, $1);
  2941.           /* chain them together */
  2942.           chainon ($1, $3);
  2943.           /* make a compound expr */
  2944.           $1 = build_compound_expr ($1);
  2945.             }
  2946.       messageargs ']'
  2947.         {
  2948.           $$ = build_tree_list ($1, $5);
  2949.         }
  2950.     ;
  2951.  
  2952. selectorarg:
  2953.       selector
  2954.         | keywordnamelist
  2955.     ;
  2956.  
  2957. keywordnamelist:
  2958.       keywordname
  2959.     | keywordnamelist keywordname
  2960.         {
  2961.           $$ = chainon ($1, $2);
  2962.         }
  2963.     ;
  2964.  
  2965. keywordname:
  2966.       selector ':'
  2967.         {
  2968.           $$ = build_tree_list ($1, NULL_TREE);
  2969.         }
  2970.     | ':'
  2971.         {
  2972.           $$ = build_tree_list (NULL_TREE, NULL_TREE);
  2973.         }
  2974.     ;
  2975.  
  2976. objcselectorexpr:
  2977.       SELECTOR '(' selectorarg ')'
  2978.         {
  2979.           $$ = $3;
  2980.         }
  2981.     ;
  2982.  
  2983. objcprotocolexpr:
  2984.       PROTOCOL '(' identifier ')'
  2985.         {
  2986.           $$ = $3;
  2987.         }
  2988.     ;
  2989.  
  2990. /* extension to support C-structures in the archiver */
  2991.  
  2992. objcencodeexpr:
  2993.       ENCODE '(' typename ')'
  2994.         {
  2995.           $$ = groktypename ($3);
  2996.         }
  2997.     ;
  2998.  
  2999. end ifobjc
  3000. %%
  3001.