2 /* A Bison parser, made from ./expread.y */
12 #define NAME_OR_INT 266
13 #define NAME_OR_UINT 267
19 #define COLONCOLON 273
24 #define INT_KEYWORD 278
28 #define ASSIGN_MODIFY 282
30 #define ABOVE_COMMA 284
44 #line 29 "./expread.y"
51 #include "expression.h"
55 static struct expression *expout;
56 static int expout_size;
57 static int expout_ptr;
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 ();
75 /* If this is nonzero, this block is used as the lexical context
78 static struct block *expression_context_block;
80 /* The innermost context required by the stack and register variables
81 we've encountered so far. */
82 struct block *innermost_block;
84 /* The block in which the most recently discovered symbol was found. */
85 struct block *block_found;
87 /* Number of arguments seen so far in innermost function call. */
88 static int arglist_len;
90 /* Data structure for saving values of arglist_len
91 for function calls whose arguments contain other function calls. */
99 struct funcall *funcall_chain;
101 /* This kind of datum is used to represent the name
102 of a symbol token. */
112 struct stoken stoken;
118 struct stoken stoken;
120 int is_a_field_of_this;
123 /* For parsing of complicated types.
124 An array should be preceded in the list by the size of the array. */
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;
132 static union type_stack_elt *type_stack;
133 static int type_stack_depth, type_stack_size;
135 static void push_type ();
136 static void push_type_int ();
137 static enum type_pieces pop_type ();
138 static int pop_type_int ();
140 /* Allow debugging of parsing. */
143 #line 132 "./expread.y"
147 unsigned LONGEST ulval;
153 struct symtoken ssym;
156 enum exp_opcode opcode;
157 struct internalvar *ivar;
176 #define YYLTYPE yyltype
188 #define YYFLAG -32768
191 #define YYTRANSLATE(x) ((unsigned)(x) <= 296 ? yytranslate[x] : 84)
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
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
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
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, 742, 743,
292 778, 780, 782, 784, 786, 789, 791, 796, 802, 804,
293 808, 810, 814, 818, 819, 821, 823, 826, 833, 835,
294 837, 839, 841, 843, 845, 847, 849, 851, 853, 855,
295 857, 860, 863, 866, 868, 870, 872, 876, 877, 883,
296 889, 898, 903, 910, 911, 912, 913, 914, 917, 918
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",""
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
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
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
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
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
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
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
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
525 /* -*-C-*- Note some compilers choke on comments on `#line' lines. */
526 #line 3 "/usr/unsupported/lib/bison.simple"
528 /* Skeleton output parser for bison,
529 Copyright (C) 1984, 1989, 1990 Bob Corbett and Richard Stallman
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 2 of the License, or
534 (at your option) any later version.
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.
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. */
548 #define alloca __builtin_alloca
549 #else /* Not GNU C. */
550 #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__)
552 #else /* Not sparc */
556 #endif /* Not sparc. */
557 #endif /* Not GNU C. */
558 #endif /* alloca not defined. */
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. */
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. */
569 #define yyerrok (yyerrstatus = 0)
570 #define yyclearin (yychar = YYEMPTY)
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) \
584 if (yychar == YYEMPTY && yylen == 1) \
585 { yychar = (token), yylval = (value); \
586 yychar1 = YYTRANSLATE (yychar); \
591 { yyerror ("syntax error: cannot back up"); YYERROR; } \
595 #define YYERRCODE 256
598 #define YYLEX yylex()
603 #define YYLEX yylex(&yylval, &yylloc)
605 #define YYLEX yylex(&yylval)
609 /* If nonreentrant, generate the variables here */
613 int yychar; /* the lookahead symbol */
614 YYSTYPE yylval; /* the semantic value of the */
615 /* lookahead symbol */
618 YYLTYPE yylloc; /* location data for the lookahead */
622 int yynerrs; /* number of parse errors so far */
623 #endif /* not YYPURE */
626 int yydebug; /* nonzero means print parse trace */
627 /* Since this is uninitialized, it does not stop multiple parsers
631 /* YYINITDEPTH indicates the initial size of the parser's stacks */
634 #define YYINITDEPTH 200
637 /* YYMAXDEPTH is the maximum size the stacks can grow to
638 (effective only if the built-in stack extension method is used). */
645 #define YYMAXDEPTH 10000
650 /* This is the most reliable way to avoid incompatibilities
651 in available built-in functions on various systems. */
653 __yy_bcopy (from, to, count)
658 register char *f = from;
659 register char *t = to;
660 register int i = count;
666 #else /* __cplusplus */
668 /* This is the most reliable way to avoid incompatibilities
669 in available built-in functions on various systems. */
671 __yy_bcopy (char *from, char *to, int count)
673 register char *f = from;
674 register char *t = to;
675 register int i = count;
683 #line 160 "/usr/unsupported/lib/bison.simple"
687 register int yystate;
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 */
694 short yyssa[YYINITDEPTH]; /* the state stack */
695 YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
697 short *yyss = yyssa; /* refer to the stacks thru separate pointers */
698 YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
701 YYLTYPE *yyls = yylsa;
703 YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
705 #define YYPOPSTACK (yyvsp--, yysp--, yylsp--)
707 #define YYPOPSTACK (yyvsp--, yysp--)
710 int yystacksize = YYINITDEPTH;
721 YYSTYPE yyval; /* the variable used to return */
722 /* semantic values from the action */
729 fprintf(stderr, "Starting parse\n");
735 yychar = YYEMPTY; /* Cause a token to be read. */
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. */
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. */
754 if (yyssp >= yyss + yystacksize - 1)
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;
761 YYLTYPE *yyls1 = yyls;
764 /* Get the current used size of the three stacks, in elements. */
765 int size = yyssp - yyss + 1;
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),
774 &yyls1, size * sizeof (*yylsp),
778 yyss = yyss1; yyvs = yyvs1;
782 #else /* no yyoverflow */
783 /* Extend the stack our own way. */
784 if (yystacksize >= YYMAXDEPTH)
786 yyerror("parser stack overflow");
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));
797 yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp));
798 __yy_bcopy ((char *)yyls1, (char *)yyls, size * sizeof (*yylsp));
800 #endif /* no yyoverflow */
802 yyssp = yyss + size - 1;
803 yyvsp = yyvs + size - 1;
805 yylsp = yyls + size - 1;
810 fprintf(stderr, "Stack size increased to %d\n", yystacksize);
813 if (yyssp >= yyss + yystacksize - 1)
819 fprintf(stderr, "Entering state %d\n", yystate);
824 /* Do appropriate processing given the current state. */
825 /* Read a lookahead token if we need one and don't already have one. */
828 /* First try to decide what to do without reference to lookahead token. */
830 yyn = yypact[yystate];
834 /* Not known => get a lookahead token if don't already have one. */
836 /* yychar is either YYEMPTY or YYEOF
837 or a valid token in external form. */
839 if (yychar == YYEMPTY)
843 fprintf(stderr, "Reading a token: ");
848 /* Convert token to internal form (in yychar1) for indexing tables with */
850 if (yychar <= 0) /* This means end of input. */
853 yychar = YYEOF; /* Don't call YYLEX any more */
857 fprintf(stderr, "Now at end of input.\n");
862 yychar1 = YYTRANSLATE(yychar);
866 fprintf(stderr, "Next token is %d (%s)\n", yychar, yytname[yychar1]);
871 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
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,
881 0, or most negative number => error. */
896 /* Shift the lookahead token. */
900 fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
903 /* Discard the token being shifted unless it is eof. */
912 /* count tokens shifted since error; after three, turn off error status. */
913 if (yyerrstatus) yyerrstatus--;
918 /* Do the default action for the current state. */
921 yyn = yydefact[yystate];
925 /* Do a reduction. yyn is the number of a rule to reduce with. */
928 yyval = yyvsp[1-yylen]; /* implement default value of the action */
935 fprintf (stderr, "Reducing via rule %d (line %d), ",
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]]);
949 #line 231 "./expread.y"
950 { write_exp_elt_opcode (BINOP_COMMA); ;
953 #line 236 "./expread.y"
954 { write_exp_elt_opcode (UNOP_IND); ;
957 #line 239 "./expread.y"
958 { write_exp_elt_opcode (UNOP_ADDR); ;
961 #line 242 "./expread.y"
962 { write_exp_elt_opcode (UNOP_NEG); ;
965 #line 246 "./expread.y"
966 { write_exp_elt_opcode (UNOP_ZEROP); ;
969 #line 250 "./expread.y"
970 { write_exp_elt_opcode (UNOP_LOGNOT); ;
973 #line 254 "./expread.y"
974 { write_exp_elt_opcode (UNOP_PREINCREMENT); ;
977 #line 258 "./expread.y"
978 { write_exp_elt_opcode (UNOP_PREDECREMENT); ;
981 #line 262 "./expread.y"
982 { write_exp_elt_opcode (UNOP_POSTINCREMENT); ;
985 #line 266 "./expread.y"
986 { write_exp_elt_opcode (UNOP_POSTDECREMENT); ;
989 #line 270 "./expread.y"
990 { write_exp_elt_opcode (UNOP_SIZEOF); ;
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); ;
999 #line 280 "./expread.y"
1000 { write_exp_elt_opcode (STRUCTOP_MPTR); ;
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); ;
1009 #line 290 "./expread.y"
1010 { write_exp_elt_opcode (STRUCTOP_MEMBER); ;
1013 #line 294 "./expread.y"
1014 { write_exp_elt_opcode (BINOP_SUBSCRIPT); ;
1017 #line 300 "./expread.y"
1018 { start_arglist (); ;
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); ;
1027 #line 311 "./expread.y"
1028 { arglist_len = 1; ;
1031 #line 315 "./expread.y"
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); ;
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); ;
1047 #line 331 "./expread.y"
1051 #line 337 "./expread.y"
1052 { write_exp_elt_opcode (BINOP_REPEAT); ;
1055 #line 341 "./expread.y"
1056 { write_exp_elt_opcode (BINOP_MUL); ;
1059 #line 345 "./expread.y"
1060 { write_exp_elt_opcode (BINOP_DIV); ;
1063 #line 349 "./expread.y"
1064 { write_exp_elt_opcode (BINOP_REM); ;
1067 #line 353 "./expread.y"
1068 { write_exp_elt_opcode (BINOP_ADD); ;
1071 #line 357 "./expread.y"
1072 { write_exp_elt_opcode (BINOP_SUB); ;
1075 #line 361 "./expread.y"
1076 { write_exp_elt_opcode (BINOP_LSH); ;
1079 #line 365 "./expread.y"
1080 { write_exp_elt_opcode (BINOP_RSH); ;
1083 #line 369 "./expread.y"
1084 { write_exp_elt_opcode (BINOP_EQUAL); ;
1087 #line 373 "./expread.y"
1088 { write_exp_elt_opcode (BINOP_NOTEQUAL); ;
1091 #line 377 "./expread.y"
1092 { write_exp_elt_opcode (BINOP_LEQ); ;
1095 #line 381 "./expread.y"
1096 { write_exp_elt_opcode (BINOP_GEQ); ;
1099 #line 385 "./expread.y"
1100 { write_exp_elt_opcode (BINOP_LESS); ;
1103 #line 389 "./expread.y"
1104 { write_exp_elt_opcode (BINOP_GTR); ;
1107 #line 393 "./expread.y"
1108 { write_exp_elt_opcode (BINOP_LOGAND); ;
1111 #line 397 "./expread.y"
1112 { write_exp_elt_opcode (BINOP_LOGXOR); ;
1115 #line 401 "./expread.y"
1116 { write_exp_elt_opcode (BINOP_LOGIOR); ;
1119 #line 405 "./expread.y"
1120 { write_exp_elt_opcode (BINOP_AND); ;
1123 #line 409 "./expread.y"
1124 { write_exp_elt_opcode (BINOP_OR); ;
1127 #line 413 "./expread.y"
1128 { write_exp_elt_opcode (TERNOP_COND); ;
1131 #line 417 "./expread.y"
1132 { write_exp_elt_opcode (BINOP_ASSIGN); ;
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); ;
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);
1146 write_exp_elt_type (BUILTIN_TYPE_LONGEST);
1147 write_exp_elt_longcst ((LONGEST) yyvsp[0].lval);
1148 write_exp_elt_opcode (OP_LONG); ;
1151 #line 437 "./expread.y"
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);
1159 write_exp_elt_type (BUILTIN_TYPE_LONGEST);
1160 write_exp_elt_longcst (val.lval);
1161 write_exp_elt_opcode (OP_LONG); ;
1164 #line 450 "./expread.y"
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);
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);
1176 #line 462 "./expread.y"
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);
1183 write_exp_elt_type (BUILTIN_TYPE_UNSIGNED_LONGEST);
1184 write_exp_elt_longcst ((LONGEST)val.ulval);
1185 write_exp_elt_opcode (OP_LONG);
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); ;
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); ;
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); ;
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); ;
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); ;
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); ;
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); ;
1234 #line 524 "./expread.y"
1235 { write_exp_elt_opcode (OP_THIS);
1236 write_exp_elt_opcode (OP_THIS); ;
1239 #line 531 "./expread.y"
1241 if (yyvsp[0].ssym.sym != 0)
1242 yyval.bval = SYMBOL_BLOCK_VALUE (yyvsp[0].ssym.sym);
1245 struct symtab *tem =
1246 lookup_symtab (copy_name (yyvsp[0].ssym.stoken));
1248 yyval.bval = BLOCKVECTOR_BLOCK
1249 (BLOCKVECTOR (tem), STATIC_BLOCK);
1251 error ("No file or function \"%s\".",
1252 copy_name (yyvsp[0].ssym.stoken));
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); ;
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);
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); ;
1279 #line 571 "./expread.y"
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.",
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);
1294 #line 584 "./expread.y"
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.",
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);
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);
1314 #line 602 "./expread.y"
1316 char *name = copy_name (yyvsp[0].sval);
1321 lookup_symbol (name, 0, VAR_NAMESPACE, 0, NULL);
1324 write_exp_elt_opcode (OP_VAR_VALUE);
1325 write_exp_elt_sym (sym);
1326 write_exp_elt_opcode (OP_VAR_VALUE);
1329 for (i = 0; i < misc_function_count; i++)
1330 if (!strcmp (misc_function_vector[i].name, name))
1333 if (i < misc_function_count)
1335 enum misc_function_type mft =
1336 misc_function_vector[i].type;
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));
1348 write_exp_elt_type (builtin_type_char);
1349 write_exp_elt_opcode (UNOP_MEMVAL);
1352 if (symtab_list == 0
1353 && partial_symtab_list == 0)
1354 error ("No symbol table is loaded. Use the \"file\" command.");
1356 error ("No symbol \"%s\" in current context.", name);
1360 #line 648 "./expread.y"
1361 { struct symbol *sym = yyvsp[0].ssym.sym;
1373 if (innermost_block == 0 ||
1374 contained_in (block_found,
1376 innermost_block = block_found;
1384 case LOC_CONST_BYTES:
1386 /* In this case the expression can
1387 be evaluated regardless of what
1388 frame we are in, so there is no
1389 need to check for the
1390 innermost_block. These cases are
1391 listed so that gcc -Wall will
1392 report types that may not have
1397 write_exp_elt_opcode (OP_VAR_VALUE);
1398 write_exp_elt_sym (sym);
1399 write_exp_elt_opcode (OP_VAR_VALUE);
1401 else if (yyvsp[0].ssym.is_a_field_of_this)
1403 /* C++: it hangs off of `this'. Must
1404 not inadvertently convert from a method call
1406 if (innermost_block == 0 ||
1407 contained_in (block_found, innermost_block))
1408 innermost_block = block_found;
1409 write_exp_elt_opcode (OP_THIS);
1410 write_exp_elt_opcode (OP_THIS);
1411 write_exp_elt_opcode (STRUCTOP_PTR);
1412 write_exp_string (yyvsp[0].ssym.stoken);
1413 write_exp_elt_opcode (STRUCTOP_PTR);
1418 register char *arg = copy_name (yyvsp[0].ssym.stoken);
1420 /* FIXME, this search is linear! At least
1421 optimize the strcmp with a 1-char cmp... */
1422 for (i = 0; i < misc_function_count; i++)
1423 if (!strcmp (misc_function_vector[i].name, arg))
1426 if (i < misc_function_count)
1428 enum misc_function_type mft =
1429 misc_function_vector[i].type;
1431 write_exp_elt_opcode (OP_LONG);
1432 write_exp_elt_type (builtin_type_int);
1433 write_exp_elt_longcst ((LONGEST) misc_function_vector[i].address);
1434 write_exp_elt_opcode (OP_LONG);
1435 write_exp_elt_opcode (UNOP_MEMVAL);
1436 if (mft == mf_data || mft == mf_bss)
1437 write_exp_elt_type (builtin_type_int);
1438 else if (mft == mf_text)
1439 write_exp_elt_type (lookup_function_type (builtin_type_int));
1441 write_exp_elt_type (builtin_type_char);
1442 write_exp_elt_opcode (UNOP_MEMVAL);
1444 else if (symtab_list == 0
1445 && partial_symtab_list == 0)
1446 error ("No symbol table is loaded. Use the \"file\" command.");
1448 error ("No symbol \"%s\" in current context.",
1449 copy_name (yyvsp[0].ssym.stoken));
1454 #line 744 "./expread.y"
1456 /* This is where the interesting stuff happens. */
1459 struct type *follow_type = yyvsp[-1].tval;
1462 switch (pop_type ())
1468 follow_type = lookup_pointer_type (follow_type);
1471 follow_type = lookup_reference_type (follow_type);
1474 array_size = pop_type_int ();
1475 if (array_size != -1)
1476 follow_type = create_array_type (follow_type,
1479 follow_type = lookup_pointer_type (follow_type);
1482 follow_type = lookup_function_type (follow_type);
1485 yyval.tval = follow_type;
1489 #line 779 "./expread.y"
1490 { push_type (tp_pointer); yyval.voidval = 0; ;
1493 #line 781 "./expread.y"
1494 { push_type (tp_pointer); yyval.voidval = yyvsp[0].voidval; ;
1497 #line 783 "./expread.y"
1498 { push_type (tp_reference); yyval.voidval = 0; ;
1501 #line 785 "./expread.y"
1502 { push_type (tp_reference); yyval.voidval = yyvsp[0].voidval; ;
1505 #line 790 "./expread.y"
1506 { yyval.voidval = yyvsp[-1].voidval; ;
1509 #line 792 "./expread.y"
1511 push_type_int (yyvsp[0].lval);
1512 push_type (tp_array);
1516 #line 797 "./expread.y"
1518 push_type_int (yyvsp[0].lval);
1519 push_type (tp_array);
1524 #line 803 "./expread.y"
1525 { push_type (tp_function); ;
1528 #line 805 "./expread.y"
1529 { push_type (tp_function); ;
1532 #line 809 "./expread.y"
1533 { yyval.lval = -1; ;
1536 #line 811 "./expread.y"
1537 { yyval.lval = yyvsp[-1].lval; ;
1540 #line 815 "./expread.y"
1541 { yyval.voidval = 0; ;
1544 #line 820 "./expread.y"
1545 { yyval.tval = lookup_member_type (builtin_type_int, yyvsp[-2].tval); ;
1548 #line 822 "./expread.y"
1549 { yyval.tval = lookup_member_type (yyvsp[-5].tval, yyvsp[-3].tval); ;
1552 #line 824 "./expread.y"
1553 { yyval.tval = lookup_member_type
1554 (lookup_function_type (yyvsp[-7].tval), yyvsp[-5].tval); ;
1557 #line 827 "./expread.y"
1558 { yyval.tval = lookup_member_type
1559 (lookup_function_type (yyvsp[-8].tval), yyvsp[-6].tval);
1560 free (yyvsp[-1].tvec); ;
1563 #line 834 "./expread.y"
1564 { yyval.tval = yyvsp[0].tsym.type; ;
1567 #line 836 "./expread.y"
1568 { yyval.tval = builtin_type_int; ;
1571 #line 838 "./expread.y"
1572 { yyval.tval = builtin_type_long; ;
1575 #line 840 "./expread.y"
1576 { yyval.tval = builtin_type_short; ;
1579 #line 842 "./expread.y"
1580 { yyval.tval = builtin_type_long; ;
1583 #line 844 "./expread.y"
1584 { yyval.tval = builtin_type_unsigned_long; ;
1587 #line 846 "./expread.y"
1588 { yyval.tval = builtin_type_long_long; ;
1591 #line 848 "./expread.y"
1592 { yyval.tval = builtin_type_long_long; ;
1595 #line 850 "./expread.y"
1596 { yyval.tval = builtin_type_unsigned_long_long; ;
1599 #line 852 "./expread.y"
1600 { yyval.tval = builtin_type_unsigned_long_long; ;
1603 #line 854 "./expread.y"
1604 { yyval.tval = builtin_type_short; ;
1607 #line 856 "./expread.y"
1608 { yyval.tval = builtin_type_unsigned_short; ;
1611 #line 858 "./expread.y"
1612 { yyval.tval = lookup_struct (copy_name (yyvsp[0].sval),
1613 expression_context_block); ;
1616 #line 861 "./expread.y"
1617 { yyval.tval = lookup_union (copy_name (yyvsp[0].sval),
1618 expression_context_block); ;
1621 #line 864 "./expread.y"
1622 { yyval.tval = lookup_enum (copy_name (yyvsp[0].sval),
1623 expression_context_block); ;
1626 #line 867 "./expread.y"
1627 { yyval.tval = lookup_unsigned_typename (TYPE_NAME(yyvsp[0].tsym.type)); ;
1630 #line 869 "./expread.y"
1631 { yyval.tval = builtin_type_unsigned_int; ;
1634 #line 871 "./expread.y"
1635 { yyval.tval = yyvsp[0].tsym.type; ;
1638 #line 873 "./expread.y"
1639 { yyval.tval = builtin_type_int; ;
1642 #line 878 "./expread.y"
1644 yyval.tsym.stoken.ptr = "int";
1645 yyval.tsym.stoken.length = 3;
1646 yyval.tsym.type = builtin_type_int;
1650 #line 884 "./expread.y"
1652 yyval.tsym.stoken.ptr = "long";
1653 yyval.tsym.stoken.length = 4;
1654 yyval.tsym.type = builtin_type_long;
1658 #line 890 "./expread.y"
1660 yyval.tsym.stoken.ptr = "short";
1661 yyval.tsym.stoken.length = 5;
1662 yyval.tsym.type = builtin_type_short;
1666 #line 899 "./expread.y"
1667 { yyval.tvec = (struct type **)xmalloc (sizeof (struct type *) * 2);
1668 yyval.tvec[0] = (struct type *)0;
1669 yyval.tvec[1] = yyvsp[0].tval;
1673 #line 904 "./expread.y"
1674 { int len = sizeof (struct type *) * ++(yyvsp[-2].ivec[0]);
1675 yyval.tvec = (struct type **)xrealloc (yyvsp[-2].tvec, len);
1676 yyval.tvec[yyval.ivec[0]] = yyvsp[0].tval;
1680 #line 910 "./expread.y"
1681 { yyval.sval = yyvsp[0].ssym.stoken; ;
1684 #line 911 "./expread.y"
1685 { yyval.sval = yyvsp[0].ssym.stoken; ;
1688 #line 912 "./expread.y"
1689 { yyval.sval = yyvsp[0].tsym.stoken; ;
1692 #line 913 "./expread.y"
1693 { yyval.sval = yyvsp[0].ssym.stoken; ;
1696 #line 914 "./expread.y"
1697 { yyval.sval = yyvsp[0].ssym.stoken; ;
1700 /* the action file gets copied in in place of this dollarsign */
1701 #line 423 "/usr/unsupported/lib/bison.simple"
1712 short *ssp1 = yyss - 1;
1713 fprintf (stderr, "state stack now");
1714 while (ssp1 != yyssp)
1715 fprintf (stderr, " %d", *++ssp1);
1716 fprintf (stderr, "\n");
1726 yylsp->first_line = yylloc.first_line;
1727 yylsp->first_column = yylloc.first_column;
1728 yylsp->last_line = (yylsp-1)->last_line;
1729 yylsp->last_column = (yylsp-1)->last_column;
1734 yylsp->last_line = (yylsp+yylen-1)->last_line;
1735 yylsp->last_column = (yylsp+yylen-1)->last_column;
1739 /* Now "shift" the result of the reduction.
1740 Determine what state that goes to,
1741 based on the state we popped back to
1742 and the rule number reduced by. */
1746 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
1747 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1748 yystate = yytable[yystate];
1750 yystate = yydefgoto[yyn - YYNTBASE];
1754 yyerrlab: /* here on detecting error */
1757 /* If not already recovering from an error, report this error. */
1761 #ifdef YYERROR_VERBOSE
1762 yyn = yypact[yystate];
1764 if (yyn > YYFLAG && yyn < YYLAST)
1771 for (x = 0; x < (sizeof(yytname) / sizeof(char *)); x++)
1772 if (yycheck[x + yyn] == x)
1773 size += strlen(yytname[x]) + 15, count++;
1774 msg = (char *) xmalloc(size + 15);
1775 strcpy(msg, "parse error");
1780 for (x = 0; x < (sizeof(yytname) / sizeof(char *)); x++)
1781 if (yycheck[x + yyn] == x)
1783 strcat(msg, count == 0 ? ", expecting `" : " or `");
1784 strcat(msg, yytname[x]);
1793 #endif /* YYERROR_VERBOSE */
1794 yyerror("parse error");
1797 yyerrlab1: /* here on error raised explicitly by an action */
1799 if (yyerrstatus == 3)
1801 /* if just tried and failed to reuse lookahead token after an error, discard it. */
1803 /* return failure if at end of input */
1804 if (yychar == YYEOF)
1809 fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
1815 /* Else will try to reuse lookahead token
1816 after shifting the error token. */
1818 yyerrstatus = 3; /* Each real token shifted decrements this */
1822 yyerrdefault: /* current state does not do anything special for the error token. */
1825 /* This is wrong; only states that explicitly want error tokens
1826 should shift them. */
1827 yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
1828 if (yyn) goto yydefault;
1831 yyerrpop: /* pop the current state because it cannot handle the error token */
1833 if (yyssp == yyss) YYABORT;
1843 short *ssp1 = yyss - 1;
1844 fprintf (stderr, "Error: state stack now");
1845 while (ssp1 != yyssp)
1846 fprintf (stderr, " %d", *++ssp1);
1847 fprintf (stderr, "\n");
1853 yyn = yypact[yystate];
1858 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
1877 fprintf(stderr, "Shifting error token, ");
1888 #line 929 "./expread.y"
1891 /* Begin counting arguments for a function call,
1892 saving the data about any containing call. */
1897 register struct funcall *new = (struct funcall *) xmalloc (sizeof (struct funcall));
1899 new->next = funcall_chain;
1900 new->arglist_len = arglist_len;
1902 funcall_chain = new;
1905 /* Return the number of arguments in a function call just terminated,
1906 and restore the data for the containing function call. */
1911 register int val = arglist_len;
1912 register struct funcall *call = funcall_chain;
1913 funcall_chain = call->next;
1914 arglist_len = call->arglist_len;
1919 /* Free everything in the funcall chain.
1920 Used when there is an error inside parsing. */
1925 register struct funcall *call, *next;
1927 for (call = funcall_chain; call; call = next)
1934 /* This page contains the functions for adding data to the struct expression
1935 being constructed. */
1937 /* Add one element to the end of the expression. */
1939 /* To avoid a bug in the Sun 4 compiler, we pass things that can fit into
1940 a register through here */
1943 write_exp_elt (expelt)
1944 union exp_element expelt;
1946 if (expout_ptr >= expout_size)
1949 expout = (struct expression *) xrealloc (expout,
1950 sizeof (struct expression)
1951 + expout_size * sizeof (union exp_element));
1953 expout->elts[expout_ptr++] = expelt;
1957 write_exp_elt_opcode (expelt)
1958 enum exp_opcode expelt;
1960 union exp_element tmp;
1962 tmp.opcode = expelt;
1964 write_exp_elt (tmp);
1968 write_exp_elt_sym (expelt)
1969 struct symbol *expelt;
1971 union exp_element tmp;
1973 tmp.symbol = expelt;
1975 write_exp_elt (tmp);
1979 write_exp_elt_longcst (expelt)
1982 union exp_element tmp;
1984 tmp.longconst = expelt;
1986 write_exp_elt (tmp);
1990 write_exp_elt_dblcst (expelt)
1993 union exp_element tmp;
1995 tmp.doubleconst = expelt;
1997 write_exp_elt (tmp);
2001 write_exp_elt_type (expelt)
2002 struct type *expelt;
2004 union exp_element tmp;
2008 write_exp_elt (tmp);
2012 write_exp_elt_intern (expelt)
2013 struct internalvar *expelt;
2015 union exp_element tmp;
2017 tmp.internalvar = expelt;
2019 write_exp_elt (tmp);
2022 /* Add a string constant to the end of the expression.
2023 Follow it by its length in bytes, as a separate exp_element. */
2026 write_exp_string (str)
2029 register int len = str.length;
2031 = (len + sizeof (union exp_element)) / sizeof (union exp_element);
2033 expout_ptr += lenelt;
2035 if (expout_ptr >= expout_size)
2037 expout_size = max (expout_size * 2, expout_ptr + 10);
2038 expout = (struct expression *)
2039 xrealloc (expout, (sizeof (struct expression)
2040 + (expout_size * sizeof (union exp_element))));
2042 bcopy (str.ptr, (char *) &expout->elts[expout_ptr - lenelt], len);
2043 ((char *) &expout->elts[expout_ptr - lenelt])[len] = 0;
2044 write_exp_elt_longcst ((LONGEST) len);
2047 /* During parsing of a C expression, the pointer to the next character
2048 is in this variable. */
2050 static char *lexptr;
2052 /* Tokens that refer to names do so with explicit pointer and length,
2053 so they can share the storage that lexptr is parsing.
2055 When it is necessary to pass a name to a function that expects
2056 a null-terminated string, the substring is copied out
2057 into a block of storage that namecopy points to.
2059 namecopy is allocated once, guaranteed big enough, for each parsing. */
2061 static char *namecopy;
2063 /* Current depth in parentheses within the expression. */
2065 static int paren_depth;
2067 /* Nonzero means stop parsing on first comma (if not within parentheses). */
2069 static int comma_terminates;
2071 /* Take care of parsing a number (anything that starts with a digit).
2072 Set yylval and return the token type; update lexptr.
2073 LEN is the number of characters in it. */
2075 /*** Needs some error checking for the float case ***/
2078 parse_number (p, len, parsed_float, putithere)
2084 register LONGEST n = 0;
2087 register int base = input_radix;
2090 extern double atof ();
2094 /* It's a float since it contains a point or an exponent. */
2095 putithere->dval = atof (p);
2099 /* Handle base-switching prefixes 0x, 0t, 0d, 0 */
2133 if (c >= 'A' && c <= 'Z')
2135 if (c != 'l' && c != 'u')
2137 if (c >= '0' && c <= '9')
2141 if (base > 10 && c >= 'a' && c <= 'f')
2142 n += i = c - 'a' + 10;
2143 else if (len == 0 && c == 'l')
2145 else if (len == 0 && c == 'u')
2148 return ERROR; /* Char not a digit */
2151 return ERROR; /* Invalid digit in this base */
2156 putithere->ulval = n;
2161 putithere->lval = n;
2170 enum exp_opcode opcode;
2173 const static struct token tokentab3[] =
2175 {">>=", ASSIGN_MODIFY, BINOP_RSH},
2176 {"<<=", ASSIGN_MODIFY, BINOP_LSH}
2179 const static struct token tokentab2[] =
2181 {"+=", ASSIGN_MODIFY, BINOP_ADD},
2182 {"-=", ASSIGN_MODIFY, BINOP_SUB},
2183 {"*=", ASSIGN_MODIFY, BINOP_MUL},
2184 {"/=", ASSIGN_MODIFY, BINOP_DIV},
2185 {"%=", ASSIGN_MODIFY, BINOP_REM},
2186 {"|=", ASSIGN_MODIFY, BINOP_LOGIOR},
2187 {"&=", ASSIGN_MODIFY, BINOP_LOGAND},
2188 {"^=", ASSIGN_MODIFY, BINOP_LOGXOR},
2189 {"++", INCREMENT, BINOP_END},
2190 {"--", DECREMENT, BINOP_END},
2191 {"->", ARROW, BINOP_END},
2192 {"&&", AND, BINOP_END},
2193 {"||", OR, BINOP_END},
2194 {"::", COLONCOLON, BINOP_END},
2195 {"<<", LSH, BINOP_END},
2196 {">>", RSH, BINOP_END},
2197 {"==", EQUAL, BINOP_END},
2198 {"!=", NOTEQUAL, BINOP_END},
2199 {"<=", LEQ, BINOP_END},
2200 {">=", GEQ, BINOP_END}
2203 /* assign machine-independent names to certain registers
2204 * (unless overridden by the REGISTER_NAMES table)
2211 { "pc", PC_REGNUM },
2214 { "fp", FP_REGNUM },
2217 { "sp", SP_REGNUM },
2220 { "ps", PS_REGNUM },
2224 #define NUM_STD_REGS (sizeof std_regs / sizeof std_regs[0])
2226 /* Read one token, getting characters through lexptr. */
2232 register int namelen;
2233 register unsigned i;
2234 register char *tokstart;
2239 /* See if it is a special token of length 3. */
2240 for (i = 0; i < sizeof tokentab3 / sizeof tokentab3[0]; i++)
2241 if (!strncmp (tokstart, tokentab3[i].operator, 3))
2244 yylval.opcode = tokentab3[i].opcode;
2245 return tokentab3[i].token;
2248 /* See if it is a special token of length 2. */
2249 for (i = 0; i < sizeof tokentab2 / sizeof tokentab2[0]; i++)
2250 if (!strncmp (tokstart, tokentab2[i].operator, 2))
2253 yylval.opcode = tokentab2[i].opcode;
2254 return tokentab2[i].token;
2257 switch (c = *tokstart)
2272 c = parse_escape (&lexptr);
2276 error ("Invalid character constant.");
2285 if (paren_depth == 0)
2292 if (comma_terminates && paren_depth == 0)
2298 /* Might be a floating point number. */
2299 if (lexptr[1] < '0' || lexptr[1] > '9')
2300 goto symbol; /* Nope, must be a symbol. */
2301 /* FALL THRU into number case. */
2314 /* It's a number. */
2315 int got_dot = 0, got_e = 0, toktype;
2316 register char *p = tokstart;
2317 int hex = input_radix > 10;
2319 if (c == '0' && (p[1] == 'x' || p[1] == 'X'))
2324 else if (c == '0' && (p[1]=='t' || p[1]=='T' || p[1]=='d' || p[1]=='D'))
2332 if (!hex && !got_e && (*p == 'e' || *p == 'E'))
2333 got_dot = got_e = 1;
2334 else if (!hex && !got_dot && *p == '.')
2336 else if (got_e && (p[-1] == 'e' || p[-1] == 'E')
2337 && (*p == '-' || *p == '+'))
2338 /* This is the sign of the exponent, not the end of the
2341 /* We will take any letters or digits. parse_number will
2342 complain if past the radix, or if L or U are not final. */
2343 else if ((*p < '0' || *p > '9')
2344 && ((*p < 'a' || *p > 'z')
2345 && (*p < 'A' || *p > 'Z')))
2348 toktype = parse_number (tokstart, p - tokstart, got_dot|got_e, &yylval);
2349 if (toktype == ERROR)
2351 char *err_copy = (char *) alloca (p - tokstart + 1);
2353 bcopy (tokstart, err_copy, p - tokstart);
2354 err_copy[p - tokstart] = 0;
2355 error ("Invalid number \"%s\".", err_copy);
2386 for (namelen = 1; (c = tokstart[namelen]) != '"'; namelen++)
2389 c = tokstart[++namelen];
2390 if (c >= '0' && c <= '9')
2392 c = tokstart[++namelen];
2393 if (c >= '0' && c <= '9')
2394 c = tokstart[++namelen];
2397 yylval.sval.ptr = tokstart + 1;
2398 yylval.sval.length = namelen - 1;
2399 lexptr += namelen + 1;
2403 if (!(c == '_' || c == '$'
2404 || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')))
2405 /* We must have come across a bad character (e.g. ';'). */
2406 error ("Invalid character '%c' in expression.", c);
2408 /* It's a name. See how long it is. */
2410 for (c = tokstart[namelen];
2411 (c == '_' || c == '$' || (c >= '0' && c <= '9')
2412 || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'));
2413 c = tokstart[++namelen])
2416 /* The token "if" terminates the expression and is NOT
2417 removed from the input stream. */
2418 if (namelen == 2 && tokstart[0] == 'i' && tokstart[1] == 'f')
2425 /* Handle the tokens $digits; also $ (short for $0) and $$ (short for $$1)
2426 and $$digits (equivalent to $<-digits> if you could type that).
2427 Make token type LAST, and put the number (the digits) in yylval. */
2429 if (*tokstart == '$')
2431 register int negate = 0;
2433 /* Double dollar means negate the number and add -1 as well.
2434 Thus $$ alone means -1. */
2435 if (namelen >= 2 && tokstart[1] == '$')
2442 /* Just dollars (one or two) */
2443 yylval.lval = - negate;
2446 /* Is the rest of the token digits? */
2447 for (; c < namelen; c++)
2448 if (!(tokstart[c] >= '0' && tokstart[c] <= '9'))
2452 yylval.lval = atoi (tokstart + 1 + negate);
2454 yylval.lval = - yylval.lval;
2459 /* Handle tokens that refer to machine registers:
2460 $ followed by a register name. */
2462 if (*tokstart == '$') {
2463 for (c = 0; c < NUM_REGS; c++)
2464 if (namelen - 1 == strlen (reg_names[c])
2465 && !strncmp (tokstart + 1, reg_names[c], namelen - 1))
2470 for (c = 0; c < NUM_STD_REGS; c++)
2471 if (namelen - 1 == strlen (std_regs[c].name)
2472 && !strncmp (tokstart + 1, std_regs[c].name, namelen - 1))
2474 yylval.lval = std_regs[c].regnum;
2478 /* Catch specific keywords. Should be done with a data structure. */
2482 if (!strncmp (tokstart, "unsigned", 8))
2486 if (!strncmp (tokstart, "struct", 6))
2488 if (!strncmp (tokstart, "signed", 6))
2490 if (!strncmp (tokstart, "sizeof", 6))
2494 if (!strncmp (tokstart, "union", 5))
2496 if (!strncmp (tokstart, "short", 5))
2500 if (!strncmp (tokstart, "enum", 4))
2502 if (!strncmp (tokstart, "long", 4))
2504 if (!strncmp (tokstart, "this", 4))
2506 static const char this_name[] =
2507 { CPLUS_MARKER, 't', 'h', 'i', 's', '\0' };
2509 if (lookup_symbol (this_name, expression_context_block,
2510 VAR_NAMESPACE, 0, NULL))
2515 if (!strncmp (tokstart, "int", 3))
2522 yylval.sval.ptr = tokstart;
2523 yylval.sval.length = namelen;
2525 /* Any other names starting in $ are debugger internal variables. */
2527 if (*tokstart == '$')
2529 yylval.ivar = lookup_internalvar (copy_name (yylval.sval) + 1);
2533 /* Use token-type BLOCKNAME for symbols that happen to be defined as
2534 functions or symtabs. If this is not so, then ...
2535 Use token-type TYPENAME for symbols that happen to be defined
2536 currently as names of types; NAME for other symbols.
2537 The caller is not constrained to care about the distinction. */
2539 char *tmp = copy_name (yylval.sval);
2541 int is_a_field_of_this = 0;
2544 sym = lookup_symbol (tmp, expression_context_block,
2545 VAR_NAMESPACE, &is_a_field_of_this, NULL);
2546 if ((sym && SYMBOL_CLASS (sym) == LOC_BLOCK) ||
2547 lookup_partial_symtab (tmp))
2549 yylval.ssym.sym = sym;
2550 yylval.ssym.is_a_field_of_this = is_a_field_of_this;
2553 if (sym && SYMBOL_CLASS (sym) == LOC_TYPEDEF)
2555 yylval.tsym.type = SYMBOL_TYPE (sym);
2558 if ((yylval.tsym.type = lookup_primitive_typename (tmp)) != 0)
2561 /* Input names that aren't symbols but ARE valid hex numbers,
2562 when the input radix permits them, can be names or numbers
2563 depending on the parse. Note we support radixes > 16 here. */
2565 ((tokstart[0] >= 'a' && tokstart[0] < 'a' + input_radix - 10) ||
2566 (tokstart[0] >= 'A' && tokstart[0] < 'A' + input_radix - 10)))
2568 YYSTYPE newlval; /* Its value is ignored. */
2569 hextype = parse_number (tokstart, namelen, 0, &newlval);
2572 yylval.ssym.sym = sym;
2573 yylval.ssym.is_a_field_of_this = is_a_field_of_this;
2576 if (hextype == UINT)
2578 yylval.ssym.sym = sym;
2579 yylval.ssym.is_a_field_of_this = is_a_field_of_this;
2580 return NAME_OR_UINT;
2584 /* Any other kind of symbol */
2585 yylval.ssym.sym = sym;
2586 yylval.ssym.is_a_field_of_this = is_a_field_of_this;
2595 error ("Invalid syntax in expression.");
2598 /* Return a null-terminated temporary copy of the name
2599 of a string token. */
2603 struct stoken token;
2605 bcopy (token.ptr, namecopy, token.length);
2606 namecopy[token.length] = 0;
2610 /* Reverse an expression from suffix form (in which it is constructed)
2611 to prefix form (in which we can conveniently print or execute it). */
2613 static void prefixify_subexp ();
2616 prefixify_expression (expr)
2617 register struct expression *expr;
2619 register int len = sizeof (struct expression) +
2620 expr->nelts * sizeof (union exp_element);
2621 register struct expression *temp;
2622 register int inpos = expr->nelts, outpos = 0;
2624 temp = (struct expression *) alloca (len);
2626 /* Copy the original expression into temp. */
2627 bcopy (expr, temp, len);
2629 prefixify_subexp (temp, expr, inpos, outpos);
2632 /* Return the number of exp_elements in the subexpression of EXPR
2633 whose last exp_element is at index ENDPOS - 1 in EXPR. */
2636 length_of_subexp (expr, endpos)
2637 register struct expression *expr;
2638 register int endpos;
2640 register int oplen = 1;
2641 register int args = 0;
2645 error ("?error in length_of_subexp");
2647 i = (int) expr->elts[endpos - 1].opcode;
2653 oplen = 4 + ((expr->elts[endpos - 2].longconst
2654 + sizeof (union exp_element))
2655 / sizeof (union exp_element));
2666 case OP_INTERNALVAR:
2672 args = 1 + expr->elts[endpos - 2].longconst;
2681 case STRUCTOP_STRUCT:
2685 oplen = 3 + ((expr->elts[endpos - 2].longconst
2686 + sizeof (union exp_element))
2687 / sizeof (union exp_element));
2694 case BINOP_ASSIGN_MODIFY:
2705 args = 1 + (i < (int) BINOP_END);
2710 oplen += length_of_subexp (expr, endpos - oplen);
2717 /* Copy the subexpression ending just before index INEND in INEXPR
2718 into OUTEXPR, starting at index OUTBEG.
2719 In the process, convert it from suffix to prefix form. */
2722 prefixify_subexp (inexpr, outexpr, inend, outbeg)
2723 register struct expression *inexpr;
2724 struct expression *outexpr;
2728 register int oplen = 1;
2729 register int args = 0;
2732 enum exp_opcode opcode;
2734 /* Compute how long the last operation is (in OPLEN),
2735 and also how many preceding subexpressions serve as
2736 arguments for it (in ARGS). */
2738 opcode = inexpr->elts[inend - 1].opcode;
2743 oplen = 4 + ((inexpr->elts[inend - 2].longconst
2744 + sizeof (union exp_element))
2745 / sizeof (union exp_element));
2756 case OP_INTERNALVAR:
2762 args = 1 + inexpr->elts[inend - 2].longconst;
2771 case STRUCTOP_STRUCT:
2775 oplen = 3 + ((inexpr->elts[inend - 2].longconst
2776 + sizeof (union exp_element))
2777 / sizeof (union exp_element));
2785 case BINOP_ASSIGN_MODIFY:
2796 args = 1 + ((int) opcode < (int) BINOP_END);
2799 /* Copy the final operator itself, from the end of the input
2800 to the beginning of the output. */
2802 bcopy (&inexpr->elts[inend], &outexpr->elts[outbeg],
2803 oplen * sizeof (union exp_element));
2806 /* Find the lengths of the arg subexpressions. */
2807 arglens = (int *) alloca (args * sizeof (int));
2808 for (i = args - 1; i >= 0; i--)
2810 oplen = length_of_subexp (inexpr, inend);
2815 /* Now copy each subexpression, preserving the order of
2816 the subexpressions, but prefixifying each one.
2817 In this loop, inend starts at the beginning of
2818 the expression this level is working on
2819 and marches forward over the arguments.
2820 outbeg does similarly in the output. */
2821 for (i = 0; i < args; i++)
2825 prefixify_subexp (inexpr, outexpr, inend, outbeg);
2830 /* This page contains the two entry points to this file. */
2832 /* Read a C expression from the string *STRINGPTR points to,
2833 parse it, and return a pointer to a struct expression that we malloc.
2834 Use block BLOCK as the lexical context for variable names;
2835 if BLOCK is zero, use the block of the selected stack frame.
2836 Meanwhile, advance *STRINGPTR to point after the expression,
2837 at the first nonwhite character that is not part of the expression
2838 (possibly a null character).
2840 If COMMA is nonzero, stop if a comma is reached. */
2843 parse_c_1 (stringptr, block, comma)
2845 struct block *block;
2848 struct cleanup *old_chain;
2850 lexptr = *stringptr;
2853 type_stack_depth = 0;
2855 comma_terminates = comma;
2857 if (lexptr == 0 || *lexptr == 0)
2858 error_no_arg ("expression to compute");
2860 old_chain = make_cleanup (free_funcalls, 0);
2863 expression_context_block = block ? block : get_selected_block ();
2865 namecopy = (char *) alloca (strlen (lexptr) + 1);
2868 expout = (struct expression *)
2869 xmalloc (sizeof (struct expression)
2870 + expout_size * sizeof (union exp_element));
2871 make_cleanup (free_current_contents, &expout);
2874 discard_cleanups (old_chain);
2875 expout->nelts = expout_ptr;
2876 expout = (struct expression *)
2878 sizeof (struct expression)
2879 + expout_ptr * sizeof (union exp_element));
2880 prefixify_expression (expout);
2881 *stringptr = lexptr;
2885 /* Parse STRING as an expression, and complain if this fails
2886 to use up all of the contents of STRING. */
2889 parse_c_expression (string)
2892 register struct expression *exp;
2893 exp = parse_c_1 (&string, 0, 0);
2895 error ("Junk after end of expression.");
2901 enum type_pieces tp;
2903 if (type_stack_depth == type_stack_size)
2905 type_stack_size *= 2;
2906 type_stack = (union type_stack_elt *)
2907 xrealloc (type_stack, type_stack_size * sizeof (*type_stack));
2909 type_stack[type_stack_depth++].piece = tp;
2916 if (type_stack_depth == type_stack_size)
2918 type_stack_size *= 2;
2919 type_stack = (union type_stack_elt *)
2920 xrealloc (type_stack, type_stack_size * sizeof (*type_stack));
2922 type_stack[type_stack_depth++].int_val = n;
2925 static enum type_pieces
2928 if (type_stack_depth)
2929 return type_stack[--type_stack_depth].piece;
2936 if (type_stack_depth)
2937 return type_stack[--type_stack_depth].int_val;
2938 /* "Can't happen". */
2943 _initialize_expread ()
2945 type_stack_size = 80;
2946 type_stack_depth = 0;
2947 type_stack = (union type_stack_elt *)
2948 xmalloc (type_stack_size * sizeof (*type_stack));