]> Git Repo - binutils.git/blob - gdb/expread.tab.c
ansi name abuse changes
[binutils.git] / gdb / expread.tab.c
1
2 /*  A Bison parser, made from ./expread.y  */
3
4 #define INT     258
5 #define CHAR    259
6 #define UINT    260
7 #define FLOAT   261
8 #define STRING  262
9 #define NAME    263
10 #define BLOCKNAME       264
11 #define TYPENAME        265
12 #define NAME_OR_INT     266
13 #define NAME_OR_UINT    267
14 #define STRUCT  268
15 #define UNION   269
16 #define ENUM    270
17 #define SIZEOF  271
18 #define UNSIGNED        272
19 #define COLONCOLON      273
20 #define ERROR   274
21 #define SIGNED  275
22 #define LONG    276
23 #define SHORT   277
24 #define INT_KEYWORD     278
25 #define LAST    279
26 #define REGNAME 280
27 #define VARIABLE        281
28 #define ASSIGN_MODIFY   282
29 #define THIS    283
30 #define ABOVE_COMMA     284
31 #define OR      285
32 #define AND     286
33 #define EQUAL   287
34 #define NOTEQUAL        288
35 #define LEQ     289
36 #define GEQ     290
37 #define LSH     291
38 #define RSH     292
39 #define UNARY   293
40 #define INCREMENT       294
41 #define DECREMENT       295
42 #define ARROW   296
43
44 #line 29 "./expread.y"
45
46 #include <stdio.h>
47 #include "defs.h"
48 #include "param.h"
49 #include "symtab.h"
50 #include "frame.h"
51 #include "expression.h"
52 #include "value.h"
53 #include "command.h"
54
55 static struct expression *expout;
56 static int expout_size;
57 static int expout_ptr;
58
59 static int yylex ();
60 static void yyerror ();
61 static void write_exp_elt ();
62 static void write_exp_elt_opcode ();
63 static void write_exp_elt_sym ();
64 static void write_exp_elt_longcst ();
65 static void write_exp_elt_dblcst ();
66 static void write_exp_elt_type ();
67 static void write_exp_elt_intern ();
68 static void write_exp_string ();
69 static void start_arglist ();
70 static int end_arglist ();
71 static void free_funcalls ();
72 static char *copy_name ();
73 static int parse_number ();
74
75 /* If this is nonzero, this block is used as the lexical context
76    for symbol names.  */
77
78 static struct block *expression_context_block;
79
80 /* The innermost context required by the stack and register variables
81    we've encountered so far. */
82 struct block *innermost_block;
83
84 /* The block in which the most recently discovered symbol was found. */
85 struct block *block_found;
86
87 /* Number of arguments seen so far in innermost function call.  */
88 static int arglist_len;
89
90 /* Data structure for saving values of arglist_len
91    for function calls whose arguments contain other function calls.  */
92
93 struct funcall
94   {
95     struct funcall *next;
96     int arglist_len;
97   };
98
99 struct funcall *funcall_chain;
100
101 /* This kind of datum is used to represent the name
102    of a symbol token.  */
103
104 struct stoken
105   {
106     char *ptr;
107     int length;
108   };
109
110 struct ttype
111   {
112     struct stoken stoken;
113     struct type *type;
114   };
115
116 struct symtoken
117   {
118     struct stoken stoken;
119     struct symbol *sym;
120     int is_a_field_of_this;
121   };
122
123 /* For parsing of complicated types.
124    An array should be preceded in the list by the size of the array.  */
125 enum type_pieces
126   {tp_end = -1, tp_pointer, tp_reference, tp_array, tp_function};
127 /* The stack can contain either an enum type_pieces or an int.  */
128 union type_stack_elt {
129   enum type_pieces piece;
130   int int_val;
131 };
132 static union type_stack_elt *type_stack;
133 static int type_stack_depth, type_stack_size;
134
135 static void push_type ();
136 static void push_type_int ();
137 static enum type_pieces pop_type ();
138 static int pop_type_int ();
139
140 /* Allow debugging of parsing.  */
141 #define YYDEBUG 1
142
143 #line 132 "./expread.y"
144 typedef union
145   {
146     LONGEST lval;
147     unsigned LONGEST ulval;
148     double dval;
149     struct symbol *sym;
150     struct type *tval;
151     struct stoken sval;
152     struct ttype tsym;
153     struct symtoken ssym;
154     int voidval;
155     struct block *bval;
156     enum exp_opcode opcode;
157     struct internalvar *ivar;
158
159     struct type **tvec;
160     int *ivec;
161   } YYSTYPE;
162
163 #ifndef YYLTYPE
164 typedef
165   struct yyltype
166     {
167       int timestamp;
168       int first_line;
169       int first_column;
170       int last_line;
171       int last_column;
172       char *text;
173    }
174   yyltype;
175
176 #define YYLTYPE yyltype
177 #endif
178
179 #include <stdio.h>
180
181 #ifndef __STDC__
182 #define const
183 #endif
184
185
186
187 #define YYFINAL         197
188 #define YYFLAG          -32768
189 #define YYNTBASE        66
190
191 #define YYTRANSLATE(x) ((unsigned)(x) <= 296 ? yytranslate[x] : 84)
192
193 static const char yytranslate[] = {     0,
194      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
195      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
196      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
197      2,     2,    59,     2,     2,     2,    51,    37,     2,    58,
198     62,    49,    47,    29,    48,    56,    50,     2,     2,     2,
199      2,     2,     2,     2,     2,     2,     2,    65,     2,    40,
200     31,    41,    32,    46,     2,     2,     2,     2,     2,     2,
201      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
202      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
203     57,     2,    61,    36,     2,     2,     2,     2,     2,     2,
204      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
205      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
206      2,     2,    63,    35,    64,    60,     2,     2,     2,     2,
207      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
208      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
209      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
210      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
211      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
212      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
213      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
214      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
215      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
216      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
217      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
218      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
219      2,     2,     2,     2,     2,     1,     2,     3,     4,     5,
220      6,     7,     8,     9,    10,    11,    12,    13,    14,    15,
221     16,    17,    18,    19,    20,    21,    22,    23,    24,    25,
222     26,    27,    28,    30,    33,    34,    38,    39,    42,    43,
223     44,    45,    52,    53,    54,    55
224 };
225
226 static const short yyprhs[] = {     0,
227      0,     2,     4,     8,    11,    14,    17,    20,    23,    26,
228     29,    32,    35,    38,    42,    47,    51,    56,    61,    62,
229     68,    69,    71,    75,    80,    85,    89,    93,    97,   101,
230    105,   109,   113,   117,   121,   125,   129,   133,   137,   141,
231    145,   149,   153,   157,   161,   165,   171,   175,   179,   181,
232    183,   185,   187,   189,   191,   193,   195,   197,   199,   204,
233    206,   208,   210,   214,   218,   222,   227,   230,   232,   234,
234    237,   239,   242,   244,   247,   249,   253,   256,   258,   261,
235    263,   266,   270,   273,   275,   279,   286,   295,   305,   307,
236    309,   311,   313,   316,   320,   323,   327,   331,   336,   339,
237    343,   346,   349,   352,   355,   357,   360,   362,   364,   366,
238    368,   370,   372,   376,   378,   380,   382,   384,   386,   388
239 };
240
241 static const short yyrhs[] = {    67,
242      0,    68,     0,    67,    29,    68,     0,    49,    68,     0,
243     37,    68,     0,    48,    68,     0,    59,    68,     0,    60,
244     68,     0,    53,    68,     0,    54,    68,     0,    68,    53,
245      0,    68,    54,     0,    16,    68,     0,    68,    55,    82,
246      0,    68,    55,    49,    68,     0,    68,    56,    82,     0,
247     68,    56,    49,    68,     0,    68,    57,    67,    61,     0,
248      0,    68,    58,    69,    70,    62,     0,     0,    68,     0,
249     70,    29,    68,     0,    63,    78,    64,    68,     0,    58,
250     78,    62,    68,     0,    58,    67,    62,     0,    68,    46,
251     68,     0,    68,    49,    68,     0,    68,    50,    68,     0,
252     68,    51,    68,     0,    68,    47,    68,     0,    68,    48,
253     68,     0,    68,    44,    68,     0,    68,    45,    68,     0,
254     68,    38,    68,     0,    68,    39,    68,     0,    68,    42,
255     68,     0,    68,    43,    68,     0,    68,    40,    68,     0,
256     68,    41,    68,     0,    68,    37,    68,     0,    68,    36,
257     68,     0,    68,    35,    68,     0,    68,    34,    68,     0,
258     68,    33,    68,     0,    68,    32,    68,    65,    68,     0,
259     68,    31,    68,     0,    68,    27,    68,     0,     3,     0,
260     11,     0,     5,     0,    12,     0,     4,     0,     6,     0,
261     72,     0,    24,     0,    25,     0,    26,     0,    16,    58,
262     78,    62,     0,     7,     0,    28,     0,     9,     0,    71,
263     18,    82,     0,    71,    18,    82,     0,    79,    18,    82,
264      0,    79,    18,    60,    82,     0,    18,    82,     0,    83,
265      0,    79,     0,    79,    74,     0,    49,     0,    49,    74,
266      0,    37,     0,    37,    74,     0,    75,     0,    58,    74,
267     62,     0,    75,    76,     0,    76,     0,    75,    77,     0,
268     77,     0,    57,    61,     0,    57,     3,    61,     0,    58,
269     62,     0,    73,     0,    79,    18,    49,     0,    78,    58,
270     79,    18,    49,    62,     0,    78,    58,    79,    18,    49,
271     62,    58,    62,     0,    78,    58,    79,    18,    49,    62,
272     58,    81,    62,     0,    10,     0,    23,     0,    21,     0,
273     22,     0,    21,    23,     0,    17,    21,    23,     0,    21,
274     21,     0,    21,    21,    23,     0,    17,    21,    21,     0,
275     17,    21,    21,    23,     0,    22,    23,     0,    17,    22,
276     23,     0,    13,    82,     0,    14,    82,     0,    15,    82,
277      0,    17,    80,     0,    17,     0,    20,    80,     0,    20,
278      0,    10,     0,    23,     0,    21,     0,    22,     0,    78,
279      0,    81,    29,    78,     0,     8,     0,     9,     0,    10,
280      0,    11,     0,    12,     0,     8,     0,     9,     0
281 };
282
283 #if YYDEBUG != 0
284 static const short yyrline[] = { 0,
285    225,   229,   230,   235,   238,   241,   245,   249,   253,   257,
286    261,   265,   269,   273,   279,   283,   289,   293,   297,   301,
287    307,   310,   314,   318,   324,   330,   336,   340,   344,   348,
288    352,   356,   360,   364,   368,   372,   376,   380,   384,   388,
289    392,   396,   400,   404,   408,   412,   416,   420,   426,   436,
290    449,   461,   474,   481,   488,   491,   497,   503,   509,   516,
291    523,   530,   548,   558,   570,   583,   601,   647,   741,   742,
292    777,   779,   781,   783,   785,   788,   790,   795,   801,   803,
293    807,   809,   813,   817,   818,   820,   822,   825,   832,   834,
294    836,   838,   840,   842,   844,   846,   848,   850,   852,   854,
295    856,   859,   862,   865,   867,   869,   871,   875,   876,   882,
296    888,   897,   902,   909,   910,   911,   912,   913,   916,   917
297 };
298
299 static const char * const yytname[] = {   "$",
300 "error","$illegal.","INT","CHAR","UINT","FLOAT","STRING","NAME","BLOCKNAME","TYPENAME",
301 "NAME_OR_INT","NAME_OR_UINT","STRUCT","UNION","ENUM","SIZEOF","UNSIGNED","COLONCOLON","ERROR","SIGNED",
302 "LONG","SHORT","INT_KEYWORD","LAST","REGNAME","VARIABLE","ASSIGN_MODIFY","THIS","','","ABOVE_COMMA",
303 "'='","'?'","OR","AND","'|'","'^'","'&'","EQUAL","NOTEQUAL","'<'",
304 "'>'","LEQ","GEQ","LSH","RSH","'@'","'+'","'-'","'*'","'/'",
305 "'%'","UNARY","INCREMENT","DECREMENT","ARROW","'.'","'['","'('","'!'","'~'",
306 "']'","')'","'{'","'}'","':'","start","exp1","exp","@1","arglist",
307 "block","variable","ptype","abs_decl","direct_abs_decl","array_mod","func_mod","type","typebase","typename",
308 "nonempty_typelist","name","name_not_typename",""
309 };
310 #endif
311
312 static const short yyr1[] = {     0,
313     66,    67,    67,    68,    68,    68,    68,    68,    68,    68,
314     68,    68,    68,    68,    68,    68,    68,    68,    69,    68,
315     70,    70,    70,    68,    68,    68,    68,    68,    68,    68,
316     68,    68,    68,    68,    68,    68,    68,    68,    68,    68,
317     68,    68,    68,    68,    68,    68,    68,    68,    68,    68,
318     68,    68,    68,    68,    68,    68,    68,    68,    68,    68,
319     68,    71,    71,    72,    72,    72,    72,    72,    73,    73,
320     74,    74,    74,    74,    74,    75,    75,    75,    75,    75,
321     76,    76,    77,    78,    78,    78,    78,    78,    79,    79,
322     79,    79,    79,    79,    79,    79,    79,    79,    79,    79,
323     79,    79,    79,    79,    79,    79,    79,    80,    80,    80,
324     80,    81,    81,    82,    82,    82,    82,    82,    83,    83
325 };
326
327 static const short yyr2[] = {     0,
328      1,     1,     3,     2,     2,     2,     2,     2,     2,     2,
329      2,     2,     2,     3,     4,     3,     4,     4,     0,     5,
330      0,     1,     3,     4,     4,     3,     3,     3,     3,     3,
331      3,     3,     3,     3,     3,     3,     3,     3,     3,     3,
332      3,     3,     3,     3,     3,     5,     3,     3,     1,     1,
333      1,     1,     1,     1,     1,     1,     1,     1,     4,     1,
334      1,     1,     3,     3,     3,     4,     2,     1,     1,     2,
335      1,     2,     1,     2,     1,     3,     2,     1,     2,     1,
336      2,     3,     2,     1,     3,     6,     8,     9,     1,     1,
337      1,     1,     2,     3,     2,     3,     3,     4,     2,     3,
338      2,     2,     2,     2,     1,     2,     1,     1,     1,     1,
339      1,     1,     3,     1,     1,     1,     1,     1,     1,     1
340 };
341
342 static const short yydefact[] = {     0,
343     49,    53,    51,    54,    60,   119,   120,    89,    50,    52,
344      0,     0,     0,     0,   105,     0,   107,    91,    92,    90,
345     56,    57,    58,    61,     0,     0,     0,     0,     0,     0,
346      0,     0,     0,     1,     2,     0,    55,     0,    68,   114,
347    115,   116,   117,   118,   101,   102,   103,     0,    13,   108,
348    110,   111,   109,   104,    67,   110,   111,   106,    95,    93,
349     99,     5,     6,     4,     9,    10,     0,    84,     0,    69,
350      7,     8,     0,    69,     0,     0,     0,     0,     0,     0,
351      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
352      0,     0,     0,     0,     0,     0,     0,    11,    12,     0,
353      0,     0,    19,     0,     0,     0,    97,    94,   100,    96,
354     26,     0,     0,     0,    73,    71,     0,     0,    70,    75,
355     78,    80,     0,     0,     3,    48,    47,     0,    45,    44,
356     43,    42,    41,    35,    36,    39,    40,    37,    38,    33,
357     34,    27,    31,    32,    28,    29,    30,     0,    14,     0,
358     16,     0,    21,    64,     0,    65,    59,    98,     0,    25,
359     85,    74,    72,     0,    81,    83,     0,     0,    77,    79,
360     24,     0,    15,    17,    18,    22,     0,    66,     0,    82,
361     76,    46,     0,    20,     0,    23,    86,     0,    87,   112,
362      0,     0,    88,   113,     0,     0,     0
363 };
364
365 static const short yydefgoto[] = {   195,
366     67,    35,   153,   177,    36,    37,    68,   119,   120,   121,
367    122,    69,    38,    54,   191,   156,    39
368 };
369
370 static const short yypact[] = {   167,
371 -32768,-32768,-32768,-32768,-32768,-32768,     7,-32768,-32768,-32768,
372     22,    22,    22,   228,   190,    22,   245,   119,    -7,-32768,
373 -32768,-32768,-32768,-32768,   167,   167,   167,   167,   167,   167,
374    167,   167,   528,    60,   303,    33,-32768,    76,-32768,-32768,
375 -32768,-32768,-32768,-32768,-32768,-32768,-32768,   167,   216,-32768,
376    134,    77,-32768,-32768,-32768,-32768,-32768,-32768,    78,-32768,
377 -32768,   216,   216,   216,   216,   216,    59,-32768,   -52,    75,
378    216,   216,   -55,    80,   167,   167,   167,   167,   167,   167,
379    167,   167,   167,   167,   167,   167,   167,   167,   167,   167,
380    167,   167,   167,   167,   167,   167,   167,-32768,-32768,   198,
381    249,   167,-32768,    22,   138,   -34,    90,-32768,-32768,-32768,
382 -32768,   528,   167,    96,   165,   165,    26,   104,-32768,   -50,
383 -32768,-32768,   167,    47,   303,   303,   303,   268,   355,   379,
384    402,   424,   445,   464,   464,   479,   479,   479,   479,   506,
385    506,   518,   529,   529,   216,   216,   216,   167,-32768,   167,
386 -32768,    -2,   167,    98,    22,-32768,    32,-32768,   113,   216,
387 -32768,-32768,-32768,    62,-32768,-32768,    82,   106,-32768,-32768,
388    216,   167,   216,   216,-32768,   303,    68,-32768,   137,-32768,
389 -32768,   330,   167,-32768,   132,   303,   139,   105,-32768,   141,
390     73,   528,-32768,   141,   196,   201,-32768
391 };
392
393 static const short yypgoto[] = {-32768,
394      1,   -14,-32768,-32768,-32768,-32768,-32768,    36,-32768,    83,
395     85,   -29,   -28,   200,-32768,    10,-32768
396 };
397
398
399 #define YYLAST          587
400
401
402 static const short yytable[] = {    49,
403     34,    70,   112,    73,    74,   112,   117,   168,   123,   113,
404     62,    63,    64,    65,    66,    61,    71,    72,   106,    70,
405     45,    46,    47,   112,   -62,    55,    75,   157,   164,    40,
406     41,    42,    43,    44,     1,     2,     3,     4,     5,     6,
407      7,     8,     9,    10,    11,    12,    13,    14,    15,    16,
408    104,    17,    18,    19,    20,    21,    22,    23,   175,    24,
409    125,   126,   127,   128,   129,   130,   131,   132,   133,   134,
410    135,   136,   137,   138,   139,   140,   141,   142,   143,   144,
411    145,   146,   147,   159,    28,    29,   165,    75,    75,    30,
412     31,    32,   114,   105,    33,   161,   183,   124,   160,   109,
413    110,   192,   152,    40,    41,    42,    43,    44,   171,   149,
414    151,   115,   158,   154,     8,   -63,   115,    11,    12,    13,
415    111,    15,   180,   116,    17,    18,    19,    20,   116,   184,
416    179,   117,   118,   173,   193,   174,   117,   118,   176,    59,
417    115,    60,   160,   181,   161,    40,    41,    42,    43,    44,
418    162,   163,   116,   167,   107,   155,   108,   182,   190,    74,
419    117,   118,   194,    74,   178,   166,   189,   166,   186,     1,
420      2,     3,     4,     5,     6,     7,     8,     9,    10,    11,
421     12,    13,    14,    15,    16,   185,    17,    18,    19,    20,
422     21,    22,    23,   187,    24,   196,   188,   155,   112,    50,
423    197,   115,   169,    25,   170,    40,    41,    42,    43,    44,
424     51,    52,    53,   116,    26,    27,    58,     0,     0,    28,
425     29,   117,   118,     0,    30,    31,    32,     0,     0,    33,
426      1,     2,     3,     4,     5,     6,     7,     8,     9,    10,
427     11,    12,    13,    14,    15,    16,   148,    17,    18,    19,
428     20,    21,    22,    23,    50,    24,    40,    41,    42,    43,
429     44,     0,     0,     0,    25,    56,    57,    53,    98,    99,
430    100,   101,   102,   103,     0,    26,    27,     0,     0,     0,
431     28,    29,     0,     0,     0,    48,    31,    32,     0,     0,
432     33,     0,     0,     0,    76,     0,     0,   150,    77,    78,
433     79,    80,    81,    82,    83,    84,    85,    86,    87,    88,
434     89,    90,    91,    92,    93,    94,    95,    96,    97,     0,
435     98,    99,   100,   101,   102,   103,     0,     0,     0,    76,
436      0,     0,   172,    77,    78,    79,    80,    81,    82,    83,
437     84,    85,    86,    87,    88,    89,    90,    91,    92,    93,
438     94,    95,    96,    97,     0,    98,    99,   100,   101,   102,
439    103,    78,    79,    80,    81,    82,    83,    84,    85,    86,
440     87,    88,    89,    90,    91,    92,    93,    94,    95,    96,
441     97,     0,    98,    99,   100,   101,   102,   103,    80,    81,
442     82,    83,    84,    85,    86,    87,    88,    89,    90,    91,
443     92,    93,    94,    95,    96,    97,     0,    98,    99,   100,
444    101,   102,   103,    81,    82,    83,    84,    85,    86,    87,
445     88,    89,    90,    91,    92,    93,    94,    95,    96,    97,
446      0,    98,    99,   100,   101,   102,   103,    82,    83,    84,
447     85,    86,    87,    88,    89,    90,    91,    92,    93,    94,
448     95,    96,    97,     0,    98,    99,   100,   101,   102,   103,
449     83,    84,    85,    86,    87,    88,    89,    90,    91,    92,
450     93,    94,    95,    96,    97,     0,    98,    99,   100,   101,
451    102,   103,    84,    85,    86,    87,    88,    89,    90,    91,
452     92,    93,    94,    95,    96,    97,     0,    98,    99,   100,
453    101,   102,   103,    86,    87,    88,    89,    90,    91,    92,
454     93,    94,    95,    96,    97,     0,    98,    99,   100,   101,
455    102,   103,    90,    91,    92,    93,    94,    95,    96,    97,
456      0,    98,    99,   100,   101,   102,   103,     8,     0,     0,
457     11,    12,    13,     0,    15,     0,     0,    17,    18,    19,
458     20,    92,    93,    94,    95,    96,    97,     0,    98,    99,
459    100,   101,   102,   103,    93,    94,    95,    96,    97,     0,
460     98,    99,   100,   101,   102,   103,     0,    95,    96,    97,
461      0,    98,    99,   100,   101,   102,   103
462 };
463
464 static const short yycheck[] = {    14,
465      0,    30,    58,    33,    33,    58,    57,    58,    64,    62,
466     25,    26,    27,    28,    29,    23,    31,    32,    48,    48,
467     11,    12,    13,    58,    18,    16,    29,    62,     3,     8,
468      9,    10,    11,    12,     3,     4,     5,     6,     7,     8,
469      9,    10,    11,    12,    13,    14,    15,    16,    17,    18,
470     18,    20,    21,    22,    23,    24,    25,    26,    61,    28,
471     75,    76,    77,    78,    79,    80,    81,    82,    83,    84,
472     85,    86,    87,    88,    89,    90,    91,    92,    93,    94,
473     95,    96,    97,   112,    53,    54,    61,    29,    29,    58,
474     59,    60,    18,    18,    63,    49,    29,    18,   113,    23,
475     23,    29,   102,     8,     9,    10,    11,    12,   123,   100,
476    101,    37,    23,   104,    10,    18,    37,    13,    14,    15,
477     62,    17,    61,    49,    20,    21,    22,    23,    49,    62,
478     18,    57,    58,   148,    62,   150,    57,    58,   153,    21,
479     37,    23,   157,    62,    49,     8,     9,    10,    11,    12,
480    115,   116,    49,   118,    21,    60,    23,   172,   188,   188,
481     57,    58,   192,   192,   155,    62,    62,    62,   183,     3,
482      4,     5,     6,     7,     8,     9,    10,    11,    12,    13,
483     14,    15,    16,    17,    18,    49,    20,    21,    22,    23,
484     24,    25,    26,    62,    28,     0,    58,    60,    58,    10,
485      0,    37,   120,    37,   120,     8,     9,    10,    11,    12,
486     21,    22,    23,    49,    48,    49,    17,    -1,    -1,    53,
487     54,    57,    58,    -1,    58,    59,    60,    -1,    -1,    63,
488      3,     4,     5,     6,     7,     8,     9,    10,    11,    12,
489     13,    14,    15,    16,    17,    18,    49,    20,    21,    22,
490     23,    24,    25,    26,    10,    28,     8,     9,    10,    11,
491     12,    -1,    -1,    -1,    37,    21,    22,    23,    53,    54,
492     55,    56,    57,    58,    -1,    48,    49,    -1,    -1,    -1,
493     53,    54,    -1,    -1,    -1,    58,    59,    60,    -1,    -1,
494     63,    -1,    -1,    -1,    27,    -1,    -1,    49,    31,    32,
495     33,    34,    35,    36,    37,    38,    39,    40,    41,    42,
496     43,    44,    45,    46,    47,    48,    49,    50,    51,    -1,
497     53,    54,    55,    56,    57,    58,    -1,    -1,    -1,    27,
498     -1,    -1,    65,    31,    32,    33,    34,    35,    36,    37,
499     38,    39,    40,    41,    42,    43,    44,    45,    46,    47,
500     48,    49,    50,    51,    -1,    53,    54,    55,    56,    57,
501     58,    32,    33,    34,    35,    36,    37,    38,    39,    40,
502     41,    42,    43,    44,    45,    46,    47,    48,    49,    50,
503     51,    -1,    53,    54,    55,    56,    57,    58,    34,    35,
504     36,    37,    38,    39,    40,    41,    42,    43,    44,    45,
505     46,    47,    48,    49,    50,    51,    -1,    53,    54,    55,
506     56,    57,    58,    35,    36,    37,    38,    39,    40,    41,
507     42,    43,    44,    45,    46,    47,    48,    49,    50,    51,
508     -1,    53,    54,    55,    56,    57,    58,    36,    37,    38,
509     39,    40,    41,    42,    43,    44,    45,    46,    47,    48,
510     49,    50,    51,    -1,    53,    54,    55,    56,    57,    58,
511     37,    38,    39,    40,    41,    42,    43,    44,    45,    46,
512     47,    48,    49,    50,    51,    -1,    53,    54,    55,    56,
513     57,    58,    38,    39,    40,    41,    42,    43,    44,    45,
514     46,    47,    48,    49,    50,    51,    -1,    53,    54,    55,
515     56,    57,    58,    40,    41,    42,    43,    44,    45,    46,
516     47,    48,    49,    50,    51,    -1,    53,    54,    55,    56,
517     57,    58,    44,    45,    46,    47,    48,    49,    50,    51,
518     -1,    53,    54,    55,    56,    57,    58,    10,    -1,    -1,
519     13,    14,    15,    -1,    17,    -1,    -1,    20,    21,    22,
520     23,    46,    47,    48,    49,    50,    51,    -1,    53,    54,
521     55,    56,    57,    58,    47,    48,    49,    50,    51,    -1,
522     53,    54,    55,    56,    57,    58,    -1,    49,    50,    51,
523     -1,    53,    54,    55,    56,    57,    58
524 };
525 /* -*-C-*-  Note some compilers choke on comments on `#line' lines.  */
526 #line 3 "/usr/latest/lib/bison.simple"
527
528 /* Skeleton output parser for bison,
529    Copyright (C) 1984, 1989, 1990 Bob Corbett and Richard Stallman
530
531    This program is free software; you can redistribute it and/or modify
532    it under the terms of the GNU General Public License as published by
533    the Free Software Foundation; either version 1, or (at your option)
534    any later version.
535
536    This program is distributed in the hope that it will be useful,
537    but WITHOUT ANY WARRANTY; without even the implied warranty of
538    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
539    GNU General Public License for more details.
540
541    You should have received a copy of the GNU General Public License
542    along with this program; if not, write to the Free Software
543    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
544
545
546 #ifndef alloca
547 #ifdef __GNUC__
548 #define alloca __builtin_alloca
549 #else /* Not GNU C.  */
550 #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__)
551 #include <alloca.h>
552 #else /* Not sparc */
553 #ifdef MSDOS
554 #include <malloc.h>
555 #endif /* MSDOS */
556 #endif /* Not sparc.  */
557 #endif /* Not GNU C.  */
558 #endif /* alloca not defined.  */
559
560 /* This is the parser code that is written into each bison parser
561   when the %semantic_parser declaration is not specified in the grammar.
562   It was written by Richard Stallman by simplifying the hairy parser
563   used when %semantic_parser is specified.  */
564
565 /* Note: there must be only one dollar sign in this file.
566    It is replaced by the list of actions, each action
567    as one case of the switch.  */
568
569 #define yyerrok         (yyerrstatus = 0)
570 #define yyclearin       (yychar = YYEMPTY)
571 #define YYEMPTY         -2
572 #define YYEOF           0
573 #define YYACCEPT        return(0)
574 #define YYABORT         return(1)
575 #define YYERROR         goto yyerrlab1
576 /* Like YYERROR except do call yyerror.
577    This remains here temporarily to ease the
578    transition to the new meaning of YYERROR, for GCC.
579    Once GCC version 2 has supplanted version 1, this can go.  */
580 #define YYFAIL          goto yyerrlab
581 #define YYRECOVERING()  (!!yyerrstatus)
582 #define YYBACKUP(token, value) \
583 do                                                              \
584   if (yychar == YYEMPTY && yylen == 1)                          \
585     { yychar = (token), yylval = (value);                       \
586       yychar1 = YYTRANSLATE (yychar);                           \
587       YYPOPSTACK;                                               \
588       goto yybackup;                                            \
589     }                                                           \
590   else                                                          \
591     { yyerror ("syntax error: cannot back up"); YYERROR; }      \
592 while (0)
593
594 #define YYTERROR        1
595 #define YYERRCODE       256
596
597 #ifndef YYPURE
598 #define YYLEX           yylex()
599 #endif
600
601 #ifdef YYPURE
602 #ifdef YYLSP_NEEDED
603 #define YYLEX           yylex(&yylval, &yylloc)
604 #else
605 #define YYLEX           yylex(&yylval)
606 #endif
607 #endif
608
609 /* If nonreentrant, generate the variables here */
610
611 #ifndef YYPURE
612
613 int     yychar;                 /*  the lookahead symbol                */
614 YYSTYPE yylval;                 /*  the semantic value of the           */
615                                 /*  lookahead symbol                    */
616
617 #ifdef YYLSP_NEEDED
618 YYLTYPE yylloc;                 /*  location data for the lookahead     */
619                                 /*  symbol                              */
620 #endif
621
622 int yynerrs;                    /*  number of parse errors so far       */
623 #endif  /* not YYPURE */
624
625 #if YYDEBUG != 0
626 int yydebug;                    /*  nonzero means print parse trace     */
627 /* Since this is uninitialized, it does not stop multiple parsers
628    from coexisting.  */
629 #endif
630
631 /*  YYINITDEPTH indicates the initial size of the parser's stacks       */
632
633 #ifndef YYINITDEPTH
634 #define YYINITDEPTH 200
635 #endif
636
637 /*  YYMAXDEPTH is the maximum size the stacks can grow to
638     (effective only if the built-in stack extension method is used).  */
639
640 #if YYMAXDEPTH == 0
641 #undef YYMAXDEPTH
642 #endif
643
644 #ifndef YYMAXDEPTH
645 #define YYMAXDEPTH 10000
646 #endif
647 \f
648 #ifndef __cplusplus
649
650 /* This is the most reliable way to avoid incompatibilities
651    in available built-in functions on various systems.  */
652 static void
653 __yy_bcopy (from, to, count)
654      char *from;
655      char *to;
656      int count;
657 {
658   register char *f = from;
659   register char *t = to;
660   register int i = count;
661
662   while (i-- > 0)
663     *t++ = *f++;
664 }
665
666 #else /* __cplusplus */
667
668 /* This is the most reliable way to avoid incompatibilities
669    in available built-in functions on various systems.  */
670 static void
671 __yy_bcopy (char *from, char *to, int count)
672 {
673   register char *f = from;
674   register char *t = to;
675   register int i = count;
676
677   while (i-- > 0)
678     *t++ = *f++;
679 }
680
681 #endif
682 \f
683 #line 160 "/usr/latest/lib/bison.simple"
684 int
685 yyparse()
686 {
687   register int yystate;
688   register int yyn;
689   register short *yyssp;
690   register YYSTYPE *yyvsp;
691   int yyerrstatus;      /*  number of tokens to shift before error messages enabled */
692   int yychar1;          /*  lookahead token as an internal (translated) token number */
693
694   short yyssa[YYINITDEPTH];     /*  the state stack                     */
695   YYSTYPE yyvsa[YYINITDEPTH];   /*  the semantic value stack            */
696
697   short *yyss = yyssa;          /*  refer to the stacks thru separate pointers */
698   YYSTYPE *yyvs = yyvsa;        /*  to allow yyoverflow to reallocate them elsewhere */
699
700 #ifdef YYLSP_NEEDED
701   YYLTYPE *yyls = yylsa;
702   YYLTYPE *yylsp;
703   YYLTYPE yylsa[YYINITDEPTH];   /*  the location stack                  */
704
705 #define YYPOPSTACK   (yyvsp--, yysp--, yylsp--)
706 #else
707 #define YYPOPSTACK   (yyvsp--, yysp--)
708 #endif
709
710   int yystacksize = YYINITDEPTH;
711
712 #ifdef YYPURE
713   int yychar;
714   YYSTYPE yylval;
715   int yynerrs;
716 #ifdef YYLSP_NEEDED
717   YYLTYPE yylloc;
718 #endif
719 #endif
720
721   YYSTYPE yyval;                /*  the variable used to return         */
722                                 /*  semantic values from the action     */
723                                 /*  routines                            */
724
725   int yylen;
726
727 #if YYDEBUG != 0
728   if (yydebug)
729     fprintf(stderr, "Starting parse\n");
730 #endif
731
732   yystate = 0;
733   yyerrstatus = 0;
734   yynerrs = 0;
735   yychar = YYEMPTY;             /* Cause a token to be read.  */
736
737   /* Initialize stack pointers.
738      Waste one element of value and location stack
739      so that they stay on the same level as the state stack.  */
740
741   yyssp = yyss - 1;
742   yyvsp = yyvs;
743 #ifdef YYLSP_NEEDED
744   yylsp = yyls;
745 #endif
746
747 /* Push a new state, which is found in  yystate  .  */
748 /* In all cases, when you get here, the value and location stacks
749    have just been pushed. so pushing a state here evens the stacks.  */
750 yynewstate:
751
752   *++yyssp = yystate;
753
754   if (yyssp >= yyss + yystacksize - 1)
755     {
756       /* Give user a chance to reallocate the stack */
757       /* Use copies of these so that the &'s don't force the real ones into memory. */
758       YYSTYPE *yyvs1 = yyvs;
759       short *yyss1 = yyss;
760 #ifdef YYLSP_NEEDED
761       YYLTYPE *yyls1 = yyls;
762 #endif
763
764       /* Get the current used size of the three stacks, in elements.  */
765       int size = yyssp - yyss + 1;
766
767 #ifdef yyoverflow
768       /* Each stack pointer address is followed by the size of
769          the data in use in that stack, in bytes.  */
770       yyoverflow("parser stack overflow",
771                  &yyss1, size * sizeof (*yyssp),
772                  &yyvs1, size * sizeof (*yyvsp),
773 #ifdef YYLSP_NEEDED
774                  &yyls1, size * sizeof (*yylsp),
775 #endif
776                  &yystacksize);
777
778       yyss = yyss1; yyvs = yyvs1;
779 #ifdef YYLSP_NEEDED
780       yyls = yyls1;
781 #endif
782 #else /* no yyoverflow */
783       /* Extend the stack our own way.  */
784       if (yystacksize >= YYMAXDEPTH)
785         {
786           yyerror("parser stack overflow");
787           return 2;
788         }
789       yystacksize *= 2;
790       if (yystacksize > YYMAXDEPTH)
791         yystacksize = YYMAXDEPTH;
792       yyss = (short *) alloca (yystacksize * sizeof (*yyssp));
793       __yy_bcopy ((char *)yyss1, (char *)yyss, size * sizeof (*yyssp));
794       yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp));
795       __yy_bcopy ((char *)yyvs1, (char *)yyvs, size * sizeof (*yyvsp));
796 #ifdef YYLSP_NEEDED
797       yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp));
798       __yy_bcopy ((char *)yyls1, (char *)yyls, size * sizeof (*yylsp));
799 #endif
800 #endif /* no yyoverflow */
801
802       yyssp = yyss + size - 1;
803       yyvsp = yyvs + size - 1;
804 #ifdef YYLSP_NEEDED
805       yylsp = yyls + size - 1;
806 #endif
807
808 #if YYDEBUG != 0
809       if (yydebug)
810         fprintf(stderr, "Stack size increased to %d\n", yystacksize);
811 #endif
812
813       if (yyssp >= yyss + yystacksize - 1)
814         YYABORT;
815     }
816
817 #if YYDEBUG != 0
818   if (yydebug)
819     fprintf(stderr, "Entering state %d\n", yystate);
820 #endif
821
822  yybackup:
823
824 /* Do appropriate processing given the current state.  */
825 /* Read a lookahead token if we need one and don't already have one.  */
826 /* yyresume: */
827
828   /* First try to decide what to do without reference to lookahead token.  */
829
830   yyn = yypact[yystate];
831   if (yyn == YYFLAG)
832     goto yydefault;
833
834   /* Not known => get a lookahead token if don't already have one.  */
835
836   /* yychar is either YYEMPTY or YYEOF
837      or a valid token in external form.  */
838
839   if (yychar == YYEMPTY)
840     {
841 #if YYDEBUG != 0
842       if (yydebug)
843         fprintf(stderr, "Reading a token: ");
844 #endif
845       yychar = YYLEX;
846     }
847
848   /* Convert token to internal form (in yychar1) for indexing tables with */
849
850   if (yychar <= 0)              /* This means end of input. */
851     {
852       yychar1 = 0;
853       yychar = YYEOF;           /* Don't call YYLEX any more */
854
855 #if YYDEBUG != 0
856       if (yydebug)
857         fprintf(stderr, "Now at end of input.\n");
858 #endif
859     }
860   else
861     {
862       yychar1 = YYTRANSLATE(yychar);
863
864 #if YYDEBUG != 0
865       if (yydebug)
866         fprintf(stderr, "Next token is %d (%s)\n", yychar, yytname[yychar1]);
867 #endif
868     }
869
870   yyn += yychar1;
871   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
872     goto yydefault;
873
874   yyn = yytable[yyn];
875
876   /* yyn is what to do for this token type in this state.
877      Negative => reduce, -yyn is rule number.
878      Positive => shift, yyn is new state.
879        New state is final state => don't bother to shift,
880        just return success.
881      0, or most negative number => error.  */
882
883   if (yyn < 0)
884     {
885       if (yyn == YYFLAG)
886         goto yyerrlab;
887       yyn = -yyn;
888       goto yyreduce;
889     }
890   else if (yyn == 0)
891     goto yyerrlab;
892
893   if (yyn == YYFINAL)
894     YYACCEPT;
895
896   /* Shift the lookahead token.  */
897
898 #if YYDEBUG != 0
899   if (yydebug)
900     fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
901 #endif
902
903   /* Discard the token being shifted unless it is eof.  */
904   if (yychar != YYEOF)
905     yychar = YYEMPTY;
906
907   *++yyvsp = yylval;
908 #ifdef YYLSP_NEEDED
909   *++yylsp = yylloc;
910 #endif
911
912   /* count tokens shifted since error; after three, turn off error status.  */
913   if (yyerrstatus) yyerrstatus--;
914
915   yystate = yyn;
916   goto yynewstate;
917
918 /* Do the default action for the current state.  */
919 yydefault:
920
921   yyn = yydefact[yystate];
922   if (yyn == 0)
923     goto yyerrlab;
924
925 /* Do a reduction.  yyn is the number of a rule to reduce with.  */
926 yyreduce:
927   yylen = yyr2[yyn];
928   yyval = yyvsp[1-yylen]; /* implement default value of the action */
929
930 #if YYDEBUG != 0
931   if (yydebug)
932     {
933       int i;
934
935       fprintf (stderr, "Reducing via rule %d (line %d), ",
936                yyn, yyrline[yyn]);
937
938       /* Print the symboles being reduced, and their result.  */
939       for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
940         fprintf (stderr, "%s ", yytname[yyrhs[i]]);
941       fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
942     }
943 #endif
944
945
946   switch (yyn) {
947
948 case 3:
949 #line 231 "./expread.y"
950 { write_exp_elt_opcode (BINOP_COMMA); ;
951     break;}
952 case 4:
953 #line 236 "./expread.y"
954 { write_exp_elt_opcode (UNOP_IND); ;
955     break;}
956 case 5:
957 #line 239 "./expread.y"
958 { write_exp_elt_opcode (UNOP_ADDR); ;
959     break;}
960 case 6:
961 #line 242 "./expread.y"
962 { write_exp_elt_opcode (UNOP_NEG); ;
963     break;}
964 case 7:
965 #line 246 "./expread.y"
966 { write_exp_elt_opcode (UNOP_ZEROP); ;
967     break;}
968 case 8:
969 #line 250 "./expread.y"
970 { write_exp_elt_opcode (UNOP_LOGNOT); ;
971     break;}
972 case 9:
973 #line 254 "./expread.y"
974 { write_exp_elt_opcode (UNOP_PREINCREMENT); ;
975     break;}
976 case 10:
977 #line 258 "./expread.y"
978 { write_exp_elt_opcode (UNOP_PREDECREMENT); ;
979     break;}
980 case 11:
981 #line 262 "./expread.y"
982 { write_exp_elt_opcode (UNOP_POSTINCREMENT); ;
983     break;}
984 case 12:
985 #line 266 "./expread.y"
986 { write_exp_elt_opcode (UNOP_POSTDECREMENT); ;
987     break;}
988 case 13:
989 #line 270 "./expread.y"
990 { write_exp_elt_opcode (UNOP_SIZEOF); ;
991     break;}
992 case 14:
993 #line 274 "./expread.y"
994 { write_exp_elt_opcode (STRUCTOP_PTR);
995                           write_exp_string (yyvsp[0].sval);
996                           write_exp_elt_opcode (STRUCTOP_PTR); ;
997     break;}
998 case 15:
999 #line 280 "./expread.y"
1000 { write_exp_elt_opcode (STRUCTOP_MPTR); ;
1001     break;}
1002 case 16:
1003 #line 284 "./expread.y"
1004 { write_exp_elt_opcode (STRUCTOP_STRUCT);
1005                           write_exp_string (yyvsp[0].sval);
1006                           write_exp_elt_opcode (STRUCTOP_STRUCT); ;
1007     break;}
1008 case 17:
1009 #line 290 "./expread.y"
1010 { write_exp_elt_opcode (STRUCTOP_MEMBER); ;
1011     break;}
1012 case 18:
1013 #line 294 "./expread.y"
1014 { write_exp_elt_opcode (BINOP_SUBSCRIPT); ;
1015     break;}
1016 case 19:
1017 #line 300 "./expread.y"
1018 { start_arglist (); ;
1019     break;}
1020 case 20:
1021 #line 302 "./expread.y"
1022 { write_exp_elt_opcode (OP_FUNCALL);
1023                           write_exp_elt_longcst ((LONGEST) end_arglist ());
1024                           write_exp_elt_opcode (OP_FUNCALL); ;
1025     break;}
1026 case 22:
1027 #line 311 "./expread.y"
1028 { arglist_len = 1; ;
1029     break;}
1030 case 23:
1031 #line 315 "./expread.y"
1032 { arglist_len++; ;
1033     break;}
1034 case 24:
1035 #line 319 "./expread.y"
1036 { write_exp_elt_opcode (UNOP_MEMVAL);
1037                           write_exp_elt_type (yyvsp[-2].tval);
1038                           write_exp_elt_opcode (UNOP_MEMVAL); ;
1039     break;}
1040 case 25:
1041 #line 325 "./expread.y"
1042 { write_exp_elt_opcode (UNOP_CAST);
1043                           write_exp_elt_type (yyvsp[-2].tval);
1044                           write_exp_elt_opcode (UNOP_CAST); ;
1045     break;}
1046 case 26:
1047 #line 331 "./expread.y"
1048 { ;
1049     break;}
1050 case 27:
1051 #line 337 "./expread.y"
1052 { write_exp_elt_opcode (BINOP_REPEAT); ;
1053     break;}
1054 case 28:
1055 #line 341 "./expread.y"
1056 { write_exp_elt_opcode (BINOP_MUL); ;
1057     break;}
1058 case 29:
1059 #line 345 "./expread.y"
1060 { write_exp_elt_opcode (BINOP_DIV); ;
1061     break;}
1062 case 30:
1063 #line 349 "./expread.y"
1064 { write_exp_elt_opcode (BINOP_REM); ;
1065     break;}
1066 case 31:
1067 #line 353 "./expread.y"
1068 { write_exp_elt_opcode (BINOP_ADD); ;
1069     break;}
1070 case 32:
1071 #line 357 "./expread.y"
1072 { write_exp_elt_opcode (BINOP_SUB); ;
1073     break;}
1074 case 33:
1075 #line 361 "./expread.y"
1076 { write_exp_elt_opcode (BINOP_LSH); ;
1077     break;}
1078 case 34:
1079 #line 365 "./expread.y"
1080 { write_exp_elt_opcode (BINOP_RSH); ;
1081     break;}
1082 case 35:
1083 #line 369 "./expread.y"
1084 { write_exp_elt_opcode (BINOP_EQUAL); ;
1085     break;}
1086 case 36:
1087 #line 373 "./expread.y"
1088 { write_exp_elt_opcode (BINOP_NOTEQUAL); ;
1089     break;}
1090 case 37:
1091 #line 377 "./expread.y"
1092 { write_exp_elt_opcode (BINOP_LEQ); ;
1093     break;}
1094 case 38:
1095 #line 381 "./expread.y"
1096 { write_exp_elt_opcode (BINOP_GEQ); ;
1097     break;}
1098 case 39:
1099 #line 385 "./expread.y"
1100 { write_exp_elt_opcode (BINOP_LESS); ;
1101     break;}
1102 case 40:
1103 #line 389 "./expread.y"
1104 { write_exp_elt_opcode (BINOP_GTR); ;
1105     break;}
1106 case 41:
1107 #line 393 "./expread.y"
1108 { write_exp_elt_opcode (BINOP_LOGAND); ;
1109     break;}
1110 case 42:
1111 #line 397 "./expread.y"
1112 { write_exp_elt_opcode (BINOP_LOGXOR); ;
1113     break;}
1114 case 43:
1115 #line 401 "./expread.y"
1116 { write_exp_elt_opcode (BINOP_LOGIOR); ;
1117     break;}
1118 case 44:
1119 #line 405 "./expread.y"
1120 { write_exp_elt_opcode (BINOP_AND); ;
1121     break;}
1122 case 45:
1123 #line 409 "./expread.y"
1124 { write_exp_elt_opcode (BINOP_OR); ;
1125     break;}
1126 case 46:
1127 #line 413 "./expread.y"
1128 { write_exp_elt_opcode (TERNOP_COND); ;
1129     break;}
1130 case 47:
1131 #line 417 "./expread.y"
1132 { write_exp_elt_opcode (BINOP_ASSIGN); ;
1133     break;}
1134 case 48:
1135 #line 421 "./expread.y"
1136 { write_exp_elt_opcode (BINOP_ASSIGN_MODIFY);
1137                           write_exp_elt_opcode (yyvsp[-1].opcode);
1138                           write_exp_elt_opcode (BINOP_ASSIGN_MODIFY); ;
1139     break;}
1140 case 49:
1141 #line 427 "./expread.y"
1142 { write_exp_elt_opcode (OP_LONG);
1143                           if (yyvsp[0].lval == (int) yyvsp[0].lval || yyvsp[0].lval == (unsigned int) yyvsp[0].lval)
1144                             write_exp_elt_type (builtin_type_int);
1145                           else
1146                             write_exp_elt_type (BUILTIN_TYPE_LONGEST);
1147                           write_exp_elt_longcst ((LONGEST) yyvsp[0].lval);
1148                           write_exp_elt_opcode (OP_LONG); ;
1149     break;}
1150 case 50:
1151 #line 437 "./expread.y"
1152 { YYSTYPE val;
1153                           parse_number (yyvsp[0].ssym.stoken.ptr, yyvsp[0].ssym.stoken.length, 0, &val);
1154                           write_exp_elt_opcode (OP_LONG);
1155                           if (val.lval == (int) val.lval ||
1156                               val.lval == (unsigned int) val.lval)
1157                             write_exp_elt_type (builtin_type_int);
1158                           else
1159                             write_exp_elt_type (BUILTIN_TYPE_LONGEST);
1160                           write_exp_elt_longcst (val.lval);
1161                           write_exp_elt_opcode (OP_LONG); ;
1162     break;}
1163 case 51:
1164 #line 450 "./expread.y"
1165 {
1166                           write_exp_elt_opcode (OP_LONG);
1167                           if (yyvsp[0].ulval == (unsigned int) yyvsp[0].ulval)
1168                             write_exp_elt_type (builtin_type_unsigned_int);
1169                           else
1170                             write_exp_elt_type (BUILTIN_TYPE_UNSIGNED_LONGEST);
1171                           write_exp_elt_longcst ((LONGEST) yyvsp[0].ulval);
1172                           write_exp_elt_opcode (OP_LONG);
1173                         ;
1174     break;}
1175 case 52:
1176 #line 462 "./expread.y"
1177 { YYSTYPE val;
1178                           parse_number (yyvsp[0].ssym.stoken.ptr, yyvsp[0].ssym.stoken.length, 0, &val);
1179                           write_exp_elt_opcode (OP_LONG);
1180                           if (val.ulval == (unsigned int) val.ulval)
1181                             write_exp_elt_type (builtin_type_unsigned_int);
1182                           else
1183                             write_exp_elt_type (BUILTIN_TYPE_UNSIGNED_LONGEST);
1184                           write_exp_elt_longcst ((LONGEST)val.ulval);
1185                           write_exp_elt_opcode (OP_LONG);
1186                         ;
1187     break;}
1188 case 53:
1189 #line 475 "./expread.y"
1190 { write_exp_elt_opcode (OP_LONG);
1191                           write_exp_elt_type (builtin_type_char);
1192                           write_exp_elt_longcst ((LONGEST) yyvsp[0].lval);
1193                           write_exp_elt_opcode (OP_LONG); ;
1194     break;}
1195 case 54:
1196 #line 482 "./expread.y"
1197 { write_exp_elt_opcode (OP_DOUBLE);
1198                           write_exp_elt_type (builtin_type_double);
1199                           write_exp_elt_dblcst (yyvsp[0].dval);
1200                           write_exp_elt_opcode (OP_DOUBLE); ;
1201     break;}
1202 case 56:
1203 #line 492 "./expread.y"
1204 { write_exp_elt_opcode (OP_LAST);
1205                           write_exp_elt_longcst ((LONGEST) yyvsp[0].lval);
1206                           write_exp_elt_opcode (OP_LAST); ;
1207     break;}
1208 case 57:
1209 #line 498 "./expread.y"
1210 { write_exp_elt_opcode (OP_REGISTER);
1211                           write_exp_elt_longcst ((LONGEST) yyvsp[0].lval);
1212                           write_exp_elt_opcode (OP_REGISTER); ;
1213     break;}
1214 case 58:
1215 #line 504 "./expread.y"
1216 { write_exp_elt_opcode (OP_INTERNALVAR);
1217                           write_exp_elt_intern (yyvsp[0].ivar);
1218                           write_exp_elt_opcode (OP_INTERNALVAR); ;
1219     break;}
1220 case 59:
1221 #line 510 "./expread.y"
1222 { write_exp_elt_opcode (OP_LONG);
1223                           write_exp_elt_type (builtin_type_int);
1224                           write_exp_elt_longcst ((LONGEST) TYPE_LENGTH (yyvsp[-1].tval));
1225                           write_exp_elt_opcode (OP_LONG); ;
1226     break;}
1227 case 60:
1228 #line 517 "./expread.y"
1229 { write_exp_elt_opcode (OP_STRING);
1230                           write_exp_string (yyvsp[0].sval);
1231                           write_exp_elt_opcode (OP_STRING); ;
1232     break;}
1233 case 61:
1234 #line 524 "./expread.y"
1235 { write_exp_elt_opcode (OP_THIS);
1236                           write_exp_elt_opcode (OP_THIS); ;
1237     break;}
1238 case 62:
1239 #line 531 "./expread.y"
1240 {
1241                           if (yyvsp[0].ssym.sym != 0)
1242                               yyval.bval = SYMBOL_BLOCK_VALUE (yyvsp[0].ssym.sym);
1243                           else
1244                             {
1245                               struct symtab *tem =
1246                                   lookup_symtab (copy_name (yyvsp[0].ssym.stoken));
1247                               if (tem)
1248                                 yyval.bval = BLOCKVECTOR_BLOCK
1249                                          (BLOCKVECTOR (tem), STATIC_BLOCK);
1250                               else
1251                                 error ("No file or function \"%s\".",
1252                                        copy_name (yyvsp[0].ssym.stoken));
1253                             }
1254                         ;
1255     break;}
1256 case 63:
1257 #line 549 "./expread.y"
1258 { struct symbol *tem
1259                             = lookup_symbol (copy_name (yyvsp[0].sval), yyvsp[-2].bval,
1260                                              VAR_NAMESPACE, 0, NULL);
1261                           if (!tem || SYMBOL_CLASS (tem) != LOC_BLOCK)
1262                             error ("No function \"%s\" in specified context.",
1263                                    copy_name (yyvsp[0].sval));
1264                           yyval.bval = SYMBOL_BLOCK_VALUE (tem); ;
1265     break;}
1266 case 64:
1267 #line 559 "./expread.y"
1268 { struct symbol *sym;
1269                           sym = lookup_symbol (copy_name (yyvsp[0].sval), yyvsp[-2].bval,
1270                                                VAR_NAMESPACE, 0, NULL);
1271                           if (sym == 0)
1272                             error ("No symbol \"%s\" in specified context.",
1273                                    copy_name (yyvsp[0].sval));
1274                           write_exp_elt_opcode (OP_VAR_VALUE);
1275                           write_exp_elt_sym (sym);
1276                           write_exp_elt_opcode (OP_VAR_VALUE); ;
1277     break;}
1278 case 65:
1279 #line 571 "./expread.y"
1280 {
1281                           struct type *type = yyvsp[-2].tval;
1282                           if (TYPE_CODE (type) != TYPE_CODE_STRUCT
1283                               && TYPE_CODE (type) != TYPE_CODE_UNION)
1284                             error ("`%s' is not defined as an aggregate type.",
1285                                    TYPE_NAME (type));
1286
1287                           write_exp_elt_opcode (OP_SCOPE);
1288                           write_exp_elt_type (type);
1289                           write_exp_string (yyvsp[0].sval);
1290                           write_exp_elt_opcode (OP_SCOPE);
1291                         ;
1292     break;}
1293 case 66:
1294 #line 584 "./expread.y"
1295 {
1296                           struct type *type = yyvsp[-3].tval;
1297                           if (TYPE_CODE (type) != TYPE_CODE_STRUCT
1298                               && TYPE_CODE (type) != TYPE_CODE_UNION)
1299                             error ("`%s' is not defined as an aggregate type.",
1300                                    TYPE_NAME (type));
1301
1302                           if (strcmp (type_name_no_tag (type), yyvsp[0].sval.ptr))
1303                             error ("invalid destructor `%s::~%s'",
1304                                    type_name_no_tag (type), yyvsp[0].sval.ptr);
1305
1306                           write_exp_elt_opcode (OP_SCOPE);
1307                           write_exp_elt_type (type);
1308                           write_exp_string (yyvsp[0].sval);
1309                           write_exp_elt_opcode (OP_SCOPE);
1310                           write_exp_elt_opcode (UNOP_LOGNOT);
1311                         ;
1312     break;}
1313 case 67:
1314 #line 602 "./expread.y"
1315 {
1316                           char *name = copy_name (yyvsp[0].sval);
1317                           struct symbol *sym;
1318                           int i;
1319
1320                           sym =
1321                             lookup_symbol (name, 0, VAR_NAMESPACE, 0, NULL);
1322                           if (sym)
1323                             {
1324                               write_exp_elt_opcode (OP_VAR_VALUE);
1325                               write_exp_elt_sym (sym);
1326                               write_exp_elt_opcode (OP_VAR_VALUE);
1327                               break;
1328                             }
1329                           for (i = 0; i < misc_function_count; i++)
1330                             if (!strcmp (misc_function_vector[i].name, name))
1331                               break;
1332
1333                           if (i < misc_function_count)
1334                             {
1335                               enum misc_function_type mft =
1336                                   misc_function_vector[i].type;
1337                               
1338                               write_exp_elt_opcode (OP_LONG);
1339                               write_exp_elt_type (builtin_type_int);
1340                               write_exp_elt_longcst ((LONGEST) misc_function_vector[i].address);
1341                               write_exp_elt_opcode (OP_LONG);
1342                               write_exp_elt_opcode (UNOP_MEMVAL);
1343                               if (mft == mf_data || mft == mf_bss)
1344                                 write_exp_elt_type (builtin_type_int);
1345                               else if (mft == mf_text)
1346                                 write_exp_elt_type (lookup_function_type (builtin_type_int));
1347                               else
1348                                 write_exp_elt_type (builtin_type_char);
1349                               write_exp_elt_opcode (UNOP_MEMVAL);
1350                             }
1351                           else
1352                             if (symtab_list == 0
1353                                 && partial_symtab_list == 0)
1354                               error ("No symbol table is loaded.  Use the \"file\" command.");
1355                             else
1356                               error ("No symbol \"%s\" in current context.", name);
1357                         ;
1358     break;}
1359 case 68:
1360 #line 648 "./expread.y"
1361 { struct symbol *sym = yyvsp[0].ssym.sym;
1362
1363                           if (sym)
1364                             {
1365                               switch (sym->class)
1366                                 {
1367                                 case LOC_REGISTER:
1368                                 case LOC_ARG:
1369                                 case LOC_REF_ARG:
1370                                 case LOC_REGPARM:
1371                                 case LOC_LOCAL:
1372                                 case LOC_LOCAL_ARG:
1373                                   if (innermost_block == 0 ||
1374                                       contained_in (block_found, 
1375                                                     innermost_block))
1376                                     innermost_block = block_found;
1377                                 case LOC_UNDEF:
1378                                 case LOC_CONST:
1379                                 case LOC_STATIC:
1380                                 case LOC_TYPEDEF:
1381                                 case LOC_LABEL:
1382                                 case LOC_BLOCK:
1383                                 case LOC_CONST_BYTES:
1384
1385                                   /* In this case the expression can
1386                                      be evaluated regardless of what
1387                                      frame we are in, so there is no
1388                                      need to check for the
1389                                      innermost_block.  These cases are
1390                                      listed so that gcc -Wall will
1391                                      report types that may not have
1392                                      been considered.  */
1393
1394                                   break;
1395                                 }
1396                               write_exp_elt_opcode (OP_VAR_VALUE);
1397                               write_exp_elt_sym (sym);
1398                               write_exp_elt_opcode (OP_VAR_VALUE);
1399                             }
1400                           else if (yyvsp[0].ssym.is_a_field_of_this)
1401                             {
1402                               /* C++: it hangs off of `this'.  Must
1403                                  not inadvertently convert from a method call
1404                                  to data ref.  */
1405                               if (innermost_block == 0 || 
1406                                   contained_in (block_found, innermost_block))
1407                                 innermost_block = block_found;
1408                               write_exp_elt_opcode (OP_THIS);
1409                               write_exp_elt_opcode (OP_THIS);
1410                               write_exp_elt_opcode (STRUCTOP_PTR);
1411                               write_exp_string (yyvsp[0].ssym.stoken);
1412                               write_exp_elt_opcode (STRUCTOP_PTR);
1413                             }
1414                           else
1415                             {
1416                               register int i;
1417                               register char *arg = copy_name (yyvsp[0].ssym.stoken);
1418
1419                                 /* FIXME, this search is linear!  At least
1420                                    optimize the strcmp with a 1-char cmp... */
1421                               for (i = 0; i < misc_function_count; i++)
1422                                 if (!strcmp (misc_function_vector[i].name, arg))
1423                                   break;
1424
1425                               if (i < misc_function_count)
1426                                 {
1427                                   enum misc_function_type mft =
1428                                       misc_function_vector[i].type;
1429                                   
1430                                   write_exp_elt_opcode (OP_LONG);
1431                                   write_exp_elt_type (builtin_type_int);
1432                                   write_exp_elt_longcst ((LONGEST) misc_function_vector[i].address);
1433                                   write_exp_elt_opcode (OP_LONG);
1434                                   write_exp_elt_opcode (UNOP_MEMVAL);
1435                                   if (mft == mf_data || mft == mf_bss)
1436                                     write_exp_elt_type (builtin_type_int);
1437                                   else if (mft == mf_text)
1438                                     write_exp_elt_type (lookup_function_type (builtin_type_int));
1439                                   else
1440                                     write_exp_elt_type (builtin_type_char);
1441                                   write_exp_elt_opcode (UNOP_MEMVAL);
1442                                 }
1443                               else if (symtab_list == 0
1444                                        && partial_symtab_list == 0)
1445                                 error ("No symbol table is loaded.  Use the \"file\" command.");
1446                               else
1447                                 error ("No symbol \"%s\" in current context.",
1448                                        copy_name (yyvsp[0].ssym.stoken));
1449                             }
1450                         ;
1451     break;}
1452 case 70:
1453 #line 743 "./expread.y"
1454 {
1455                   /* This is where the interesting stuff happens.  */
1456                   int done = 0;
1457                   int array_size;
1458                   struct type *follow_type = yyvsp[-1].tval;
1459                   
1460                   while (!done)
1461                     switch (pop_type ())
1462                       {
1463                       case tp_end:
1464                         done = 1;
1465                         break;
1466                       case tp_pointer:
1467                         follow_type = lookup_pointer_type (follow_type);
1468                         break;
1469                       case tp_reference:
1470                         follow_type = lookup_reference_type (follow_type);
1471                         break;
1472                       case tp_array:
1473                         array_size = pop_type_int ();
1474                         if (array_size != -1)
1475                           follow_type = create_array_type (follow_type,
1476                                                            array_size);
1477                         else
1478                           follow_type = lookup_pointer_type (follow_type);
1479                         break;
1480                       case tp_function:
1481                         follow_type = lookup_function_type (follow_type);
1482                         break;
1483                       }
1484                   yyval.tval = follow_type;
1485                 ;
1486     break;}
1487 case 71:
1488 #line 778 "./expread.y"
1489 { push_type (tp_pointer); yyval.voidval = 0; ;
1490     break;}
1491 case 72:
1492 #line 780 "./expread.y"
1493 { push_type (tp_pointer); yyval.voidval = yyvsp[0].voidval; ;
1494     break;}
1495 case 73:
1496 #line 782 "./expread.y"
1497 { push_type (tp_reference); yyval.voidval = 0; ;
1498     break;}
1499 case 74:
1500 #line 784 "./expread.y"
1501 { push_type (tp_reference); yyval.voidval = yyvsp[0].voidval; ;
1502     break;}
1503 case 76:
1504 #line 789 "./expread.y"
1505 { yyval.voidval = yyvsp[-1].voidval; ;
1506     break;}
1507 case 77:
1508 #line 791 "./expread.y"
1509 {
1510                           push_type_int (yyvsp[0].lval);
1511                           push_type (tp_array);
1512                         ;
1513     break;}
1514 case 78:
1515 #line 796 "./expread.y"
1516 {
1517                           push_type_int (yyvsp[0].lval);
1518                           push_type (tp_array);
1519                           yyval.voidval = 0;
1520                         ;
1521     break;}
1522 case 79:
1523 #line 802 "./expread.y"
1524 { push_type (tp_function); ;
1525     break;}
1526 case 80:
1527 #line 804 "./expread.y"
1528 { push_type (tp_function); ;
1529     break;}
1530 case 81:
1531 #line 808 "./expread.y"
1532 { yyval.lval = -1; ;
1533     break;}
1534 case 82:
1535 #line 810 "./expread.y"
1536 { yyval.lval = yyvsp[-1].lval; ;
1537     break;}
1538 case 83:
1539 #line 814 "./expread.y"
1540 { yyval.voidval = 0; ;
1541     break;}
1542 case 85:
1543 #line 819 "./expread.y"
1544 { yyval.tval = lookup_member_type (builtin_type_int, yyvsp[-2].tval); ;
1545     break;}
1546 case 86:
1547 #line 821 "./expread.y"
1548 { yyval.tval = lookup_member_type (yyvsp[-5].tval, yyvsp[-3].tval); ;
1549     break;}
1550 case 87:
1551 #line 823 "./expread.y"
1552 { yyval.tval = lookup_member_type
1553                             (lookup_function_type (yyvsp[-7].tval), yyvsp[-5].tval); ;
1554     break;}
1555 case 88:
1556 #line 826 "./expread.y"
1557 { yyval.tval = lookup_member_type
1558                             (lookup_function_type (yyvsp[-8].tval), yyvsp[-6].tval);
1559                           free (yyvsp[-1].tvec); ;
1560     break;}
1561 case 89:
1562 #line 833 "./expread.y"
1563 { yyval.tval = yyvsp[0].tsym.type; ;
1564     break;}
1565 case 90:
1566 #line 835 "./expread.y"
1567 { yyval.tval = builtin_type_int; ;
1568     break;}
1569 case 91:
1570 #line 837 "./expread.y"
1571 { yyval.tval = builtin_type_long; ;
1572     break;}
1573 case 92:
1574 #line 839 "./expread.y"
1575 { yyval.tval = builtin_type_short; ;
1576     break;}
1577 case 93:
1578 #line 841 "./expread.y"
1579 { yyval.tval = builtin_type_long; ;
1580     break;}
1581 case 94:
1582 #line 843 "./expread.y"
1583 { yyval.tval = builtin_type_unsigned_long; ;
1584     break;}
1585 case 95:
1586 #line 845 "./expread.y"
1587 { yyval.tval = builtin_type_long_long; ;
1588     break;}
1589 case 96:
1590 #line 847 "./expread.y"
1591 { yyval.tval = builtin_type_long_long; ;
1592     break;}
1593 case 97:
1594 #line 849 "./expread.y"
1595 { yyval.tval = builtin_type_unsigned_long_long; ;
1596     break;}
1597 case 98:
1598 #line 851 "./expread.y"
1599 { yyval.tval = builtin_type_unsigned_long_long; ;
1600     break;}
1601 case 99:
1602 #line 853 "./expread.y"
1603 { yyval.tval = builtin_type_short; ;
1604     break;}
1605 case 100:
1606 #line 855 "./expread.y"
1607 { yyval.tval = builtin_type_unsigned_short; ;
1608     break;}
1609 case 101:
1610 #line 857 "./expread.y"
1611 { yyval.tval = lookup_struct (copy_name (yyvsp[0].sval),
1612                                               expression_context_block); ;
1613     break;}
1614 case 102:
1615 #line 860 "./expread.y"
1616 { yyval.tval = lookup_union (copy_name (yyvsp[0].sval),
1617                                              expression_context_block); ;
1618     break;}
1619 case 103:
1620 #line 863 "./expread.y"
1621 { yyval.tval = lookup_enum (copy_name (yyvsp[0].sval),
1622                                             expression_context_block); ;
1623     break;}
1624 case 104:
1625 #line 866 "./expread.y"
1626 { yyval.tval = lookup_unsigned_typename (TYPE_NAME(yyvsp[0].tsym.type)); ;
1627     break;}
1628 case 105:
1629 #line 868 "./expread.y"
1630 { yyval.tval = builtin_type_unsigned_int; ;
1631     break;}
1632 case 106:
1633 #line 870 "./expread.y"
1634 { yyval.tval = yyvsp[0].tsym.type; ;
1635     break;}
1636 case 107:
1637 #line 872 "./expread.y"
1638 { yyval.tval = builtin_type_int; ;
1639     break;}
1640 case 109:
1641 #line 877 "./expread.y"
1642 {
1643                   yyval.tsym.stoken.ptr = "int";
1644                   yyval.tsym.stoken.length = 3;
1645                   yyval.tsym.type = builtin_type_int;
1646                 ;
1647     break;}
1648 case 110:
1649 #line 883 "./expread.y"
1650 {
1651                   yyval.tsym.stoken.ptr = "long";
1652                   yyval.tsym.stoken.length = 4;
1653                   yyval.tsym.type = builtin_type_long;
1654                 ;
1655     break;}
1656 case 111:
1657 #line 889 "./expread.y"
1658 {
1659                   yyval.tsym.stoken.ptr = "short";
1660                   yyval.tsym.stoken.length = 5;
1661                   yyval.tsym.type = builtin_type_short;
1662                 ;
1663     break;}
1664 case 112:
1665 #line 898 "./expread.y"
1666 { yyval.tvec = (struct type **)xmalloc (sizeof (struct type *) * 2);
1667                   yyval.tvec[0] = (struct type *)0;
1668                   yyval.tvec[1] = yyvsp[0].tval;
1669                 ;
1670     break;}
1671 case 113:
1672 #line 903 "./expread.y"
1673 { int len = sizeof (struct type *) * ++(yyvsp[-2].ivec[0]);
1674                   yyval.tvec = (struct type **)xrealloc (yyvsp[-2].tvec, len);
1675                   yyval.tvec[yyval.ivec[0]] = yyvsp[0].tval;
1676                 ;
1677     break;}
1678 case 114:
1679 #line 909 "./expread.y"
1680 { yyval.sval = yyvsp[0].ssym.stoken; ;
1681     break;}
1682 case 115:
1683 #line 910 "./expread.y"
1684 { yyval.sval = yyvsp[0].ssym.stoken; ;
1685     break;}
1686 case 116:
1687 #line 911 "./expread.y"
1688 { yyval.sval = yyvsp[0].tsym.stoken; ;
1689     break;}
1690 case 117:
1691 #line 912 "./expread.y"
1692 { yyval.sval = yyvsp[0].ssym.stoken; ;
1693     break;}
1694 case 118:
1695 #line 913 "./expread.y"
1696 { yyval.sval = yyvsp[0].ssym.stoken; ;
1697     break;}
1698 }
1699    /* the action file gets copied in in place of this dollarsign */
1700 #line 423 "/usr/latest/lib/bison.simple"
1701 \f
1702   yyvsp -= yylen;
1703   yyssp -= yylen;
1704 #ifdef YYLSP_NEEDED
1705   yylsp -= yylen;
1706 #endif
1707
1708 #if YYDEBUG != 0
1709   if (yydebug)
1710     {
1711       short *ssp1 = yyss - 1;
1712       fprintf (stderr, "state stack now");
1713       while (ssp1 != yyssp)
1714         fprintf (stderr, " %d", *++ssp1);
1715       fprintf (stderr, "\n");
1716     }
1717 #endif
1718
1719   *++yyvsp = yyval;
1720
1721 #ifdef YYLSP_NEEDED
1722   yylsp++;
1723   if (yylen == 0)
1724     {
1725       yylsp->first_line = yylloc.first_line;
1726       yylsp->first_column = yylloc.first_column;
1727       yylsp->last_line = (yylsp-1)->last_line;
1728       yylsp->last_column = (yylsp-1)->last_column;
1729       yylsp->text = 0;
1730     }
1731   else
1732     {
1733       yylsp->last_line = (yylsp+yylen-1)->last_line;
1734       yylsp->last_column = (yylsp+yylen-1)->last_column;
1735     }
1736 #endif
1737
1738   /* Now "shift" the result of the reduction.
1739      Determine what state that goes to,
1740      based on the state we popped back to
1741      and the rule number reduced by.  */
1742
1743   yyn = yyr1[yyn];
1744
1745   yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
1746   if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1747     yystate = yytable[yystate];
1748   else
1749     yystate = yydefgoto[yyn - YYNTBASE];
1750
1751   goto yynewstate;
1752
1753 yyerrlab:   /* here on detecting error */
1754
1755   if (! yyerrstatus)
1756     /* If not already recovering from an error, report this error.  */
1757     {
1758       ++yynerrs;
1759
1760 #ifdef YYERROR_VERBOSE
1761       yyn = yypact[yystate];
1762
1763       if (yyn > YYFLAG && yyn < YYLAST)
1764         {
1765           int size = 0;
1766           char *msg;
1767           int x, count;
1768
1769           count = 0;
1770           for (x = 0; x < (sizeof(yytname) / sizeof(char *)); x++)
1771             if (yycheck[x + yyn] == x)
1772               size += strlen(yytname[x]) + 15, count++;
1773           msg = (char *) xmalloc(size + 15);
1774           strcpy(msg, "parse error");
1775
1776           if (count < 5)
1777             {
1778               count = 0;
1779               for (x = 0; x < (sizeof(yytname) / sizeof(char *)); x++)
1780                 if (yycheck[x + yyn] == x)
1781                   {
1782                     strcat(msg, count == 0 ? ", expecting `" : " or `");
1783                     strcat(msg, yytname[x]);
1784                     strcat(msg, "'");
1785                     count++;
1786                   }
1787             }
1788           yyerror(msg);
1789           free(msg);
1790         }
1791       else
1792 #endif /* YYERROR_VERBOSE */
1793         yyerror("parse error");
1794     }
1795
1796 yyerrlab1:   /* here on error raised explicitly by an action */
1797
1798   if (yyerrstatus == 3)
1799     {
1800       /* if just tried and failed to reuse lookahead token after an error, discard it.  */
1801
1802       /* return failure if at end of input */
1803       if (yychar == YYEOF)
1804         YYABORT;
1805
1806 #if YYDEBUG != 0
1807       if (yydebug)
1808         fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
1809 #endif
1810
1811       yychar = YYEMPTY;
1812     }
1813
1814   /* Else will try to reuse lookahead token
1815      after shifting the error token.  */
1816
1817   yyerrstatus = 3;              /* Each real token shifted decrements this */
1818
1819   goto yyerrhandle;
1820
1821 yyerrdefault:  /* current state does not do anything special for the error token. */
1822
1823 #if 0
1824   /* This is wrong; only states that explicitly want error tokens
1825      should shift them.  */
1826   yyn = yydefact[yystate];  /* If its default is to accept any token, ok.  Otherwise pop it.*/
1827   if (yyn) goto yydefault;
1828 #endif
1829
1830 yyerrpop:   /* pop the current state because it cannot handle the error token */
1831
1832   if (yyssp == yyss) YYABORT;
1833   yyvsp--;
1834   yystate = *--yyssp;
1835 #ifdef YYLSP_NEEDED
1836   yylsp--;
1837 #endif
1838
1839 #if YYDEBUG != 0
1840   if (yydebug)
1841     {
1842       short *ssp1 = yyss - 1;
1843       fprintf (stderr, "Error: state stack now");
1844       while (ssp1 != yyssp)
1845         fprintf (stderr, " %d", *++ssp1);
1846       fprintf (stderr, "\n");
1847     }
1848 #endif
1849
1850 yyerrhandle:
1851
1852   yyn = yypact[yystate];
1853   if (yyn == YYFLAG)
1854     goto yyerrdefault;
1855
1856   yyn += YYTERROR;
1857   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
1858     goto yyerrdefault;
1859
1860   yyn = yytable[yyn];
1861   if (yyn < 0)
1862     {
1863       if (yyn == YYFLAG)
1864         goto yyerrpop;
1865       yyn = -yyn;
1866       goto yyreduce;
1867     }
1868   else if (yyn == 0)
1869     goto yyerrpop;
1870
1871   if (yyn == YYFINAL)
1872     YYACCEPT;
1873
1874 #if YYDEBUG != 0
1875   if (yydebug)
1876     fprintf(stderr, "Shifting error token, ");
1877 #endif
1878
1879   *++yyvsp = yylval;
1880 #ifdef YYLSP_NEEDED
1881   *++yylsp = yylloc;
1882 #endif
1883
1884   yystate = yyn;
1885   goto yynewstate;
1886 }
1887 #line 928 "./expread.y"
1888
1889 \f
1890 /* Begin counting arguments for a function call,
1891    saving the data about any containing call.  */
1892
1893 static void
1894 start_arglist ()
1895 {
1896   register struct funcall *new = (struct funcall *) xmalloc (sizeof (struct funcall));
1897
1898   new->next = funcall_chain;
1899   new->arglist_len = arglist_len;
1900   arglist_len = 0;
1901   funcall_chain = new;
1902 }
1903
1904 /* Return the number of arguments in a function call just terminated,
1905    and restore the data for the containing function call.  */
1906
1907 static int
1908 end_arglist ()
1909 {
1910   register int val = arglist_len;
1911   register struct funcall *call = funcall_chain;
1912   funcall_chain = call->next;
1913   arglist_len = call->arglist_len;
1914   free (call);
1915   return val;
1916 }
1917
1918 /* Free everything in the funcall chain.
1919    Used when there is an error inside parsing.  */
1920
1921 static void
1922 free_funcalls ()
1923 {
1924   register struct funcall *call, *next;
1925
1926   for (call = funcall_chain; call; call = next)
1927     {
1928       next = call->next;
1929       free (call);
1930     }
1931 }
1932 \f
1933 /* This page contains the functions for adding data to the  struct expression
1934    being constructed.  */
1935
1936 /* Add one element to the end of the expression.  */
1937
1938 /* To avoid a bug in the Sun 4 compiler, we pass things that can fit into
1939    a register through here */
1940
1941 static void
1942 write_exp_elt (expelt)
1943      union exp_element expelt;
1944 {
1945   if (expout_ptr >= expout_size)
1946     {
1947       expout_size *= 2;
1948       expout = (struct expression *) xrealloc (expout,
1949                                                sizeof (struct expression)
1950                                                + expout_size * sizeof (union exp_element));
1951     }
1952   expout->elts[expout_ptr++] = expelt;
1953 }
1954
1955 static void
1956 write_exp_elt_opcode (expelt)
1957      enum exp_opcode expelt;
1958 {
1959   union exp_element tmp;
1960
1961   tmp.opcode = expelt;
1962
1963   write_exp_elt (tmp);
1964 }
1965
1966 static void
1967 write_exp_elt_sym (expelt)
1968      struct symbol *expelt;
1969 {
1970   union exp_element tmp;
1971
1972   tmp.symbol = expelt;
1973
1974   write_exp_elt (tmp);
1975 }
1976
1977 static void
1978 write_exp_elt_longcst (expelt)
1979      LONGEST expelt;
1980 {
1981   union exp_element tmp;
1982
1983   tmp.longconst = expelt;
1984
1985   write_exp_elt (tmp);
1986 }
1987
1988 static void
1989 write_exp_elt_dblcst (expelt)
1990      double expelt;
1991 {
1992   union exp_element tmp;
1993
1994   tmp.doubleconst = expelt;
1995
1996   write_exp_elt (tmp);
1997 }
1998
1999 static void
2000 write_exp_elt_type (expelt)
2001      struct type *expelt;
2002 {
2003   union exp_element tmp;
2004
2005   tmp.type = expelt;
2006
2007   write_exp_elt (tmp);
2008 }
2009
2010 static void
2011 write_exp_elt_intern (expelt)
2012      struct internalvar *expelt;
2013 {
2014   union exp_element tmp;
2015
2016   tmp.internalvar = expelt;
2017
2018   write_exp_elt (tmp);
2019 }
2020
2021 /* Add a string constant to the end of the expression.
2022    Follow it by its length in bytes, as a separate exp_element.  */
2023
2024 static void
2025 write_exp_string (str)
2026      struct stoken str;
2027 {
2028   register int len = str.length;
2029   register int lenelt
2030     = (len + sizeof (union exp_element)) / sizeof (union exp_element);
2031
2032   expout_ptr += lenelt;
2033
2034   if (expout_ptr >= expout_size)
2035     {
2036       expout_size = max (expout_size * 2, expout_ptr + 10);
2037       expout = (struct expression *)
2038         xrealloc (expout, (sizeof (struct expression)
2039                            + (expout_size * sizeof (union exp_element))));
2040     }
2041   bcopy (str.ptr, (char *) &expout->elts[expout_ptr - lenelt], len);
2042   ((char *) &expout->elts[expout_ptr - lenelt])[len] = 0;
2043   write_exp_elt_longcst ((LONGEST) len);
2044 }
2045 \f
2046 /* During parsing of a C expression, the pointer to the next character
2047    is in this variable.  */
2048
2049 static char *lexptr;
2050
2051 /* Tokens that refer to names do so with explicit pointer and length,
2052    so they can share the storage that lexptr is parsing.
2053
2054    When it is necessary to pass a name to a function that expects
2055    a null-terminated string, the substring is copied out
2056    into a block of storage that namecopy points to.
2057
2058    namecopy is allocated once, guaranteed big enough, for each parsing.  */
2059
2060 static char *namecopy;
2061
2062 /* Current depth in parentheses within the expression.  */
2063
2064 static int paren_depth;
2065
2066 /* Nonzero means stop parsing on first comma (if not within parentheses).  */
2067
2068 static int comma_terminates;
2069
2070 /* Take care of parsing a number (anything that starts with a digit).
2071    Set yylval and return the token type; update lexptr.
2072    LEN is the number of characters in it.  */
2073
2074 /*** Needs some error checking for the float case ***/
2075
2076 static int
2077 parse_number (p, len, parsed_float, putithere)
2078      register char *p;
2079      register int len;
2080      int parsed_float;
2081      YYSTYPE *putithere;
2082 {
2083   register LONGEST n = 0;
2084   register int i;
2085   register int c;
2086   register int base = input_radix;
2087   int unsigned_p = 0;
2088
2089   extern double atof ();
2090
2091   if (parsed_float)
2092     {
2093       /* It's a float since it contains a point or an exponent.  */
2094       putithere->dval = atof (p);
2095       return FLOAT;
2096     }
2097
2098   /* Handle base-switching prefixes 0x, 0t, 0d, 0 */
2099   if (p[0] == '0')
2100     switch (p[1])
2101       {
2102       case 'x':
2103       case 'X':
2104         if (len >= 3)
2105           {
2106             p += 2;
2107             base = 16;
2108             len -= 2;
2109           }
2110         break;
2111
2112       case 't':
2113       case 'T':
2114       case 'd':
2115       case 'D':
2116         if (len >= 3)
2117           {
2118             p += 2;
2119             base = 10;
2120             len -= 2;
2121           }
2122         break;
2123
2124       default:
2125         base = 8;
2126         break;
2127       }
2128
2129   while (len-- > 0)
2130     {
2131       c = *p++;
2132       if (c >= 'A' && c <= 'Z')
2133         c += 'a' - 'A';
2134       if (c != 'l' && c != 'u')
2135         n *= base;
2136       if (c >= '0' && c <= '9')
2137         n += i = c - '0';
2138       else
2139         {
2140           if (base > 10 && c >= 'a' && c <= 'f')
2141             n += i = c - 'a' + 10;
2142           else if (len == 0 && c == 'l')
2143             ;
2144           else if (len == 0 && c == 'u')
2145             unsigned_p = 1;
2146           else
2147             return ERROR;       /* Char not a digit */
2148         }
2149       if (i >= base)
2150         return ERROR;           /* Invalid digit in this base */
2151     }
2152
2153   if (unsigned_p)
2154     {
2155       putithere->ulval = n;
2156       return UINT;
2157     }
2158   else
2159     {
2160       putithere->lval = n;
2161       return INT;
2162     }
2163 }
2164
2165 struct token
2166 {
2167   char *operator;
2168   int token;
2169   enum exp_opcode opcode;
2170 };
2171
2172 const static struct token tokentab3[] =
2173   {
2174     {">>=", ASSIGN_MODIFY, BINOP_RSH},
2175     {"<<=", ASSIGN_MODIFY, BINOP_LSH}
2176   };
2177
2178 const static struct token tokentab2[] =
2179   {
2180     {"+=", ASSIGN_MODIFY, BINOP_ADD},
2181     {"-=", ASSIGN_MODIFY, BINOP_SUB},
2182     {"*=", ASSIGN_MODIFY, BINOP_MUL},
2183     {"/=", ASSIGN_MODIFY, BINOP_DIV},
2184     {"%=", ASSIGN_MODIFY, BINOP_REM},
2185     {"|=", ASSIGN_MODIFY, BINOP_LOGIOR},
2186     {"&=", ASSIGN_MODIFY, BINOP_LOGAND},
2187     {"^=", ASSIGN_MODIFY, BINOP_LOGXOR},
2188     {"++", INCREMENT, BINOP_END},
2189     {"--", DECREMENT, BINOP_END},
2190     {"->", ARROW, BINOP_END},
2191     {"&&", AND, BINOP_END},
2192     {"||", OR, BINOP_END},
2193     {"::", COLONCOLON, BINOP_END},
2194     {"<<", LSH, BINOP_END},
2195     {">>", RSH, BINOP_END},
2196     {"==", EQUAL, BINOP_END},
2197     {"!=", NOTEQUAL, BINOP_END},
2198     {"<=", LEQ, BINOP_END},
2199     {">=", GEQ, BINOP_END}
2200   };
2201
2202 /* assign machine-independent names to certain registers 
2203  * (unless overridden by the REGISTER_NAMES table)
2204  */
2205 struct std_regs {
2206         char *name;
2207         int regnum;
2208 } std_regs[] = {
2209 #ifdef PC_REGNUM
2210         { "pc", PC_REGNUM },
2211 #endif
2212 #ifdef FP_REGNUM
2213         { "fp", FP_REGNUM },
2214 #endif
2215 #ifdef SP_REGNUM
2216         { "sp", SP_REGNUM },
2217 #endif
2218 #ifdef PS_REGNUM
2219         { "ps", PS_REGNUM },
2220 #endif
2221 };
2222
2223 #define NUM_STD_REGS (sizeof std_regs / sizeof std_regs[0])
2224
2225 /* Read one token, getting characters through lexptr.  */
2226
2227 static int
2228 yylex ()
2229 {
2230   register int c;
2231   register int namelen;
2232   register unsigned i;
2233   register char *tokstart;
2234
2235  retry:
2236
2237   tokstart = lexptr;
2238   /* See if it is a special token of length 3.  */
2239   for (i = 0; i < sizeof tokentab3 / sizeof tokentab3[0]; i++)
2240     if (!strncmp (tokstart, tokentab3[i].operator, 3))
2241       {
2242         lexptr += 3;
2243         yylval.opcode = tokentab3[i].opcode;
2244         return tokentab3[i].token;
2245       }
2246
2247   /* See if it is a special token of length 2.  */
2248   for (i = 0; i < sizeof tokentab2 / sizeof tokentab2[0]; i++)
2249     if (!strncmp (tokstart, tokentab2[i].operator, 2))
2250       {
2251         lexptr += 2;
2252         yylval.opcode = tokentab2[i].opcode;
2253         return tokentab2[i].token;
2254       }
2255
2256   switch (c = *tokstart)
2257     {
2258     case 0:
2259       return 0;
2260
2261     case ' ':
2262     case '\t':
2263     case '\n':
2264       lexptr++;
2265       goto retry;
2266
2267     case '\'':
2268       lexptr++;
2269       c = *lexptr++;
2270       if (c == '\\')
2271         c = parse_escape (&lexptr);
2272       yylval.lval = c;
2273       c = *lexptr++;
2274       if (c != '\'')
2275         error ("Invalid character constant.");
2276       return CHAR;
2277
2278     case '(':
2279       paren_depth++;
2280       lexptr++;
2281       return c;
2282
2283     case ')':
2284       if (paren_depth == 0)
2285         return 0;
2286       paren_depth--;
2287       lexptr++;
2288       return c;
2289
2290     case ',':
2291       if (comma_terminates && paren_depth == 0)
2292         return 0;
2293       lexptr++;
2294       return c;
2295
2296     case '.':
2297       /* Might be a floating point number.  */
2298       if (lexptr[1] < '0' || lexptr[1] > '9')
2299         goto symbol;            /* Nope, must be a symbol. */
2300       /* FALL THRU into number case.  */
2301
2302     case '0':
2303     case '1':
2304     case '2':
2305     case '3':
2306     case '4':
2307     case '5':
2308     case '6':
2309     case '7':
2310     case '8':
2311     case '9':
2312       {
2313         /* It's a number.  */
2314         int got_dot = 0, got_e = 0, toktype;
2315         register char *p = tokstart;
2316         int hex = input_radix > 10;
2317
2318         if (c == '0' && (p[1] == 'x' || p[1] == 'X'))
2319           {
2320             p += 2;
2321             hex = 1;
2322           }
2323         else if (c == '0' && (p[1]=='t' || p[1]=='T' || p[1]=='d' || p[1]=='D'))
2324           {
2325             p += 2;
2326             hex = 0;
2327           }
2328
2329         for (;; ++p)
2330           {
2331             if (!hex && !got_e && (*p == 'e' || *p == 'E'))
2332               got_dot = got_e = 1;
2333             else if (!hex && !got_dot && *p == '.')
2334               got_dot = 1;
2335             else if (got_e && (p[-1] == 'e' || p[-1] == 'E')
2336                      && (*p == '-' || *p == '+'))
2337               /* This is the sign of the exponent, not the end of the
2338                  number.  */
2339               continue;
2340             /* We will take any letters or digits.  parse_number will
2341                complain if past the radix, or if L or U are not final.  */
2342             else if ((*p < '0' || *p > '9')
2343                      && ((*p < 'a' || *p > 'z')
2344                                   && (*p < 'A' || *p > 'Z')))
2345               break;
2346           }
2347         toktype = parse_number (tokstart, p - tokstart, got_dot|got_e, &yylval);
2348         if (toktype == ERROR)
2349           {
2350             char *err_copy = (char *) alloca (p - tokstart + 1);
2351
2352             bcopy (tokstart, err_copy, p - tokstart);
2353             err_copy[p - tokstart] = 0;
2354             error ("Invalid number \"%s\".", err_copy);
2355           }
2356         lexptr = p;
2357         return toktype;
2358       }
2359
2360     case '+':
2361     case '-':
2362     case '*':
2363     case '/':
2364     case '%':
2365     case '|':
2366     case '&':
2367     case '^':
2368     case '~':
2369     case '!':
2370     case '@':
2371     case '<':
2372     case '>':
2373     case '[':
2374     case ']':
2375     case '?':
2376     case ':':
2377     case '=':
2378     case '{':
2379     case '}':
2380     symbol:
2381       lexptr++;
2382       return c;
2383
2384     case '"':
2385       for (namelen = 1; (c = tokstart[namelen]) != '"'; namelen++)
2386         if (c == '\\')
2387           {
2388             c = tokstart[++namelen];
2389             if (c >= '0' && c <= '9')
2390               {
2391                 c = tokstart[++namelen];
2392                 if (c >= '0' && c <= '9')
2393                   c = tokstart[++namelen];
2394               }
2395           }
2396       yylval.sval.ptr = tokstart + 1;
2397       yylval.sval.length = namelen - 1;
2398       lexptr += namelen + 1;
2399       return STRING;
2400     }
2401
2402   if (!(c == '_' || c == '$'
2403         || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')))
2404     /* We must have come across a bad character (e.g. ';').  */
2405     error ("Invalid character '%c' in expression.", c);
2406
2407   /* It's a name.  See how long it is.  */
2408   namelen = 0;
2409   for (c = tokstart[namelen];
2410        (c == '_' || c == '$' || (c >= '0' && c <= '9')
2411         || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'));
2412        c = tokstart[++namelen])
2413     ;
2414
2415   /* The token "if" terminates the expression and is NOT 
2416      removed from the input stream.  */
2417   if (namelen == 2 && tokstart[0] == 'i' && tokstart[1] == 'f')
2418     {
2419       return 0;
2420     }
2421
2422   lexptr += namelen;
2423
2424   /* Handle the tokens $digits; also $ (short for $0) and $$ (short for $$1)
2425      and $$digits (equivalent to $<-digits> if you could type that).
2426      Make token type LAST, and put the number (the digits) in yylval.  */
2427
2428   if (*tokstart == '$')
2429     {
2430       register int negate = 0;
2431       c = 1;
2432       /* Double dollar means negate the number and add -1 as well.
2433          Thus $$ alone means -1.  */
2434       if (namelen >= 2 && tokstart[1] == '$')
2435         {
2436           negate = 1;
2437           c = 2;
2438         }
2439       if (c == namelen)
2440         {
2441           /* Just dollars (one or two) */
2442           yylval.lval = - negate;
2443           return LAST;
2444         }
2445       /* Is the rest of the token digits?  */
2446       for (; c < namelen; c++)
2447         if (!(tokstart[c] >= '0' && tokstart[c] <= '9'))
2448           break;
2449       if (c == namelen)
2450         {
2451           yylval.lval = atoi (tokstart + 1 + negate);
2452           if (negate)
2453             yylval.lval = - yylval.lval;
2454           return LAST;
2455         }
2456     }
2457
2458   /* Handle tokens that refer to machine registers:
2459      $ followed by a register name.  */
2460
2461   if (*tokstart == '$') {
2462     for (c = 0; c < NUM_REGS; c++)
2463       if (namelen - 1 == strlen (reg_names[c])
2464           && !strncmp (tokstart + 1, reg_names[c], namelen - 1))
2465         {
2466           yylval.lval = c;
2467           return REGNAME;
2468         }
2469     for (c = 0; c < NUM_STD_REGS; c++)
2470      if (namelen - 1 == strlen (std_regs[c].name)
2471          && !strncmp (tokstart + 1, std_regs[c].name, namelen - 1))
2472        {
2473          yylval.lval = std_regs[c].regnum;
2474          return REGNAME;
2475        }
2476   }
2477   /* Catch specific keywords.  Should be done with a data structure.  */
2478   switch (namelen)
2479     {
2480     case 8:
2481       if (!strncmp (tokstart, "unsigned", 8))
2482         return UNSIGNED;
2483       break;
2484     case 6:
2485       if (!strncmp (tokstart, "struct", 6))
2486         return STRUCT;
2487       if (!strncmp (tokstart, "signed", 6))
2488         return SIGNED;
2489       if (!strncmp (tokstart, "sizeof", 6))      
2490         return SIZEOF;
2491       break;
2492     case 5:
2493       if (!strncmp (tokstart, "union", 5))
2494         return UNION;
2495       if (!strncmp (tokstart, "short", 5))
2496         return SHORT;
2497       break;
2498     case 4:
2499       if (!strncmp (tokstart, "enum", 4))
2500         return ENUM;
2501       if (!strncmp (tokstart, "long", 4))
2502         return LONG;
2503       if (!strncmp (tokstart, "this", 4))
2504         {
2505           static const char this_name[] =
2506                                  { CPLUS_MARKER, 't', 'h', 'i', 's', '\0' };
2507
2508           if (lookup_symbol (this_name, expression_context_block,
2509                              VAR_NAMESPACE, 0, NULL))
2510             return THIS;
2511         }
2512       break;
2513     case 3:
2514       if (!strncmp (tokstart, "int", 3))
2515         return INT_KEYWORD;
2516       break;
2517     default:
2518       break;
2519     }
2520
2521   yylval.sval.ptr = tokstart;
2522   yylval.sval.length = namelen;
2523
2524   /* Any other names starting in $ are debugger internal variables.  */
2525
2526   if (*tokstart == '$')
2527     {
2528       yylval.ivar =  lookup_internalvar (copy_name (yylval.sval) + 1);
2529       return VARIABLE;
2530     }
2531
2532   /* Use token-type BLOCKNAME for symbols that happen to be defined as
2533      functions or symtabs.  If this is not so, then ...
2534      Use token-type TYPENAME for symbols that happen to be defined
2535      currently as names of types; NAME for other symbols.
2536      The caller is not constrained to care about the distinction.  */
2537   {
2538     char *tmp = copy_name (yylval.sval);
2539     struct symbol *sym;
2540     int is_a_field_of_this = 0;
2541     int hextype;
2542
2543     sym = lookup_symbol (tmp, expression_context_block,
2544                          VAR_NAMESPACE, &is_a_field_of_this, NULL);
2545     if ((sym && SYMBOL_CLASS (sym) == LOC_BLOCK) ||
2546         lookup_partial_symtab (tmp))
2547       {
2548         yylval.ssym.sym = sym;
2549         yylval.ssym.is_a_field_of_this = is_a_field_of_this;
2550         return BLOCKNAME;
2551       }
2552     if (sym && SYMBOL_CLASS (sym) == LOC_TYPEDEF)
2553         {
2554           yylval.tsym.type = SYMBOL_TYPE (sym);
2555           return TYPENAME;
2556         }
2557     if ((yylval.tsym.type = lookup_primitive_typename (tmp)) != 0)
2558         return TYPENAME;
2559
2560     /* Input names that aren't symbols but ARE valid hex numbers,
2561        when the input radix permits them, can be names or numbers
2562        depending on the parse.  Note we support radixes > 16 here.  */
2563     if (!sym && 
2564         ((tokstart[0] >= 'a' && tokstart[0] < 'a' + input_radix - 10) ||
2565          (tokstart[0] >= 'A' && tokstart[0] < 'A' + input_radix - 10)))
2566       {
2567         YYSTYPE newlval;        /* Its value is ignored.  */
2568         hextype = parse_number (tokstart, namelen, 0, &newlval);
2569         if (hextype == INT)
2570           {
2571             yylval.ssym.sym = sym;
2572             yylval.ssym.is_a_field_of_this = is_a_field_of_this;
2573             return NAME_OR_INT;
2574           }
2575         if (hextype == UINT)
2576           {
2577             yylval.ssym.sym = sym;
2578             yylval.ssym.is_a_field_of_this = is_a_field_of_this;
2579             return NAME_OR_UINT;
2580           }
2581       }
2582
2583     /* Any other kind of symbol */
2584     yylval.ssym.sym = sym;
2585     yylval.ssym.is_a_field_of_this = is_a_field_of_this;
2586     return NAME;
2587   }
2588 }
2589
2590 static void
2591 yyerror (msg)
2592      char *msg;
2593 {
2594   error ("Invalid syntax in expression.");
2595 }
2596
2597 /* Return a null-terminated temporary copy of the name
2598    of a string token.  */
2599
2600 static char *
2601 copy_name (token)
2602      struct stoken token;
2603 {
2604   bcopy (token.ptr, namecopy, token.length);
2605   namecopy[token.length] = 0;
2606   return namecopy;
2607 }
2608 \f
2609 /* Reverse an expression from suffix form (in which it is constructed)
2610    to prefix form (in which we can conveniently print or execute it).  */
2611
2612 static void prefixify_subexp ();
2613
2614 static void
2615 prefixify_expression (expr)
2616      register struct expression *expr;
2617 {
2618   register int len = sizeof (struct expression) +
2619                                     expr->nelts * sizeof (union exp_element);
2620   register struct expression *temp;
2621   register int inpos = expr->nelts, outpos = 0;
2622
2623   temp = (struct expression *) alloca (len);
2624
2625   /* Copy the original expression into temp.  */
2626   bcopy (expr, temp, len);
2627
2628   prefixify_subexp (temp, expr, inpos, outpos);
2629 }
2630
2631 /* Return the number of exp_elements in the subexpression of EXPR
2632    whose last exp_element is at index ENDPOS - 1 in EXPR.  */
2633
2634 static int
2635 length_of_subexp (expr, endpos)
2636      register struct expression *expr;
2637      register int endpos;
2638 {
2639   register int oplen = 1;
2640   register int args = 0;
2641   register int i;
2642
2643   if (endpos < 0)
2644     error ("?error in length_of_subexp");
2645
2646   i = (int) expr->elts[endpos - 1].opcode;
2647
2648   switch (i)
2649     {
2650       /* C++  */
2651     case OP_SCOPE:
2652       oplen = 4 + ((expr->elts[endpos - 2].longconst
2653                     + sizeof (union exp_element))
2654                    / sizeof (union exp_element));
2655       break;
2656
2657     case OP_LONG:
2658     case OP_DOUBLE:
2659       oplen = 4;
2660       break;
2661
2662     case OP_VAR_VALUE:
2663     case OP_LAST:
2664     case OP_REGISTER:
2665     case OP_INTERNALVAR:
2666       oplen = 3;
2667       break;
2668
2669     case OP_FUNCALL:
2670       oplen = 3;
2671       args = 1 + expr->elts[endpos - 2].longconst;
2672       break;
2673
2674     case UNOP_CAST:
2675     case UNOP_MEMVAL:
2676       oplen = 3;
2677       args = 1;
2678       break;
2679
2680     case STRUCTOP_STRUCT:
2681     case STRUCTOP_PTR:
2682       args = 1;
2683     case OP_STRING:
2684       oplen = 3 + ((expr->elts[endpos - 2].longconst
2685                     + sizeof (union exp_element))
2686                    / sizeof (union exp_element));
2687       break;
2688
2689     case TERNOP_COND:
2690       args = 3;
2691       break;
2692
2693     case BINOP_ASSIGN_MODIFY:
2694       oplen = 3;
2695       args = 2;
2696       break;
2697
2698       /* C++ */
2699     case OP_THIS:
2700       oplen = 2;
2701       break;
2702
2703     default:
2704       args = 1 + (i < (int) BINOP_END);
2705     }
2706
2707   while (args > 0)
2708     {
2709       oplen += length_of_subexp (expr, endpos - oplen);
2710       args--;
2711     }
2712
2713   return oplen;
2714 }
2715
2716 /* Copy the subexpression ending just before index INEND in INEXPR
2717    into OUTEXPR, starting at index OUTBEG.
2718    In the process, convert it from suffix to prefix form.  */
2719
2720 static void
2721 prefixify_subexp (inexpr, outexpr, inend, outbeg)
2722      register struct expression *inexpr;
2723      struct expression *outexpr;
2724      register int inend;
2725      int outbeg;
2726 {
2727   register int oplen = 1;
2728   register int args = 0;
2729   register int i;
2730   int *arglens;
2731   enum exp_opcode opcode;
2732
2733   /* Compute how long the last operation is (in OPLEN),
2734      and also how many preceding subexpressions serve as
2735      arguments for it (in ARGS).  */
2736
2737   opcode = inexpr->elts[inend - 1].opcode;
2738   switch (opcode)
2739     {
2740       /* C++  */
2741     case OP_SCOPE:
2742       oplen = 4 + ((inexpr->elts[inend - 2].longconst
2743                     + sizeof (union exp_element))
2744                    / sizeof (union exp_element));
2745       break;
2746
2747     case OP_LONG:
2748     case OP_DOUBLE:
2749       oplen = 4;
2750       break;
2751
2752     case OP_VAR_VALUE:
2753     case OP_LAST:
2754     case OP_REGISTER:
2755     case OP_INTERNALVAR:
2756       oplen = 3;
2757       break;
2758
2759     case OP_FUNCALL:
2760       oplen = 3;
2761       args = 1 + inexpr->elts[inend - 2].longconst;
2762       break;
2763
2764     case UNOP_CAST:
2765     case UNOP_MEMVAL:
2766       oplen = 3;
2767       args = 1;
2768       break;
2769
2770     case STRUCTOP_STRUCT:
2771     case STRUCTOP_PTR:
2772       args = 1;
2773     case OP_STRING:
2774       oplen = 3 + ((inexpr->elts[inend - 2].longconst
2775                     + sizeof (union exp_element))
2776                    / sizeof (union exp_element));
2777                    
2778       break;
2779
2780     case TERNOP_COND:
2781       args = 3;
2782       break;
2783
2784     case BINOP_ASSIGN_MODIFY:
2785       oplen = 3;
2786       args = 2;
2787       break;
2788
2789       /* C++ */
2790     case OP_THIS:
2791       oplen = 2;
2792       break;
2793
2794     default:
2795       args = 1 + ((int) opcode < (int) BINOP_END);
2796     }
2797
2798   /* Copy the final operator itself, from the end of the input
2799      to the beginning of the output.  */
2800   inend -= oplen;
2801   bcopy (&inexpr->elts[inend], &outexpr->elts[outbeg],
2802          oplen * sizeof (union exp_element));
2803   outbeg += oplen;
2804
2805   /* Find the lengths of the arg subexpressions.  */
2806   arglens = (int *) alloca (args * sizeof (int));
2807   for (i = args - 1; i >= 0; i--)
2808     {
2809       oplen = length_of_subexp (inexpr, inend);
2810       arglens[i] = oplen;
2811       inend -= oplen;
2812     }
2813
2814   /* Now copy each subexpression, preserving the order of
2815      the subexpressions, but prefixifying each one.
2816      In this loop, inend starts at the beginning of
2817      the expression this level is working on
2818      and marches forward over the arguments.
2819      outbeg does similarly in the output.  */
2820   for (i = 0; i < args; i++)
2821     {
2822       oplen = arglens[i];
2823       inend += oplen;
2824       prefixify_subexp (inexpr, outexpr, inend, outbeg);
2825       outbeg += oplen;
2826     }
2827 }
2828 \f
2829 /* This page contains the two entry points to this file.  */
2830
2831 /* Read a C expression from the string *STRINGPTR points to,
2832    parse it, and return a pointer to a  struct expression  that we malloc.
2833    Use block BLOCK as the lexical context for variable names;
2834    if BLOCK is zero, use the block of the selected stack frame.
2835    Meanwhile, advance *STRINGPTR to point after the expression,
2836    at the first nonwhite character that is not part of the expression
2837    (possibly a null character).
2838
2839    If COMMA is nonzero, stop if a comma is reached.  */
2840
2841 struct expression *
2842 parse_c_1 (stringptr, block, comma)
2843      char **stringptr;
2844      struct block *block;
2845      int comma;
2846 {
2847   struct cleanup *old_chain;
2848
2849   lexptr = *stringptr;
2850
2851   paren_depth = 0;
2852   type_stack_depth = 0;
2853
2854   comma_terminates = comma;
2855
2856   if (lexptr == 0 || *lexptr == 0)
2857     error_no_arg ("expression to compute");
2858
2859   old_chain = make_cleanup (free_funcalls, 0);
2860   funcall_chain = 0;
2861
2862   expression_context_block = block ? block : get_selected_block ();
2863
2864   namecopy = (char *) alloca (strlen (lexptr) + 1);
2865   expout_size = 10;
2866   expout_ptr = 0;
2867   expout = (struct expression *)
2868     xmalloc (sizeof (struct expression)
2869              + expout_size * sizeof (union exp_element));
2870   make_cleanup (free_current_contents, &expout);
2871   if (yyparse ())
2872     yyerror (NULL);
2873   discard_cleanups (old_chain);
2874   expout->nelts = expout_ptr;
2875   expout = (struct expression *)
2876     xrealloc (expout,
2877               sizeof (struct expression)
2878               + expout_ptr * sizeof (union exp_element));
2879   prefixify_expression (expout);
2880   *stringptr = lexptr;
2881   return expout;
2882 }
2883
2884 /* Parse STRING as an expression, and complain if this fails
2885    to use up all of the contents of STRING.  */
2886
2887 struct expression *
2888 parse_c_expression (string)
2889      char *string;
2890 {
2891   register struct expression *exp;
2892   exp = parse_c_1 (&string, 0, 0);
2893   if (*string)
2894     error ("Junk after end of expression.");
2895   return exp;
2896 }
2897
2898 static void 
2899 push_type (tp)
2900      enum type_pieces tp;
2901 {
2902   if (type_stack_depth == type_stack_size)
2903     {
2904       type_stack_size *= 2;
2905       type_stack = (union type_stack_elt *)
2906         xrealloc (type_stack, type_stack_size * sizeof (*type_stack));
2907     }
2908   type_stack[type_stack_depth++].piece = tp;
2909 }
2910
2911 static void
2912 push_type_int (n)
2913      int n;
2914 {
2915   if (type_stack_depth == type_stack_size)
2916     {
2917       type_stack_size *= 2;
2918       type_stack = (union type_stack_elt *)
2919         xrealloc (type_stack, type_stack_size * sizeof (*type_stack));
2920     }
2921   type_stack[type_stack_depth++].int_val = n;
2922 }
2923
2924 static enum type_pieces 
2925 pop_type ()
2926 {
2927   if (type_stack_depth)
2928     return type_stack[--type_stack_depth].piece;
2929   return tp_end;
2930 }
2931
2932 static int
2933 pop_type_int ()
2934 {
2935   if (type_stack_depth)
2936     return type_stack[--type_stack_depth].int_val;
2937   /* "Can't happen".  */
2938   return 0;
2939 }
2940
2941 void
2942 _initialize_expread ()
2943 {
2944   type_stack_size = 80;
2945   type_stack_depth = 0;
2946   type_stack = (union type_stack_elt *)
2947     xmalloc (type_stack_size * sizeof (*type_stack));
2948 }
This page took 0.190833 seconds and 4 git commands to generate.