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 static enum type_pieces
*type_stack
;
128 static int type_stack_depth
, type_stack_size
;
130 static void push_type ();
131 static enum type_pieces
pop_type ();
133 /* Allow debugging of parsing. */
136 #line 125 "../expread.y"
140 unsigned LONGEST ulval
;
146 struct symtoken ssym
;
149 enum exp_opcode opcode
;
150 struct internalvar
*ivar
;
169 #define YYLTYPE yyltype
181 #define YYFLAG -32768
184 #define YYTRANSLATE(x) ((unsigned)(x) <= 296 ? yytranslate[x] : 84)
186 static const char yytranslate
[] = { 0,
187 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
188 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
189 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
190 2, 2, 59, 2, 2, 2, 51, 37, 2, 58,
191 62, 49, 47, 29, 48, 56, 50, 2, 2, 2,
192 2, 2, 2, 2, 2, 2, 2, 65, 2, 40,
193 31, 41, 32, 46, 2, 2, 2, 2, 2, 2,
194 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
195 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
196 57, 2, 61, 36, 2, 2, 2, 2, 2, 2,
197 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
198 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
199 2, 2, 63, 35, 64, 60, 2, 2, 2, 2,
200 2, 2, 2, 2, 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 2, 2, 2, 2, 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, 2, 2, 2, 2, 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, 1, 2, 3, 4, 5,
213 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
214 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
215 26, 27, 28, 30, 33, 34, 38, 39, 42, 43,
216 44, 45, 52, 53, 54, 55
219 static const short yyrline
[] = { 0,
220 218, 222, 223, 228, 231, 234, 238, 242, 246, 250,
221 254, 258, 262, 266, 272, 276, 282, 286, 290, 294,
222 300, 303, 307, 311, 317, 323, 329, 333, 337, 341,
223 345, 349, 353, 357, 361, 365, 369, 373, 377, 381,
224 385, 389, 393, 397, 401, 405, 409, 413, 419, 429,
225 442, 454, 467, 474, 481, 484, 490, 496, 502, 509,
226 516, 523, 541, 551, 563, 576, 594, 640, 714, 715,
227 750, 752, 754, 756, 758, 761, 763, 768, 774, 776,
228 780, 782, 786, 790, 791, 793, 795, 798, 805, 807,
229 809, 811, 813, 815, 817, 819, 821, 823, 825, 827,
230 829, 832, 835, 838, 840, 842, 844, 848, 849, 855,
231 861, 870, 875, 882, 883, 884, 885, 886, 889, 890
234 static const char * const yytname
[] = { 0,
235 "error","$illegal.","INT","CHAR","UINT","FLOAT","STRING","NAME","BLOCKNAME","TYPENAME",
236 "NAME_OR_INT","NAME_OR_UINT","STRUCT","UNION","ENUM","SIZEOF","UNSIGNED","COLONCOLON","ERROR","SIGNED",
237 "LONG","SHORT","INT_KEYWORD","LAST","REGNAME","VARIABLE","ASSIGN_MODIFY","THIS","','","ABOVE_COMMA",
238 "'='","'?'","OR","AND","'|'","'^'","'&'","EQUAL","NOTEQUAL","'<'",
239 "'>'","LEQ","GEQ","LSH","RSH","'@'","'+'","'-'","'*'","'/'",
240 "'%'","UNARY","INCREMENT","DECREMENT","ARROW","'.'","'['","'('","'!'","'~'",
241 "']'","')'","'{'","'}'","':'","start"
244 static const short yyr1
[] = { 0,
245 66, 67, 67, 68, 68, 68, 68, 68, 68, 68,
246 68, 68, 68, 68, 68, 68, 68, 68, 69, 68,
247 70, 70, 70, 68, 68, 68, 68, 68, 68, 68,
248 68, 68, 68, 68, 68, 68, 68, 68, 68, 68,
249 68, 68, 68, 68, 68, 68, 68, 68, 68, 68,
250 68, 68, 68, 68, 68, 68, 68, 68, 68, 68,
251 68, 71, 71, 72, 72, 72, 72, 72, 73, 73,
252 74, 74, 74, 74, 74, 75, 75, 75, 75, 75,
253 76, 76, 77, 78, 78, 78, 78, 78, 79, 79,
254 79, 79, 79, 79, 79, 79, 79, 79, 79, 79,
255 79, 79, 79, 79, 79, 79, 79, 80, 80, 80,
256 80, 81, 81, 82, 82, 82, 82, 82, 83, 83
259 static const short yyr2
[] = { 0,
260 1, 1, 3, 2, 2, 2, 2, 2, 2, 2,
261 2, 2, 2, 3, 4, 3, 4, 4, 0, 5,
262 0, 1, 3, 4, 4, 3, 3, 3, 3, 3,
263 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
264 3, 3, 3, 3, 3, 5, 3, 3, 1, 1,
265 1, 1, 1, 1, 1, 1, 1, 1, 4, 1,
266 1, 1, 3, 3, 3, 4, 2, 1, 1, 2,
267 1, 2, 1, 2, 1, 3, 2, 1, 2, 1,
268 2, 3, 2, 1, 3, 6, 8, 9, 1, 1,
269 1, 1, 2, 3, 2, 3, 3, 4, 2, 3,
270 2, 2, 2, 2, 1, 2, 1, 1, 1, 1,
271 1, 1, 3, 1, 1, 1, 1, 1, 1, 1
274 static const short yydefact
[] = { 0,
275 49, 53, 51, 54, 60, 119, 120, 89, 50, 52,
276 0, 0, 0, 0, 105, 0, 107, 91, 92, 90,
277 56, 57, 58, 61, 0, 0, 0, 0, 0, 0,
278 0, 0, 0, 1, 2, 0, 55, 0, 68, 114,
279 115, 116, 117, 118, 101, 102, 103, 0, 13, 108,
280 110, 111, 109, 104, 67, 110, 111, 106, 95, 93,
281 99, 5, 6, 4, 9, 10, 0, 84, 0, 69,
282 7, 8, 0, 69, 0, 0, 0, 0, 0, 0,
283 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
284 0, 0, 0, 0, 0, 0, 0, 11, 12, 0,
285 0, 0, 19, 0, 0, 0, 97, 94, 100, 96,
286 26, 0, 0, 0, 73, 71, 0, 0, 70, 75,
287 78, 80, 0, 0, 3, 48, 47, 0, 45, 44,
288 43, 42, 41, 35, 36, 39, 40, 37, 38, 33,
289 34, 27, 31, 32, 28, 29, 30, 0, 14, 0,
290 16, 0, 21, 64, 0, 65, 59, 98, 0, 25,
291 85, 74, 72, 0, 81, 83, 0, 0, 77, 79,
292 24, 0, 15, 17, 18, 22, 0, 66, 0, 82,
293 76, 46, 0, 20, 0, 23, 86, 0, 87, 112,
294 0, 0, 88, 113, 0, 0, 0
297 static const short yydefgoto
[] = { 195,
298 67, 35, 153, 177, 36, 37, 68, 119, 120, 121,
299 122, 69, 38, 54, 191, 156, 39
302 static const short yypact
[] = { 167,
303 -32768,-32768,-32768,-32768,-32768,-32768, 7,-32768,-32768,-32768,
304 22, 22, 22, 228, 190, 22, 245, 119, -7,-32768,
305 -32768,-32768,-32768,-32768, 167, 167, 167, 167, 167, 167,
306 167, 167, 528, 60, 303, 33,-32768, 76,-32768,-32768,
307 -32768,-32768,-32768,-32768,-32768,-32768,-32768, 167, 216,-32768,
308 134, 77,-32768,-32768,-32768,-32768,-32768,-32768, 78,-32768,
309 -32768, 216, 216, 216, 216, 216, 59,-32768, -52, 75,
310 216, 216, -55, 80, 167, 167, 167, 167, 167, 167,
311 167, 167, 167, 167, 167, 167, 167, 167, 167, 167,
312 167, 167, 167, 167, 167, 167, 167,-32768,-32768, 198,
313 249, 167,-32768, 22, 138, -34, 90,-32768,-32768,-32768,
314 -32768, 528, 167, 96, 165, 165, 26, 104,-32768, -50,
315 -32768,-32768, 167, 47, 303, 303, 303, 268, 355, 379,
316 402, 424, 445, 464, 464, 479, 479, 479, 479, 506,
317 506, 518, 529, 529, 216, 216, 216, 167,-32768, 167,
318 -32768, -2, 167, 98, 22,-32768, 32,-32768, 113, 216,
319 -32768,-32768,-32768, 62,-32768,-32768, 82, 106,-32768,-32768,
320 216, 167, 216, 216,-32768, 303, 68,-32768, 137,-32768,
321 -32768, 330, 167,-32768, 132, 303, 139, 105,-32768, 141,
322 73, 528,-32768, 141, 196, 201,-32768
325 static const short yypgoto
[] = {-32768,
326 1, -14,-32768,-32768,-32768,-32768,-32768, 36,-32768, 83,
327 85, -29, -28, 200,-32768, 10,-32768
334 static const short yytable
[] = { 49,
335 34, 70, 112, 73, 74, 112, 117, 168, 123, 113,
336 62, 63, 64, 65, 66, 61, 71, 72, 106, 70,
337 45, 46, 47, 112, -62, 55, 75, 157, 164, 40,
338 41, 42, 43, 44, 1, 2, 3, 4, 5, 6,
339 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
340 104, 17, 18, 19, 20, 21, 22, 23, 175, 24,
341 125, 126, 127, 128, 129, 130, 131, 132, 133, 134,
342 135, 136, 137, 138, 139, 140, 141, 142, 143, 144,
343 145, 146, 147, 159, 28, 29, 165, 75, 75, 30,
344 31, 32, 114, 105, 33, 161, 183, 124, 160, 109,
345 110, 192, 152, 40, 41, 42, 43, 44, 171, 149,
346 151, 115, 158, 154, 8, -63, 115, 11, 12, 13,
347 111, 15, 180, 116, 17, 18, 19, 20, 116, 184,
348 179, 117, 118, 173, 193, 174, 117, 118, 176, 59,
349 115, 60, 160, 181, 161, 40, 41, 42, 43, 44,
350 162, 163, 116, 167, 107, 155, 108, 182, 190, 74,
351 117, 118, 194, 74, 178, 166, 189, 166, 186, 1,
352 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
353 12, 13, 14, 15, 16, 185, 17, 18, 19, 20,
354 21, 22, 23, 187, 24, 196, 188, 155, 112, 50,
355 197, 115, 169, 25, 170, 40, 41, 42, 43, 44,
356 51, 52, 53, 116, 26, 27, 58, 0, 0, 28,
357 29, 117, 118, 0, 30, 31, 32, 0, 0, 33,
358 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
359 11, 12, 13, 14, 15, 16, 148, 17, 18, 19,
360 20, 21, 22, 23, 50, 24, 40, 41, 42, 43,
361 44, 0, 0, 0, 25, 56, 57, 53, 98, 99,
362 100, 101, 102, 103, 0, 26, 27, 0, 0, 0,
363 28, 29, 0, 0, 0, 48, 31, 32, 0, 0,
364 33, 0, 0, 0, 76, 0, 0, 150, 77, 78,
365 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
366 89, 90, 91, 92, 93, 94, 95, 96, 97, 0,
367 98, 99, 100, 101, 102, 103, 0, 0, 0, 76,
368 0, 0, 172, 77, 78, 79, 80, 81, 82, 83,
369 84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
370 94, 95, 96, 97, 0, 98, 99, 100, 101, 102,
371 103, 78, 79, 80, 81, 82, 83, 84, 85, 86,
372 87, 88, 89, 90, 91, 92, 93, 94, 95, 96,
373 97, 0, 98, 99, 100, 101, 102, 103, 80, 81,
374 82, 83, 84, 85, 86, 87, 88, 89, 90, 91,
375 92, 93, 94, 95, 96, 97, 0, 98, 99, 100,
376 101, 102, 103, 81, 82, 83, 84, 85, 86, 87,
377 88, 89, 90, 91, 92, 93, 94, 95, 96, 97,
378 0, 98, 99, 100, 101, 102, 103, 82, 83, 84,
379 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
380 95, 96, 97, 0, 98, 99, 100, 101, 102, 103,
381 83, 84, 85, 86, 87, 88, 89, 90, 91, 92,
382 93, 94, 95, 96, 97, 0, 98, 99, 100, 101,
383 102, 103, 84, 85, 86, 87, 88, 89, 90, 91,
384 92, 93, 94, 95, 96, 97, 0, 98, 99, 100,
385 101, 102, 103, 86, 87, 88, 89, 90, 91, 92,
386 93, 94, 95, 96, 97, 0, 98, 99, 100, 101,
387 102, 103, 90, 91, 92, 93, 94, 95, 96, 97,
388 0, 98, 99, 100, 101, 102, 103, 8, 0, 0,
389 11, 12, 13, 0, 15, 0, 0, 17, 18, 19,
390 20, 92, 93, 94, 95, 96, 97, 0, 98, 99,
391 100, 101, 102, 103, 93, 94, 95, 96, 97, 0,
392 98, 99, 100, 101, 102, 103, 0, 95, 96, 97,
393 0, 98, 99, 100, 101, 102, 103
396 static const short yycheck
[] = { 14,
397 0, 30, 58, 33, 33, 58, 57, 58, 64, 62,
398 25, 26, 27, 28, 29, 23, 31, 32, 48, 48,
399 11, 12, 13, 58, 18, 16, 29, 62, 3, 8,
400 9, 10, 11, 12, 3, 4, 5, 6, 7, 8,
401 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
402 18, 20, 21, 22, 23, 24, 25, 26, 61, 28,
403 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
404 85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
405 95, 96, 97, 112, 53, 54, 61, 29, 29, 58,
406 59, 60, 18, 18, 63, 49, 29, 18, 113, 23,
407 23, 29, 102, 8, 9, 10, 11, 12, 123, 100,
408 101, 37, 23, 104, 10, 18, 37, 13, 14, 15,
409 62, 17, 61, 49, 20, 21, 22, 23, 49, 62,
410 18, 57, 58, 148, 62, 150, 57, 58, 153, 21,
411 37, 23, 157, 62, 49, 8, 9, 10, 11, 12,
412 115, 116, 49, 118, 21, 60, 23, 172, 188, 188,
413 57, 58, 192, 192, 155, 62, 62, 62, 183, 3,
414 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
415 14, 15, 16, 17, 18, 49, 20, 21, 22, 23,
416 24, 25, 26, 62, 28, 0, 58, 60, 58, 10,
417 0, 37, 120, 37, 120, 8, 9, 10, 11, 12,
418 21, 22, 23, 49, 48, 49, 17, -1, -1, 53,
419 54, 57, 58, -1, 58, 59, 60, -1, -1, 63,
420 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
421 13, 14, 15, 16, 17, 18, 49, 20, 21, 22,
422 23, 24, 25, 26, 10, 28, 8, 9, 10, 11,
423 12, -1, -1, -1, 37, 21, 22, 23, 53, 54,
424 55, 56, 57, 58, -1, 48, 49, -1, -1, -1,
425 53, 54, -1, -1, -1, 58, 59, 60, -1, -1,
426 63, -1, -1, -1, 27, -1, -1, 49, 31, 32,
427 33, 34, 35, 36, 37, 38, 39, 40, 41, 42,
428 43, 44, 45, 46, 47, 48, 49, 50, 51, -1,
429 53, 54, 55, 56, 57, 58, -1, -1, -1, 27,
430 -1, -1, 65, 31, 32, 33, 34, 35, 36, 37,
431 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
432 48, 49, 50, 51, -1, 53, 54, 55, 56, 57,
433 58, 32, 33, 34, 35, 36, 37, 38, 39, 40,
434 41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
435 51, -1, 53, 54, 55, 56, 57, 58, 34, 35,
436 36, 37, 38, 39, 40, 41, 42, 43, 44, 45,
437 46, 47, 48, 49, 50, 51, -1, 53, 54, 55,
438 56, 57, 58, 35, 36, 37, 38, 39, 40, 41,
439 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,
440 -1, 53, 54, 55, 56, 57, 58, 36, 37, 38,
441 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
442 49, 50, 51, -1, 53, 54, 55, 56, 57, 58,
443 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
444 47, 48, 49, 50, 51, -1, 53, 54, 55, 56,
445 57, 58, 38, 39, 40, 41, 42, 43, 44, 45,
446 46, 47, 48, 49, 50, 51, -1, 53, 54, 55,
447 56, 57, 58, 40, 41, 42, 43, 44, 45, 46,
448 47, 48, 49, 50, 51, -1, 53, 54, 55, 56,
449 57, 58, 44, 45, 46, 47, 48, 49, 50, 51,
450 -1, 53, 54, 55, 56, 57, 58, 10, -1, -1,
451 13, 14, 15, -1, 17, -1, -1, 20, 21, 22,
452 23, 46, 47, 48, 49, 50, 51, -1, 53, 54,
453 55, 56, 57, 58, 47, 48, 49, 50, 51, -1,
454 53, 54, 55, 56, 57, 58, -1, 49, 50, 51,
455 -1, 53, 54, 55, 56, 57, 58
459 /* -*-C-*- Note some compilers choke on comments on `#line' lines. */
460 #line 3 "bison.simple"
462 /* Skeleton output parser for bison,
463 Copyright (C) 1984 Bob Corbett and Richard Stallman
465 This program is free software; you can redistribute it and/or modify
466 it under the terms of the GNU General Public License as published by
467 the Free Software Foundation; either version 1, or (at your option)
470 This program is distributed in the hope that it will be useful,
471 but WITHOUT ANY WARRANTY; without even the implied warranty of
472 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
473 GNU General Public License for more details.
475 You should have received a copy of the GNU General Public License
476 along with this program; if not, write to the Free Software
477 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
480 #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__)
484 /* This is the parser code that is written into each bison parser
485 when the %semantic_parser declaration is not specified in the grammar.
486 It was written by Richard Stallman by simplifying the hairy parser
487 used when %semantic_parser is specified. */
489 /* Note: there must be only one dollar sign in this file.
490 It is replaced by the list of actions, each action
491 as one case of the switch. */
493 #define yyerrok (yyerrstatus = 0)
494 #define yyclearin (yychar = YYEMPTY)
497 #define YYFAIL goto yyerrlab;
498 #define YYACCEPT return(0)
499 #define YYABORT return(1)
500 #define YYERROR goto yyerrlab
503 #define YYERRCODE 256
506 #define YYLEX yylex()
510 #define YYLEX yylex(&yylval, &yylloc)
513 /* If nonreentrant, generate the variables here */
517 int yychar
; /* the lookahead symbol */
518 YYSTYPE yylval
; /* the semantic value of the */
519 /* lookahead symbol */
521 YYLTYPE yylloc
; /* location data for the lookahead */
524 int yynerrs
; /* number of parse errors so far */
525 #endif /* YYIMPURE */
528 int yydebug
; /* nonzero means print parse trace */
529 /* Since this is uninitialized, it does not stop multiple parsers
533 /* YYMAXDEPTH indicates the initial size of the parser's stacks */
536 #define YYMAXDEPTH 200
539 /* YYMAXLIMIT is the maximum size the stacks can grow to
540 (effective only if the built-in stack extension method is used). */
543 #define YYMAXLIMIT 10000
547 #line 90 "bison.simple"
551 register int yystate
;
553 register short *yyssp
;
554 register YYSTYPE
*yyvsp
;
556 int yyerrstatus
; /* number of tokens to shift before error messages enabled */
557 int yychar1
; /* lookahead token as an internal (translated) token number */
559 short yyssa
[YYMAXDEPTH
]; /* the state stack */
560 YYSTYPE yyvsa
[YYMAXDEPTH
]; /* the semantic value stack */
561 YYLTYPE yylsa
[YYMAXDEPTH
]; /* the location stack */
563 short *yyss
= yyssa
; /* refer to the stacks thru separate pointers */
564 YYSTYPE
*yyvs
= yyvsa
; /* to allow yyoverflow to reallocate them elsewhere */
565 YYLTYPE
*yyls
= yylsa
;
567 int yymaxdepth
= YYMAXDEPTH
;
576 YYSTYPE yyval
; /* the variable used to return */
577 /* semantic values from the action */
584 fprintf(stderr
, "Starting parse\n");
590 yychar
= YYEMPTY
; /* Cause a token to be read. */
592 /* Initialize stack pointers.
593 Waste one element of value and location stack
594 so that they stay on the same level as the state stack. */
600 /* Push a new state, which is found in yystate . */
601 /* In all cases, when you get here, the value and location stacks
602 have just been pushed. so pushing a state here evens the stacks. */
607 if (yyssp
>= yyss
+ yymaxdepth
- 1)
609 /* Give user a chance to reallocate the stack */
610 /* Use copies of these so that the &'s don't force the real ones into memory. */
611 YYSTYPE
*yyvs1
= yyvs
;
612 YYLTYPE
*yyls1
= yyls
;
615 /* Get the current used size of the three stacks, in elements. */
616 int size
= yyssp
- yyss
+ 1;
619 /* Each stack pointer address is followed by the size of
620 the data in use in that stack, in bytes. */
621 yyoverflow("parser stack overflow",
622 &yyss1
, size
* sizeof (*yyssp
),
623 &yyvs1
, size
* sizeof (*yyvsp
),
624 &yyls1
, size
* sizeof (*yylsp
),
627 yyss
= yyss1
; yyvs
= yyvs1
; yyls
= yyls1
;
628 #else /* no yyoverflow */
629 /* Extend the stack our own way. */
630 if (yymaxdepth
>= YYMAXLIMIT
)
631 yyerror("parser stack overflow");
633 if (yymaxdepth
> YYMAXLIMIT
)
634 yymaxdepth
= YYMAXLIMIT
;
635 yyss
= (short *) alloca (yymaxdepth
* sizeof (*yyssp
));
636 bcopy ((char *)yyss1
, (char *)yyss
, size
* sizeof (*yyssp
));
637 yyvs
= (YYSTYPE
*) alloca (yymaxdepth
* sizeof (*yyvsp
));
638 bcopy ((char *)yyvs1
, (char *)yyvs
, size
* sizeof (*yyvsp
));
640 yyls
= (YYLTYPE
*) alloca (yymaxdepth
* sizeof (*yylsp
));
641 bcopy ((char *)yyls1
, (char *)yyls
, size
* sizeof (*yylsp
));
643 #endif /* no yyoverflow */
645 yyssp
= yyss
+ size
- 1;
646 yyvsp
= yyvs
+ size
- 1;
648 yylsp
= yyls
+ size
- 1;
653 fprintf(stderr
, "Stack size increased to %d\n", yymaxdepth
);
656 if (yyssp
>= yyss
+ yymaxdepth
- 1)
662 fprintf(stderr
, "Entering state %d\n", yystate
);
665 /* Do appropriate processing given the current state. */
666 /* Read a lookahead token if we need one and don't already have one. */
669 /* First try to decide what to do without reference to lookahead token. */
671 yyn
= yypact
[yystate
];
675 /* Not known => get a lookahead token if don't already have one. */
677 /* yychar is either YYEMPTY or YYEOF
678 or a valid token in external form. */
680 if (yychar
== YYEMPTY
)
684 fprintf(stderr
, "Reading a token: ");
689 /* Convert token to internal form (in yychar1) for indexing tables with */
691 if (yychar
<= 0) /* This means end of input. */
694 yychar
= YYEOF
; /* Don't call YYLEX any more */
698 fprintf(stderr
, "Now at end of input.\n");
703 yychar1
= YYTRANSLATE(yychar
);
707 fprintf(stderr
, "Next token is %d (%s)\n", yychar
, yytname
[yychar1
]);
712 if (yyn
< 0 || yyn
> YYLAST
|| yycheck
[yyn
] != yychar1
)
717 /* yyn is what to do for this token type in this state.
718 Negative => reduce, -yyn is rule number.
719 Positive => shift, yyn is new state.
720 New state is final state => don't bother to shift,
722 0, or most negative number => error. */
737 /* Shift the lookahead token. */
741 fprintf(stderr
, "Shifting token %d (%s), ", yychar
, yytname
[yychar1
]);
744 /* Discard the token being shifted unless it is eof. */
753 /* count tokens shifted since error; after three, turn off error status. */
754 if (yyerrstatus
) yyerrstatus
--;
759 /* Do the default action for the current state. */
762 yyn
= yydefact
[yystate
];
766 /* Do a reduction. yyn is the number of a rule to reduce with. */
769 yyval
= yyvsp
[1-yylen
]; /* implement default value of the action */
775 fprintf (stderr
, "Reducing 1 value via line %d, ",
778 fprintf (stderr
, "Reducing %d values via line %d, ",
779 yylen
, yyrline
[yyn
]);
787 #line 224 "../expread.y"
788 { write_exp_elt_opcode (BINOP_COMMA
); ;
791 #line 229 "../expread.y"
792 { write_exp_elt_opcode (UNOP_IND
); ;
795 #line 232 "../expread.y"
796 { write_exp_elt_opcode (UNOP_ADDR
); ;
799 #line 235 "../expread.y"
800 { write_exp_elt_opcode (UNOP_NEG
); ;
803 #line 239 "../expread.y"
804 { write_exp_elt_opcode (UNOP_ZEROP
); ;
807 #line 243 "../expread.y"
808 { write_exp_elt_opcode (UNOP_LOGNOT
); ;
811 #line 247 "../expread.y"
812 { write_exp_elt_opcode (UNOP_PREINCREMENT
); ;
815 #line 251 "../expread.y"
816 { write_exp_elt_opcode (UNOP_PREDECREMENT
); ;
819 #line 255 "../expread.y"
820 { write_exp_elt_opcode (UNOP_POSTINCREMENT
); ;
823 #line 259 "../expread.y"
824 { write_exp_elt_opcode (UNOP_POSTDECREMENT
); ;
827 #line 263 "../expread.y"
828 { write_exp_elt_opcode (UNOP_SIZEOF
); ;
831 #line 267 "../expread.y"
832 { write_exp_elt_opcode (STRUCTOP_PTR
);
833 write_exp_string (yyvsp
[0].sval
);
834 write_exp_elt_opcode (STRUCTOP_PTR
); ;
837 #line 273 "../expread.y"
838 { write_exp_elt_opcode (STRUCTOP_MPTR
); ;
841 #line 277 "../expread.y"
842 { write_exp_elt_opcode (STRUCTOP_STRUCT
);
843 write_exp_string (yyvsp
[0].sval
);
844 write_exp_elt_opcode (STRUCTOP_STRUCT
); ;
847 #line 283 "../expread.y"
848 { write_exp_elt_opcode (STRUCTOP_MEMBER
); ;
851 #line 287 "../expread.y"
852 { write_exp_elt_opcode (BINOP_SUBSCRIPT
); ;
855 #line 293 "../expread.y"
856 { start_arglist (); ;
859 #line 295 "../expread.y"
860 { write_exp_elt_opcode (OP_FUNCALL
);
861 write_exp_elt_longcst ((LONGEST
) end_arglist ());
862 write_exp_elt_opcode (OP_FUNCALL
); ;
865 #line 304 "../expread.y"
869 #line 308 "../expread.y"
873 #line 312 "../expread.y"
874 { write_exp_elt_opcode (UNOP_MEMVAL
);
875 write_exp_elt_type (yyvsp
[-2].tval
);
876 write_exp_elt_opcode (UNOP_MEMVAL
); ;
879 #line 318 "../expread.y"
880 { write_exp_elt_opcode (UNOP_CAST
);
881 write_exp_elt_type (yyvsp
[-2].tval
);
882 write_exp_elt_opcode (UNOP_CAST
); ;
885 #line 324 "../expread.y"
889 #line 330 "../expread.y"
890 { write_exp_elt_opcode (BINOP_REPEAT
); ;
893 #line 334 "../expread.y"
894 { write_exp_elt_opcode (BINOP_MUL
); ;
897 #line 338 "../expread.y"
898 { write_exp_elt_opcode (BINOP_DIV
); ;
901 #line 342 "../expread.y"
902 { write_exp_elt_opcode (BINOP_REM
); ;
905 #line 346 "../expread.y"
906 { write_exp_elt_opcode (BINOP_ADD
); ;
909 #line 350 "../expread.y"
910 { write_exp_elt_opcode (BINOP_SUB
); ;
913 #line 354 "../expread.y"
914 { write_exp_elt_opcode (BINOP_LSH
); ;
917 #line 358 "../expread.y"
918 { write_exp_elt_opcode (BINOP_RSH
); ;
921 #line 362 "../expread.y"
922 { write_exp_elt_opcode (BINOP_EQUAL
); ;
925 #line 366 "../expread.y"
926 { write_exp_elt_opcode (BINOP_NOTEQUAL
); ;
929 #line 370 "../expread.y"
930 { write_exp_elt_opcode (BINOP_LEQ
); ;
933 #line 374 "../expread.y"
934 { write_exp_elt_opcode (BINOP_GEQ
); ;
937 #line 378 "../expread.y"
938 { write_exp_elt_opcode (BINOP_LESS
); ;
941 #line 382 "../expread.y"
942 { write_exp_elt_opcode (BINOP_GTR
); ;
945 #line 386 "../expread.y"
946 { write_exp_elt_opcode (BINOP_LOGAND
); ;
949 #line 390 "../expread.y"
950 { write_exp_elt_opcode (BINOP_LOGXOR
); ;
953 #line 394 "../expread.y"
954 { write_exp_elt_opcode (BINOP_LOGIOR
); ;
957 #line 398 "../expread.y"
958 { write_exp_elt_opcode (BINOP_AND
); ;
961 #line 402 "../expread.y"
962 { write_exp_elt_opcode (BINOP_OR
); ;
965 #line 406 "../expread.y"
966 { write_exp_elt_opcode (TERNOP_COND
); ;
969 #line 410 "../expread.y"
970 { write_exp_elt_opcode (BINOP_ASSIGN
); ;
973 #line 414 "../expread.y"
974 { write_exp_elt_opcode (BINOP_ASSIGN_MODIFY
);
975 write_exp_elt_opcode (yyvsp
[-1].opcode
);
976 write_exp_elt_opcode (BINOP_ASSIGN_MODIFY
); ;
979 #line 420 "../expread.y"
980 { write_exp_elt_opcode (OP_LONG
);
981 if (yyvsp
[0].lval
== (int) yyvsp
[0].lval
|| yyvsp
[0].lval
== (unsigned int) yyvsp
[0].lval
)
982 write_exp_elt_type (builtin_type_int
);
984 write_exp_elt_type (BUILTIN_TYPE_LONGEST
);
985 write_exp_elt_longcst ((LONGEST
) yyvsp
[0].lval
);
986 write_exp_elt_opcode (OP_LONG
); ;
989 #line 430 "../expread.y"
991 parse_number (yyvsp
[0].ssym
.stoken
.ptr
, yyvsp
[0].ssym
.stoken
.length
, 0, &val
);
992 write_exp_elt_opcode (OP_LONG
);
993 if (val
.lval
== (int) val
.lval
||
994 val
.lval
== (unsigned int) val
.lval
)
995 write_exp_elt_type (builtin_type_int
);
997 write_exp_elt_type (BUILTIN_TYPE_LONGEST
);
998 write_exp_elt_longcst (val
.lval
);
999 write_exp_elt_opcode (OP_LONG
); ;
1002 #line 443 "../expread.y"
1004 write_exp_elt_opcode (OP_LONG
);
1005 if (yyvsp
[0].ulval
== (unsigned int) yyvsp
[0].ulval
)
1006 write_exp_elt_type (builtin_type_unsigned_int
);
1008 write_exp_elt_type (BUILTIN_TYPE_UNSIGNED_LONGEST
);
1009 write_exp_elt_longcst ((LONGEST
) yyvsp
[0].ulval
);
1010 write_exp_elt_opcode (OP_LONG
);
1014 #line 455 "../expread.y"
1016 parse_number (yyvsp
[0].ssym
.stoken
.ptr
, yyvsp
[0].ssym
.stoken
.length
, 0, &val
);
1017 write_exp_elt_opcode (OP_LONG
);
1018 if (val
.ulval
== (unsigned int) val
.ulval
)
1019 write_exp_elt_type (builtin_type_unsigned_int
);
1021 write_exp_elt_type (BUILTIN_TYPE_UNSIGNED_LONGEST
);
1022 write_exp_elt_longcst ((LONGEST
)val
.ulval
);
1023 write_exp_elt_opcode (OP_LONG
);
1027 #line 468 "../expread.y"
1028 { write_exp_elt_opcode (OP_LONG
);
1029 write_exp_elt_type (builtin_type_char
);
1030 write_exp_elt_longcst ((LONGEST
) yyvsp
[0].lval
);
1031 write_exp_elt_opcode (OP_LONG
); ;
1034 #line 475 "../expread.y"
1035 { write_exp_elt_opcode (OP_DOUBLE
);
1036 write_exp_elt_type (builtin_type_double
);
1037 write_exp_elt_dblcst (yyvsp
[0].dval
);
1038 write_exp_elt_opcode (OP_DOUBLE
); ;
1041 #line 485 "../expread.y"
1042 { write_exp_elt_opcode (OP_LAST
);
1043 write_exp_elt_longcst ((LONGEST
) yyvsp
[0].lval
);
1044 write_exp_elt_opcode (OP_LAST
); ;
1047 #line 491 "../expread.y"
1048 { write_exp_elt_opcode (OP_REGISTER
);
1049 write_exp_elt_longcst ((LONGEST
) yyvsp
[0].lval
);
1050 write_exp_elt_opcode (OP_REGISTER
); ;
1053 #line 497 "../expread.y"
1054 { write_exp_elt_opcode (OP_INTERNALVAR
);
1055 write_exp_elt_intern (yyvsp
[0].ivar
);
1056 write_exp_elt_opcode (OP_INTERNALVAR
); ;
1059 #line 503 "../expread.y"
1060 { write_exp_elt_opcode (OP_LONG
);
1061 write_exp_elt_type (builtin_type_int
);
1062 write_exp_elt_longcst ((LONGEST
) TYPE_LENGTH (yyvsp
[-1].tval
));
1063 write_exp_elt_opcode (OP_LONG
); ;
1066 #line 510 "../expread.y"
1067 { write_exp_elt_opcode (OP_STRING
);
1068 write_exp_string (yyvsp
[0].sval
);
1069 write_exp_elt_opcode (OP_STRING
); ;
1072 #line 517 "../expread.y"
1073 { write_exp_elt_opcode (OP_THIS
);
1074 write_exp_elt_opcode (OP_THIS
); ;
1077 #line 524 "../expread.y"
1079 if (yyvsp
[0].ssym
.sym
!= 0)
1080 yyval
.bval
= SYMBOL_BLOCK_VALUE (yyvsp
[0].ssym
.sym
);
1083 struct symtab
*tem
=
1084 lookup_symtab (copy_name (yyvsp
[0].ssym
.stoken
));
1086 yyval
.bval
= BLOCKVECTOR_BLOCK
1087 (BLOCKVECTOR (tem
), STATIC_BLOCK
);
1089 error ("No file or function \"%s\".",
1090 copy_name (yyvsp
[0].ssym
.stoken
));
1095 #line 542 "../expread.y"
1096 { struct symbol
*tem
1097 = lookup_symbol (copy_name (yyvsp
[0].sval
), yyvsp
[-2].bval
,
1098 VAR_NAMESPACE
, 0, NULL
);
1099 if (!tem
|| SYMBOL_CLASS (tem
) != LOC_BLOCK
)
1100 error ("No function \"%s\" in specified context.",
1101 copy_name (yyvsp
[0].sval
));
1102 yyval
.bval
= SYMBOL_BLOCK_VALUE (tem
); ;
1105 #line 552 "../expread.y"
1106 { struct symbol
*sym
;
1107 sym
= lookup_symbol (copy_name (yyvsp
[0].sval
), yyvsp
[-2].bval
,
1108 VAR_NAMESPACE
, 0, NULL
);
1110 error ("No symbol \"%s\" in specified context.",
1111 copy_name (yyvsp
[0].sval
));
1112 write_exp_elt_opcode (OP_VAR_VALUE
);
1113 write_exp_elt_sym (sym
);
1114 write_exp_elt_opcode (OP_VAR_VALUE
); ;
1117 #line 564 "../expread.y"
1119 struct type
*type
= yyvsp
[-2].tval
;
1120 if (TYPE_CODE (type
) != TYPE_CODE_STRUCT
1121 && TYPE_CODE (type
) != TYPE_CODE_UNION
)
1122 error ("`%s' is not defined as an aggregate type.",
1125 write_exp_elt_opcode (OP_SCOPE
);
1126 write_exp_elt_type (type
);
1127 write_exp_string (yyvsp
[0].sval
);
1128 write_exp_elt_opcode (OP_SCOPE
);
1132 #line 577 "../expread.y"
1134 struct type
*type
= yyvsp
[-3].tval
;
1135 if (TYPE_CODE (type
) != TYPE_CODE_STRUCT
1136 && TYPE_CODE (type
) != TYPE_CODE_UNION
)
1137 error ("`%s' is not defined as an aggregate type.",
1140 if (strcmp (type_name_no_tag (type
), yyvsp
[0].sval
.ptr
))
1141 error ("invalid destructor `%s::~%s'",
1142 type_name_no_tag (type
), yyvsp
[0].sval
.ptr
);
1144 write_exp_elt_opcode (OP_SCOPE
);
1145 write_exp_elt_type (type
);
1146 write_exp_string (yyvsp
[0].sval
);
1147 write_exp_elt_opcode (OP_SCOPE
);
1148 write_exp_elt_opcode (UNOP_LOGNOT
);
1152 #line 595 "../expread.y"
1154 char *name
= copy_name (yyvsp
[0].sval
);
1159 lookup_symbol (name
, 0, VAR_NAMESPACE
, 0, NULL
);
1162 write_exp_elt_opcode (OP_VAR_VALUE
);
1163 write_exp_elt_sym (sym
);
1164 write_exp_elt_opcode (OP_VAR_VALUE
);
1167 for (i
= 0; i
< misc_function_count
; i
++)
1168 if (!strcmp (misc_function_vector
[i
].name
, name
))
1171 if (i
< misc_function_count
)
1173 enum misc_function_type mft
=
1174 misc_function_vector
[i
].type
;
1176 write_exp_elt_opcode (OP_LONG
);
1177 write_exp_elt_type (builtin_type_int
);
1178 write_exp_elt_longcst ((LONGEST
) misc_function_vector
[i
].address
);
1179 write_exp_elt_opcode (OP_LONG
);
1180 write_exp_elt_opcode (UNOP_MEMVAL
);
1181 if (mft
== mf_data
|| mft
== mf_bss
)
1182 write_exp_elt_type (builtin_type_int
);
1183 else if (mft
== mf_text
)
1184 write_exp_elt_type (lookup_function_type (builtin_type_int
));
1186 write_exp_elt_type (builtin_type_char
);
1187 write_exp_elt_opcode (UNOP_MEMVAL
);
1190 if (symtab_list
== 0
1191 && partial_symtab_list
== 0)
1192 error ("No symbol table is loaded. Use the \"file\" command.");
1194 error ("No symbol \"%s\" in current context.", name
);
1198 #line 641 "../expread.y"
1199 { struct symbol
*sym
= yyvsp
[0].ssym
.sym
;
1209 if (innermost_block
== 0 ||
1210 contained_in (block_found
,
1212 innermost_block
= block_found
;
1214 write_exp_elt_opcode (OP_VAR_VALUE
);
1215 write_exp_elt_sym (sym
);
1216 write_exp_elt_opcode (OP_VAR_VALUE
);
1218 else if (yyvsp
[0].ssym
.is_a_field_of_this
)
1220 /* C++: it hangs off of `this'. Must
1221 not inadvertently convert from a method call
1223 if (innermost_block
== 0 ||
1224 contained_in (block_found
, innermost_block
))
1225 innermost_block
= block_found
;
1226 write_exp_elt_opcode (OP_THIS
);
1227 write_exp_elt_opcode (OP_THIS
);
1228 write_exp_elt_opcode (STRUCTOP_PTR
);
1229 write_exp_string (yyvsp
[0].ssym
.stoken
);
1230 write_exp_elt_opcode (STRUCTOP_PTR
);
1235 register char *arg
= copy_name (yyvsp
[0].ssym
.stoken
);
1237 /* FIXME, this search is linear! At least
1238 optimize the strcmp with a 1-char cmp... */
1239 for (i
= 0; i
< misc_function_count
; i
++)
1240 if (!strcmp (misc_function_vector
[i
].name
, arg
))
1243 if (i
< misc_function_count
)
1245 enum misc_function_type mft
=
1246 misc_function_vector
[i
].type
;
1248 write_exp_elt_opcode (OP_LONG
);
1249 write_exp_elt_type (builtin_type_int
);
1250 write_exp_elt_longcst ((LONGEST
) misc_function_vector
[i
].address
);
1251 write_exp_elt_opcode (OP_LONG
);
1252 write_exp_elt_opcode (UNOP_MEMVAL
);
1253 if (mft
== mf_data
|| mft
== mf_bss
)
1254 write_exp_elt_type (builtin_type_int
);
1255 else if (mft
== mf_text
)
1256 write_exp_elt_type (lookup_function_type (builtin_type_int
));
1258 write_exp_elt_type (builtin_type_char
);
1259 write_exp_elt_opcode (UNOP_MEMVAL
);
1261 else if (symtab_list
== 0
1262 && partial_symtab_list
== 0)
1263 error ("No symbol table is loaded. Use the \"file\" command.");
1265 error ("No symbol \"%s\" in current context.",
1266 copy_name (yyvsp
[0].ssym
.stoken
));
1271 #line 716 "../expread.y"
1273 /* This is where the interesting stuff happens. */
1276 struct type
*follow_type
= yyvsp
[-1].tval
;
1279 switch (pop_type ())
1285 follow_type
= lookup_pointer_type (follow_type
);
1288 follow_type
= lookup_reference_type (follow_type
);
1291 array_size
= (int) pop_type ();
1292 if (array_size
!= -1)
1293 follow_type
= create_array_type (follow_type
,
1296 follow_type
= lookup_pointer_type (follow_type
);
1299 follow_type
= lookup_function_type (follow_type
);
1302 yyval
.tval
= follow_type
;
1306 #line 751 "../expread.y"
1307 { push_type (tp_pointer
); yyval
.voidval
= 0; ;
1310 #line 753 "../expread.y"
1311 { push_type (tp_pointer
); yyval
.voidval
= yyvsp
[0].voidval
; ;
1314 #line 755 "../expread.y"
1315 { push_type (tp_reference
); yyval
.voidval
= 0; ;
1318 #line 757 "../expread.y"
1319 { push_type (tp_reference
); yyval
.voidval
= yyvsp
[0].voidval
; ;
1322 #line 762 "../expread.y"
1323 { yyval
.voidval
= yyvsp
[-1].voidval
; ;
1326 #line 764 "../expread.y"
1328 push_type ((enum type_pieces
) yyvsp
[0].lval
);
1329 push_type (tp_array
);
1333 #line 769 "../expread.y"
1335 push_type ((enum type_pieces
) yyvsp
[0].lval
);
1336 push_type (tp_array
);
1341 #line 775 "../expread.y"
1342 { push_type (tp_function
); ;
1345 #line 777 "../expread.y"
1346 { push_type (tp_function
); ;
1349 #line 781 "../expread.y"
1350 { yyval
.lval
= -1; ;
1353 #line 783 "../expread.y"
1354 { yyval
.lval
= yyvsp
[-1].lval
; ;
1357 #line 787 "../expread.y"
1358 { yyval
.voidval
= 0; ;
1361 #line 792 "../expread.y"
1362 { yyval
.tval
= lookup_member_type (builtin_type_int
, yyvsp
[-2].tval
); ;
1365 #line 794 "../expread.y"
1366 { yyval
.tval
= lookup_member_type (yyvsp
[-5].tval
, yyvsp
[-3].tval
); ;
1369 #line 796 "../expread.y"
1370 { yyval
.tval
= lookup_member_type
1371 (lookup_function_type (yyvsp
[-7].tval
), yyvsp
[-5].tval
); ;
1374 #line 799 "../expread.y"
1375 { yyval
.tval
= lookup_member_type
1376 (lookup_function_type (yyvsp
[-8].tval
), yyvsp
[-6].tval
);
1377 free (yyvsp
[-1].tvec
); ;
1380 #line 806 "../expread.y"
1381 { yyval
.tval
= yyvsp
[0].tsym
.type
; ;
1384 #line 808 "../expread.y"
1385 { yyval
.tval
= builtin_type_int
; ;
1388 #line 810 "../expread.y"
1389 { yyval
.tval
= builtin_type_long
; ;
1392 #line 812 "../expread.y"
1393 { yyval
.tval
= builtin_type_short
; ;
1396 #line 814 "../expread.y"
1397 { yyval
.tval
= builtin_type_long
; ;
1400 #line 816 "../expread.y"
1401 { yyval
.tval
= builtin_type_unsigned_long
; ;
1404 #line 818 "../expread.y"
1405 { yyval
.tval
= builtin_type_long_long
; ;
1408 #line 820 "../expread.y"
1409 { yyval
.tval
= builtin_type_long_long
; ;
1412 #line 822 "../expread.y"
1413 { yyval
.tval
= builtin_type_unsigned_long_long
; ;
1416 #line 824 "../expread.y"
1417 { yyval
.tval
= builtin_type_unsigned_long_long
; ;
1420 #line 826 "../expread.y"
1421 { yyval
.tval
= builtin_type_short
; ;
1424 #line 828 "../expread.y"
1425 { yyval
.tval
= builtin_type_unsigned_short
; ;
1428 #line 830 "../expread.y"
1429 { yyval
.tval
= lookup_struct (copy_name (yyvsp
[0].sval
),
1430 expression_context_block
); ;
1433 #line 833 "../expread.y"
1434 { yyval
.tval
= lookup_union (copy_name (yyvsp
[0].sval
),
1435 expression_context_block
); ;
1438 #line 836 "../expread.y"
1439 { yyval
.tval
= lookup_enum (copy_name (yyvsp
[0].sval
),
1440 expression_context_block
); ;
1443 #line 839 "../expread.y"
1444 { yyval
.tval
= lookup_unsigned_typename (TYPE_NAME(yyvsp
[0].tsym
.type
)); ;
1447 #line 841 "../expread.y"
1448 { yyval
.tval
= builtin_type_unsigned_int
; ;
1451 #line 843 "../expread.y"
1452 { yyval
.tval
= yyvsp
[0].tsym
.type
; ;
1455 #line 845 "../expread.y"
1456 { yyval
.tval
= builtin_type_int
; ;
1459 #line 850 "../expread.y"
1461 yyval
.tsym
.stoken
.ptr
= "int";
1462 yyval
.tsym
.stoken
.length
= 3;
1463 yyval
.tsym
.type
= builtin_type_int
;
1467 #line 856 "../expread.y"
1469 yyval
.tsym
.stoken
.ptr
= "long";
1470 yyval
.tsym
.stoken
.length
= 4;
1471 yyval
.tsym
.type
= builtin_type_long
;
1475 #line 862 "../expread.y"
1477 yyval
.tsym
.stoken
.ptr
= "short";
1478 yyval
.tsym
.stoken
.length
= 5;
1479 yyval
.tsym
.type
= builtin_type_short
;
1483 #line 871 "../expread.y"
1484 { yyval
.tvec
= (struct type
**)xmalloc (sizeof (struct type
*) * 2);
1485 yyval
.tvec
[0] = (struct type
*)0;
1486 yyval
.tvec
[1] = yyvsp
[0].tval
;
1490 #line 876 "../expread.y"
1491 { int len
= sizeof (struct type
*) * ++(yyvsp
[-2].ivec
[0]);
1492 yyval
.tvec
= (struct type
**)xrealloc (yyvsp
[-2].tvec
, len
);
1493 yyval
.tvec
[yyval
.ivec
[0]] = yyvsp
[0].tval
;
1497 #line 882 "../expread.y"
1498 { yyval
.sval
= yyvsp
[0].ssym
.stoken
; ;
1501 #line 883 "../expread.y"
1502 { yyval
.sval
= yyvsp
[0].ssym
.stoken
; ;
1505 #line 884 "../expread.y"
1506 { yyval
.sval
= yyvsp
[0].tsym
.stoken
; ;
1509 #line 885 "../expread.y"
1510 { yyval
.sval
= yyvsp
[0].ssym
.stoken
; ;
1513 #line 886 "../expread.y"
1514 { yyval
.sval
= yyvsp
[0].ssym
.stoken
; ;
1517 /* the action file gets copied in in place of this dollarsign */
1518 #line 327 "bison.simple"
1529 short *ssp1
= yyss
- 1;
1530 fprintf (stderr
, "state stack now");
1531 while (ssp1
!= yyssp
)
1532 fprintf (stderr
, " %d", *++ssp1
);
1533 fprintf (stderr
, "\n");
1543 yylsp
->first_line
= yylloc
.first_line
;
1544 yylsp
->first_column
= yylloc
.first_column
;
1545 yylsp
->last_line
= (yylsp
-1)->last_line
;
1546 yylsp
->last_column
= (yylsp
-1)->last_column
;
1551 yylsp
->last_line
= (yylsp
+yylen
-1)->last_line
;
1552 yylsp
->last_column
= (yylsp
+yylen
-1)->last_column
;
1556 /* Now "shift" the result of the reduction.
1557 Determine what state that goes to,
1558 based on the state we popped back to
1559 and the rule number reduced by. */
1563 yystate
= yypgoto
[yyn
- YYNTBASE
] + *yyssp
;
1564 if (yystate
>= 0 && yystate
<= YYLAST
&& yycheck
[yystate
] == *yyssp
)
1565 yystate
= yytable
[yystate
];
1567 yystate
= yydefgoto
[yyn
- YYNTBASE
];
1571 yyerrlab
: /* here on detecting error */
1574 /* If not already recovering from an error, report this error. */
1577 yyerror("parse error");
1580 if (yyerrstatus
== 3)
1582 /* if just tried and failed to reuse lookahead token after an error, discard it. */
1584 /* return failure if at end of input */
1585 if (yychar
== YYEOF
)
1590 fprintf(stderr
, "Discarding token %d (%s).\n", yychar
, yytname
[yychar1
]);
1596 /* Else will try to reuse lookahead token
1597 after shifting the error token. */
1599 yyerrstatus
= 3; /* Each real token shifted decrements this */
1603 yyerrdefault
: /* current state does not do anything special for the error token. */
1606 /* This is wrong; only states that explicitly want error tokens
1607 should shift them. */
1608 yyn
= yydefact
[yystate
]; /* If its default is to accept any token, ok. Otherwise pop it.*/
1609 if (yyn
) goto yydefault
;
1612 yyerrpop
: /* pop the current state because it cannot handle the error token */
1614 if (yyssp
== yyss
) YYABORT
;
1624 short *ssp1
= yyss
- 1;
1625 fprintf (stderr
, "Error: state stack now");
1626 while (ssp1
!= yyssp
)
1627 fprintf (stderr
, " %d", *++ssp1
);
1628 fprintf (stderr
, "\n");
1634 yyn
= yypact
[yystate
];
1639 if (yyn
< 0 || yyn
> YYLAST
|| yycheck
[yyn
] != YYTERROR
)
1658 fprintf(stderr
, "Shifting error token, ");
1669 #line 901 "../expread.y"
1672 /* Begin counting arguments for a function call,
1673 saving the data about any containing call. */
1678 register struct funcall
*new = (struct funcall
*) xmalloc (sizeof (struct funcall
));
1680 new->next
= funcall_chain
;
1681 new->arglist_len
= arglist_len
;
1683 funcall_chain
= new;
1686 /* Return the number of arguments in a function call just terminated,
1687 and restore the data for the containing function call. */
1692 register int val
= arglist_len
;
1693 register struct funcall
*call
= funcall_chain
;
1694 funcall_chain
= call
->next
;
1695 arglist_len
= call
->arglist_len
;
1700 /* Free everything in the funcall chain.
1701 Used when there is an error inside parsing. */
1706 register struct funcall
*call
, *next
;
1708 for (call
= funcall_chain
; call
; call
= next
)
1715 /* This page contains the functions for adding data to the struct expression
1716 being constructed. */
1718 /* Add one element to the end of the expression. */
1720 /* To avoid a bug in the Sun 4 compiler, we pass things that can fit into
1721 a register through here */
1724 write_exp_elt (expelt
)
1725 union exp_element expelt
;
1727 if (expout_ptr
>= expout_size
)
1730 expout
= (struct expression
*) xrealloc (expout
,
1731 sizeof (struct expression
)
1732 + expout_size
* sizeof (union exp_element
));
1734 expout
->elts
[expout_ptr
++] = expelt
;
1738 write_exp_elt_opcode (expelt
)
1739 enum exp_opcode expelt
;
1741 union exp_element tmp
;
1743 tmp
.opcode
= expelt
;
1745 write_exp_elt (tmp
);
1749 write_exp_elt_sym (expelt
)
1750 struct symbol
*expelt
;
1752 union exp_element tmp
;
1754 tmp
.symbol
= expelt
;
1756 write_exp_elt (tmp
);
1760 write_exp_elt_longcst (expelt
)
1763 union exp_element tmp
;
1765 tmp
.longconst
= expelt
;
1767 write_exp_elt (tmp
);
1771 write_exp_elt_dblcst (expelt
)
1774 union exp_element tmp
;
1776 tmp
.doubleconst
= expelt
;
1778 write_exp_elt (tmp
);
1782 write_exp_elt_type (expelt
)
1783 struct type
*expelt
;
1785 union exp_element tmp
;
1789 write_exp_elt (tmp
);
1793 write_exp_elt_intern (expelt
)
1794 struct internalvar
*expelt
;
1796 union exp_element tmp
;
1798 tmp
.internalvar
= expelt
;
1800 write_exp_elt (tmp
);
1803 /* Add a string constant to the end of the expression.
1804 Follow it by its length in bytes, as a separate exp_element. */
1807 write_exp_string (str
)
1810 register int len
= str
.length
;
1812 = (len
+ sizeof (union exp_element
)) / sizeof (union exp_element
);
1814 expout_ptr
+= lenelt
;
1816 if (expout_ptr
>= expout_size
)
1818 expout_size
= max (expout_size
* 2, expout_ptr
+ 10);
1819 expout
= (struct expression
*)
1820 xrealloc (expout
, (sizeof (struct expression
)
1821 + (expout_size
* sizeof (union exp_element
))));
1823 bcopy (str
.ptr
, (char *) &expout
->elts
[expout_ptr
- lenelt
], len
);
1824 ((char *) &expout
->elts
[expout_ptr
- lenelt
])[len
] = 0;
1825 write_exp_elt_longcst ((LONGEST
) len
);
1828 /* During parsing of a C expression, the pointer to the next character
1829 is in this variable. */
1831 static char *lexptr
;
1833 /* Tokens that refer to names do so with explicit pointer and length,
1834 so they can share the storage that lexptr is parsing.
1836 When it is necessary to pass a name to a function that expects
1837 a null-terminated string, the substring is copied out
1838 into a block of storage that namecopy points to.
1840 namecopy is allocated once, guaranteed big enough, for each parsing. */
1842 static char *namecopy
;
1844 /* Current depth in parentheses within the expression. */
1846 static int paren_depth
;
1848 /* Nonzero means stop parsing on first comma (if not within parentheses). */
1850 static int comma_terminates
;
1852 /* Take care of parsing a number (anything that starts with a digit).
1853 Set yylval and return the token type; update lexptr.
1854 LEN is the number of characters in it. */
1856 /*** Needs some error checking for the float case ***/
1859 parse_number (p
, len
, parsed_float
, putithere
)
1865 register LONGEST n
= 0;
1868 register int base
= input_radix
;
1871 extern double atof ();
1875 /* It's a float since it contains a point or an exponent. */
1876 putithere
->dval
= atof (p
);
1880 /* Handle base-switching prefixes 0x, 0t, 0d, 0 */
1914 if (c
>= 'A' && c
<= 'Z')
1916 if (c
!= 'l' && c
!= 'u')
1918 if (c
>= '0' && c
<= '9')
1922 if (base
> 10 && c
>= 'a' && c
<= 'f')
1923 n
+= i
= c
- 'a' + 10;
1924 else if (len
== 0 && c
== 'l')
1926 else if (len
== 0 && c
== 'u')
1929 return ERROR
; /* Char not a digit */
1932 return ERROR
; /* Invalid digit in this base */
1937 putithere
->ulval
= n
;
1942 putithere
->lval
= n
;
1951 enum exp_opcode opcode
;
1954 const static struct token tokentab3
[] =
1956 {">>=", ASSIGN_MODIFY
, BINOP_RSH
},
1957 {"<<=", ASSIGN_MODIFY
, BINOP_LSH
}
1960 const static struct token tokentab2
[] =
1962 {"+=", ASSIGN_MODIFY
, BINOP_ADD
},
1963 {"-=", ASSIGN_MODIFY
, BINOP_SUB
},
1964 {"*=", ASSIGN_MODIFY
, BINOP_MUL
},
1965 {"/=", ASSIGN_MODIFY
, BINOP_DIV
},
1966 {"%=", ASSIGN_MODIFY
, BINOP_REM
},
1967 {"|=", ASSIGN_MODIFY
, BINOP_LOGIOR
},
1968 {"&=", ASSIGN_MODIFY
, BINOP_LOGAND
},
1969 {"^=", ASSIGN_MODIFY
, BINOP_LOGXOR
},
1970 {"++", INCREMENT
, BINOP_END
},
1971 {"--", DECREMENT
, BINOP_END
},
1972 {"->", ARROW
, BINOP_END
},
1973 {"&&", AND
, BINOP_END
},
1974 {"||", OR
, BINOP_END
},
1975 {"::", COLONCOLON
, BINOP_END
},
1976 {"<<", LSH
, BINOP_END
},
1977 {">>", RSH
, BINOP_END
},
1978 {"==", EQUAL
, BINOP_END
},
1979 {"!=", NOTEQUAL
, BINOP_END
},
1980 {"<=", LEQ
, BINOP_END
},
1981 {">=", GEQ
, BINOP_END
}
1984 /* assign machine-independent names to certain registers
1985 * (unless overridden by the REGISTER_NAMES table)
1992 { "pc", PC_REGNUM
},
1995 { "fp", FP_REGNUM
},
1998 { "sp", SP_REGNUM
},
2001 { "ps", PS_REGNUM
},
2005 #define NUM_STD_REGS (sizeof std_regs / sizeof std_regs[0])
2007 /* Read one token, getting characters through lexptr. */
2013 register int namelen
;
2014 register unsigned i
;
2015 register char *tokstart
;
2020 /* See if it is a special token of length 3. */
2021 for (i
= 0; i
< sizeof tokentab3
/ sizeof tokentab3
[0]; i
++)
2022 if (!strncmp (tokstart
, tokentab3
[i
].operator, 3))
2025 yylval
.opcode
= tokentab3
[i
].opcode
;
2026 return tokentab3
[i
].token
;
2029 /* See if it is a special token of length 2. */
2030 for (i
= 0; i
< sizeof tokentab2
/ sizeof tokentab2
[0]; i
++)
2031 if (!strncmp (tokstart
, tokentab2
[i
].operator, 2))
2034 yylval
.opcode
= tokentab2
[i
].opcode
;
2035 return tokentab2
[i
].token
;
2038 switch (c
= *tokstart
)
2053 c
= parse_escape (&lexptr
);
2057 error ("Invalid character constant.");
2066 if (paren_depth
== 0)
2073 if (comma_terminates
&& paren_depth
== 0)
2079 /* Might be a floating point number. */
2080 if (lexptr
[1] < '0' || lexptr
[1] > '9')
2081 goto symbol
; /* Nope, must be a symbol. */
2082 /* FALL THRU into number case. */
2095 /* It's a number. */
2096 int got_dot
= 0, got_e
= 0, toktype
;
2097 register char *p
= tokstart
;
2098 int hex
= input_radix
> 10;
2100 if (c
== '0' && (p
[1] == 'x' || p
[1] == 'X'))
2105 else if (c
== '0' && (p
[1]=='t' || p
[1]=='T' || p
[1]=='d' || p
[1]=='D'))
2113 if (!hex
&& !got_e
&& (*p
== 'e' || *p
== 'E'))
2114 got_dot
= got_e
= 1;
2115 else if (!hex
&& !got_dot
&& *p
== '.')
2117 else if (got_e
&& (p
[-1] == 'e' || p
[-1] == 'E')
2118 && (*p
== '-' || *p
== '+'))
2119 /* This is the sign of the exponent, not the end of the
2122 /* We will take any letters or digits. parse_number will
2123 complain if past the radix, or if L or U are not final. */
2124 else if ((*p
< '0' || *p
> '9')
2125 && ((*p
< 'a' || *p
> 'z')
2126 && (*p
< 'A' || *p
> 'Z')))
2129 toktype
= parse_number (tokstart
, p
- tokstart
, got_dot
|got_e
, &yylval
);
2130 if (toktype
== ERROR
)
2132 char *err_copy
= (char *) alloca (p
- tokstart
+ 1);
2134 bcopy (tokstart
, err_copy
, p
- tokstart
);
2135 err_copy
[p
- tokstart
] = 0;
2136 error ("Invalid number \"%s\".", err_copy
);
2167 for (namelen
= 1; (c
= tokstart
[namelen
]) != '"'; namelen
++)
2170 c
= tokstart
[++namelen
];
2171 if (c
>= '0' && c
<= '9')
2173 c
= tokstart
[++namelen
];
2174 if (c
>= '0' && c
<= '9')
2175 c
= tokstart
[++namelen
];
2178 yylval
.sval
.ptr
= tokstart
+ 1;
2179 yylval
.sval
.length
= namelen
- 1;
2180 lexptr
+= namelen
+ 1;
2184 if (!(c
== '_' || c
== '$'
2185 || (c
>= 'a' && c
<= 'z') || (c
>= 'A' && c
<= 'Z')))
2186 /* We must have come across a bad character (e.g. ';'). */
2187 error ("Invalid character '%c' in expression.", c
);
2189 /* It's a name. See how long it is. */
2191 for (c
= tokstart
[namelen
];
2192 (c
== '_' || c
== '$' || (c
>= '0' && c
<= '9')
2193 || (c
>= 'a' && c
<= 'z') || (c
>= 'A' && c
<= 'Z'));
2194 c
= tokstart
[++namelen
])
2197 /* The token "if" terminates the expression and is NOT
2198 removed from the input stream. */
2199 if (namelen
== 2 && tokstart
[0] == 'i' && tokstart
[1] == 'f')
2206 /* Handle the tokens $digits; also $ (short for $0) and $$ (short for $$1)
2207 and $$digits (equivalent to $<-digits> if you could type that).
2208 Make token type LAST, and put the number (the digits) in yylval. */
2210 if (*tokstart
== '$')
2212 register int negate
= 0;
2214 /* Double dollar means negate the number and add -1 as well.
2215 Thus $$ alone means -1. */
2216 if (namelen
>= 2 && tokstart
[1] == '$')
2223 /* Just dollars (one or two) */
2224 yylval
.lval
= - negate
;
2227 /* Is the rest of the token digits? */
2228 for (; c
< namelen
; c
++)
2229 if (!(tokstart
[c
] >= '0' && tokstart
[c
] <= '9'))
2233 yylval
.lval
= atoi (tokstart
+ 1 + negate
);
2235 yylval
.lval
= - yylval
.lval
;
2240 /* Handle tokens that refer to machine registers:
2241 $ followed by a register name. */
2243 if (*tokstart
== '$') {
2244 for (c
= 0; c
< NUM_REGS
; c
++)
2245 if (namelen
- 1 == strlen (reg_names
[c
])
2246 && !strncmp (tokstart
+ 1, reg_names
[c
], namelen
- 1))
2251 for (c
= 0; c
< NUM_STD_REGS
; c
++)
2252 if (namelen
- 1 == strlen (std_regs
[c
].name
)
2253 && !strncmp (tokstart
+ 1, std_regs
[c
].name
, namelen
- 1))
2255 yylval
.lval
= std_regs
[c
].regnum
;
2259 /* Catch specific keywords. Should be done with a data structure. */
2263 if (!strncmp (tokstart
, "unsigned", 8))
2267 if (!strncmp (tokstart
, "struct", 6))
2269 if (!strncmp (tokstart
, "signed", 6))
2271 if (!strncmp (tokstart
, "sizeof", 6))
2275 if (!strncmp (tokstart
, "union", 5))
2277 if (!strncmp (tokstart
, "short", 5))
2281 if (!strncmp (tokstart
, "enum", 4))
2283 if (!strncmp (tokstart
, "long", 4))
2285 if (!strncmp (tokstart
, "this", 4))
2287 static const char this_name
[] =
2288 { CPLUS_MARKER
, 't', 'h', 'i', 's', '\0' };
2290 if (lookup_symbol (this_name
, expression_context_block
,
2291 VAR_NAMESPACE
, 0, NULL
))
2296 if (!strncmp (tokstart
, "int", 3))
2303 yylval
.sval
.ptr
= tokstart
;
2304 yylval
.sval
.length
= namelen
;
2306 /* Any other names starting in $ are debugger internal variables. */
2308 if (*tokstart
== '$')
2310 yylval
.ivar
= lookup_internalvar (copy_name (yylval
.sval
) + 1);
2314 /* Use token-type BLOCKNAME for symbols that happen to be defined as
2315 functions or symtabs. If this is not so, then ...
2316 Use token-type TYPENAME for symbols that happen to be defined
2317 currently as names of types; NAME for other symbols.
2318 The caller is not constrained to care about the distinction. */
2320 char *tmp
= copy_name (yylval
.sval
);
2322 int is_a_field_of_this
= 0;
2325 sym
= lookup_symbol (tmp
, expression_context_block
,
2326 VAR_NAMESPACE
, &is_a_field_of_this
, NULL
);
2327 if ((sym
&& SYMBOL_CLASS (sym
) == LOC_BLOCK
) ||
2328 lookup_partial_symtab (tmp
))
2330 yylval
.ssym
.sym
= sym
;
2331 yylval
.ssym
.is_a_field_of_this
= is_a_field_of_this
;
2334 if (sym
&& SYMBOL_CLASS (sym
) == LOC_TYPEDEF
)
2336 yylval
.tsym
.type
= SYMBOL_TYPE (sym
);
2339 if ((yylval
.tsym
.type
= lookup_primitive_typename (tmp
)) != 0)
2342 /* Input names that aren't symbols but ARE valid hex numbers,
2343 when the input radix permits them, can be names or numbers
2344 depending on the parse. Note we support radixes > 16 here. */
2346 ((tokstart
[0] >= 'a' && tokstart
[0] < 'a' + input_radix
- 10) ||
2347 (tokstart
[0] >= 'A' && tokstart
[0] < 'A' + input_radix
- 10)))
2349 YYSTYPE newlval
; /* Its value is ignored. */
2350 hextype
= parse_number (tokstart
, namelen
, 0, &newlval
);
2353 yylval
.ssym
.sym
= sym
;
2354 yylval
.ssym
.is_a_field_of_this
= is_a_field_of_this
;
2357 if (hextype
== UINT
)
2359 yylval
.ssym
.sym
= sym
;
2360 yylval
.ssym
.is_a_field_of_this
= is_a_field_of_this
;
2361 return NAME_OR_UINT
;
2365 /* Any other kind of symbol */
2366 yylval
.ssym
.sym
= sym
;
2367 yylval
.ssym
.is_a_field_of_this
= is_a_field_of_this
;
2376 error ("Invalid syntax in expression.");
2379 /* Return a null-terminated temporary copy of the name
2380 of a string token. */
2384 struct stoken token
;
2386 bcopy (token
.ptr
, namecopy
, token
.length
);
2387 namecopy
[token
.length
] = 0;
2391 /* Reverse an expression from suffix form (in which it is constructed)
2392 to prefix form (in which we can conveniently print or execute it). */
2394 static void prefixify_subexp ();
2397 prefixify_expression (expr
)
2398 register struct expression
*expr
;
2400 register int len
= sizeof (struct expression
) +
2401 expr
->nelts
* sizeof (union exp_element
);
2402 register struct expression
*temp
;
2403 register int inpos
= expr
->nelts
, outpos
= 0;
2405 temp
= (struct expression
*) alloca (len
);
2407 /* Copy the original expression into temp. */
2408 bcopy (expr
, temp
, len
);
2410 prefixify_subexp (temp
, expr
, inpos
, outpos
);
2413 /* Return the number of exp_elements in the subexpression of EXPR
2414 whose last exp_element is at index ENDPOS - 1 in EXPR. */
2417 length_of_subexp (expr
, endpos
)
2418 register struct expression
*expr
;
2419 register int endpos
;
2421 register int oplen
= 1;
2422 register int args
= 0;
2426 error ("?error in length_of_subexp");
2428 i
= (int) expr
->elts
[endpos
- 1].opcode
;
2434 oplen
= 4 + ((expr
->elts
[endpos
- 2].longconst
2435 + sizeof (union exp_element
))
2436 / sizeof (union exp_element
));
2447 case OP_INTERNALVAR
:
2453 args
= 1 + expr
->elts
[endpos
- 2].longconst
;
2462 case STRUCTOP_STRUCT
:
2466 oplen
= 3 + ((expr
->elts
[endpos
- 2].longconst
2467 + sizeof (union exp_element
))
2468 / sizeof (union exp_element
));
2475 case BINOP_ASSIGN_MODIFY
:
2486 args
= 1 + (i
< (int) BINOP_END
);
2491 oplen
+= length_of_subexp (expr
, endpos
- oplen
);
2498 /* Copy the subexpression ending just before index INEND in INEXPR
2499 into OUTEXPR, starting at index OUTBEG.
2500 In the process, convert it from suffix to prefix form. */
2503 prefixify_subexp (inexpr
, outexpr
, inend
, outbeg
)
2504 register struct expression
*inexpr
;
2505 struct expression
*outexpr
;
2509 register int oplen
= 1;
2510 register int args
= 0;
2513 enum exp_opcode opcode
;
2515 /* Compute how long the last operation is (in OPLEN),
2516 and also how many preceding subexpressions serve as
2517 arguments for it (in ARGS). */
2519 opcode
= inexpr
->elts
[inend
- 1].opcode
;
2524 oplen
= 4 + ((inexpr
->elts
[inend
- 2].longconst
2525 + sizeof (union exp_element
))
2526 / sizeof (union exp_element
));
2537 case OP_INTERNALVAR
:
2543 args
= 1 + inexpr
->elts
[inend
- 2].longconst
;
2552 case STRUCTOP_STRUCT
:
2556 oplen
= 3 + ((inexpr
->elts
[inend
- 2].longconst
2557 + sizeof (union exp_element
))
2558 / sizeof (union exp_element
));
2566 case BINOP_ASSIGN_MODIFY
:
2577 args
= 1 + ((int) opcode
< (int) BINOP_END
);
2580 /* Copy the final operator itself, from the end of the input
2581 to the beginning of the output. */
2583 bcopy (&inexpr
->elts
[inend
], &outexpr
->elts
[outbeg
],
2584 oplen
* sizeof (union exp_element
));
2587 /* Find the lengths of the arg subexpressions. */
2588 arglens
= (int *) alloca (args
* sizeof (int));
2589 for (i
= args
- 1; i
>= 0; i
--)
2591 oplen
= length_of_subexp (inexpr
, inend
);
2596 /* Now copy each subexpression, preserving the order of
2597 the subexpressions, but prefixifying each one.
2598 In this loop, inend starts at the beginning of
2599 the expression this level is working on
2600 and marches forward over the arguments.
2601 outbeg does similarly in the output. */
2602 for (i
= 0; i
< args
; i
++)
2606 prefixify_subexp (inexpr
, outexpr
, inend
, outbeg
);
2611 /* This page contains the two entry points to this file. */
2613 /* Read a C expression from the string *STRINGPTR points to,
2614 parse it, and return a pointer to a struct expression that we malloc.
2615 Use block BLOCK as the lexical context for variable names;
2616 if BLOCK is zero, use the block of the selected stack frame.
2617 Meanwhile, advance *STRINGPTR to point after the expression,
2618 at the first nonwhite character that is not part of the expression
2619 (possibly a null character).
2621 If COMMA is nonzero, stop if a comma is reached. */
2624 parse_c_1 (stringptr
, block
, comma
)
2626 struct block
*block
;
2629 struct cleanup
*old_chain
;
2631 lexptr
= *stringptr
;
2634 type_stack_depth
= 0;
2636 comma_terminates
= comma
;
2638 if (lexptr
== 0 || *lexptr
== 0)
2639 error_no_arg ("expression to compute");
2641 old_chain
= make_cleanup (free_funcalls
, 0);
2644 expression_context_block
= block
? block
: get_selected_block ();
2646 namecopy
= (char *) alloca (strlen (lexptr
) + 1);
2649 expout
= (struct expression
*)
2650 xmalloc (sizeof (struct expression
)
2651 + expout_size
* sizeof (union exp_element
));
2652 make_cleanup (free_current_contents
, &expout
);
2655 discard_cleanups (old_chain
);
2656 expout
->nelts
= expout_ptr
;
2657 expout
= (struct expression
*)
2659 sizeof (struct expression
)
2660 + expout_ptr
* sizeof (union exp_element
));
2661 prefixify_expression (expout
);
2662 *stringptr
= lexptr
;
2666 /* Parse STRING as an expression, and complain if this fails
2667 to use up all of the contents of STRING. */
2670 parse_c_expression (string
)
2673 register struct expression
*exp
;
2674 exp
= parse_c_1 (&string
, 0, 0);
2676 error ("Junk after end of expression.");
2682 enum type_pieces tp
;
2684 if (type_stack_depth
== type_stack_size
)
2686 type_stack_size
*= 2;
2687 type_stack
= (enum type_pieces
*)
2688 xrealloc (type_stack
, type_stack_size
* sizeof (enum type_pieces
));
2690 type_stack
[type_stack_depth
++] = tp
;
2693 static enum type_pieces
2696 if (type_stack_depth
)
2697 return type_stack
[--type_stack_depth
];
2702 _initialize_expread ()
2704 type_stack_size
= 80;
2705 type_stack_depth
= 0;
2706 type_stack
= (enum type_pieces
*)
2707 xmalloc (type_stack_size
* sizeof (enum type_pieces
));