1 /* A Bison parser, made by GNU Bison 1.875c. */
2
3 /* Skeleton parser for Yacc-like parsing with Bison,
4 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
20
21 /* As a special exception, when this file is copied by Bison into a
22 Bison output file, you may use that output file without restriction.
23 This special exception was added by the Free Software Foundation
24 in version 1.24 of Bison. */
25
26 /* Written by Richard Stallman by simplifying the original so called
27 ``semantic'' parser. */
28
29 /* All symbols defined below should begin with yy or YY, to avoid
30 infringing on user name space. This should be done even for local
31 variables, as they might otherwise be expanded by user macros.
32 There are some unavoidable exceptions within include files to
33 define necessary library symbols; they are noted "INFRINGES ON
34 USER NAME SPACE" below. */
35
36 /* Identify Bison output. */
37 #define YYBISON 1
38
39 /* Skeleton name. */
40 #define YYSKELETON_NAME "yacc.c"
41
42 /* Pure parsers. */
43 #define YYPURE 0
44
45 /* Using locations. */
46 #define YYLSP_NEEDED 0
47
48
49
50 /* Tokens. */
51 #ifndef YYTOKENTYPE
52 # define YYTOKENTYPE
53 /* Put the tokens into the symbol table, so that GDB and other debuggers
54 know about them. */
55 enum yytokentype {
56 INT = 258,
57 FLOAT = 259,
58 STRING = 260,
59 NAME = 261,
60 TYPENAME = 262,
61 NAME_OR_INT = 263,
62 STRUCT = 264,
63 CLASS = 265,
64 UNION = 266,
65 ENUM = 267,
66 SIZEOF = 268,
67 UNSIGNED = 269,
68 COLONCOLON = 270,
69 TEMPLATE = 271,
70 ERROR = 272,
71 SIGNED_KEYWORD = 273,
72 LONG = 274,
73 SHORT = 275,
74 INT_KEYWORD = 276,
75 CONST_KEYWORD = 277,
76 VOLATILE_KEYWORD = 278,
77 DOUBLE_KEYWORD = 279,
78 VARIABLE = 280,
79 ASSIGN_MODIFY = 281,
80 TRUEKEYWORD = 282,
81 FALSEKEYWORD = 283,
82 ABOVE_COMMA = 284,
83 OROR = 285,
84 ANDAND = 286,
85 NOTEQUAL = 287,
86 EQUAL = 288,
87 GEQ = 289,
88 LEQ = 290,
89 RSH = 291,
90 LSH = 292,
91 DECREMENT = 293,
92 INCREMENT = 294,
93 UNARY = 295,
94 ARROW = 296,
95 BLOCKNAME = 297,
96 FILENAME = 298
97 };
98 #endif
99 #define INT 258
100 #define FLOAT 259
101 #define STRING 260
102 #define NAME 261
103 #define TYPENAME 262
104 #define NAME_OR_INT 263
105 #define STRUCT 264
106 #define CLASS 265
107 #define UNION 266
108 #define ENUM 267
109 #define SIZEOF 268
110 #define UNSIGNED 269
111 #define COLONCOLON 270
112 #define TEMPLATE 271
113 #define ERROR 272
114 #define SIGNED_KEYWORD 273
115 #define LONG 274
116 #define SHORT 275
117 #define INT_KEYWORD 276
118 #define CONST_KEYWORD 277
119 #define VOLATILE_KEYWORD 278
120 #define DOUBLE_KEYWORD 279
121 #define VARIABLE 280
122 #define ASSIGN_MODIFY 281
123 #define TRUEKEYWORD 282
124 #define FALSEKEYWORD 283
125 #define ABOVE_COMMA 284
126 #define OROR 285
127 #define ANDAND 286
128 #define NOTEQUAL 287
129 #define EQUAL 288
130 #define GEQ 289
131 #define LEQ 290
132 #define RSH 291
133 #define LSH 292
134 #define DECREMENT 293
135 #define INCREMENT 294
136 #define UNARY 295
137 #define ARROW 296
138 #define BLOCKNAME 297
139 #define FILENAME 298
140
141
142
143
144 /* Copy the first part of user declarations. */
145 #line 39 "c-exp.y"
146
147
148 #include "defs.h"
149 #include "gdb_string.h"
150 #include <ctype.h>
151 #include "expression.h"
152 #include "value.h"
153 #include "parser-defs.h"
154 #include "language.h"
155 #include "c-lang.h"
156 #include "bfd.h" /* Required by objfiles.h. */
157 #include "symfile.h" /* Required by objfiles.h. */
158 #include "objfiles.h" /* For have_full_symbols and have_partial_symbols */
159 #include "charset.h"
160 #include "block.h"
161 #include "cp-support.h"
162
163 /* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc),
164 as well as gratuitiously global symbol names, so we can have multiple
165 yacc generated parsers in gdb. Note that these are only the variables
166 produced by yacc. If other parser generators (bison, byacc, etc) produce
167 additional global names that conflict at link time, then those parser
168 generators need to be fixed instead of adding those names to this list. */
169
170 #define yymaxdepth c_maxdepth
171 #define yyparse c_parse
172 #define yylex c_lex
173 #define yyerror c_error
174 #define yylval c_lval
175 #define yychar c_char
176 #define yydebug c_debug
177 #define yypact c_pact
178 #define yyr1 c_r1
179 #define yyr2 c_r2
180 #define yydef c_def
181 #define yychk c_chk
182 #define yypgo c_pgo
183 #define yyact c_act
184 #define yyexca c_exca
185 #define yyerrflag c_errflag
186 #define yynerrs c_nerrs
187 #define yyps c_ps
188 #define yypv c_pv
189 #define yys c_s
190 #define yy_yys c_yys
191 #define yystate c_state
192 #define yytmp c_tmp
193 #define yyv c_v
194 #define yy_yyv c_yyv
195 #define yyval c_val
196 #define yylloc c_lloc
197 #define yyreds c_reds /* With YYDEBUG defined */
198 #define yytoks c_toks /* With YYDEBUG defined */
199 #define yyname c_name /* With YYDEBUG defined */
200 #define yyrule c_rule /* With YYDEBUG defined */
201 #define yylhs c_yylhs
202 #define yylen c_yylen
203 #define yydefred c_yydefred
204 #define yydgoto c_yydgoto
205 #define yysindex c_yysindex
206 #define yyrindex c_yyrindex
207 #define yygindex c_yygindex
208 #define yytable c_yytable
209 #define yycheck c_yycheck
210
211 #ifndef YYDEBUG
212 #define YYDEBUG 1 /* Default to yydebug support */
213 #endif
214
215 #define YYFPRINTF parser_fprintf
216
217 int yyparse (void);
218
219 static int yylex (void);
220
221 void yyerror (char *);
222
223
224
225 /* Enabling traces. */
226 #ifndef YYDEBUG
227 # define YYDEBUG 0
228 #endif
229
230 /* Enabling verbose error messages. */
231 #ifdef YYERROR_VERBOSE
232 # undef YYERROR_VERBOSE
233 # define YYERROR_VERBOSE 1
234 #else
235 # define YYERROR_VERBOSE 0
236 #endif
237
238 #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
239 #line 123 "c-exp.y"
240 typedef union YYSTYPE {
241 LONGEST lval;
242 struct {
243 LONGEST val;
244 struct type *type;
245 } typed_val_int;
246 struct {
247 DOUBLEST dval;
248 struct type *type;
249 } typed_val_float;
250 struct symbol *sym;
251 struct type *tval;
252 struct stoken sval;
253 struct ttype tsym;
254 struct symtoken ssym;
255 int voidval;
256 struct block *bval;
257 enum exp_opcode opcode;
258 struct internalvar *ivar;
259
260 struct type **tvec;
261 int *ivec;
262 } YYSTYPE;
263 /* Line 191 of yacc.c. */
264 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
265 # define YYSTYPE_IS_DECLARED 1
266 # define YYSTYPE_IS_TRIVIAL 1
267 #endif
268
269
270
271 /* Copy the second part of user declarations. */
272 #line 147 "c-exp.y"
273
274 /* YYSTYPE gets defined by %union */
275 static int parse_number (char *, int, int, YYSTYPE *);
276
277
278 /* Line 214 of yacc.c. */
279
280 #if ! defined (yyoverflow) || YYERROR_VERBOSE
281
282 # ifndef YYFREE
283 # define YYFREE free
284 # endif
285 # ifndef YYMALLOC
286 # define YYMALLOC xmalloc
287 # endif
288
289 /* The parser invokes alloca or xmalloc; define the necessary symbols. */
290
291 # ifdef YYSTACK_USE_ALLOCA
292 # if YYSTACK_USE_ALLOCA
293 # define YYSTACK_ALLOC alloca
294 # endif
295 # else
296 # if defined (alloca) || defined (_ALLOCA_H)
297 # define YYSTACK_ALLOC alloca
298 # else
299 # ifdef __GNUC__
300 # define YYSTACK_ALLOC __builtin_alloca
301 # endif
302 # endif
303 # endif
304
305 # ifdef YYSTACK_ALLOC
306 /* Pacify GCC's `empty if-body' warning. */
307 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
308 # else
309 # if defined (__STDC__) || defined (__cplusplus)
310 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
311 # define YYSIZE_T size_t
312 # endif
313 # define YYSTACK_ALLOC YYMALLOC
314 # define YYSTACK_FREE YYFREE
315 # endif
316 #endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
317
318
319 #if (! defined (yyoverflow) \
320 && (! defined (__cplusplus) \
321 || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL)))
322
323 /* A type that is properly aligned for any stack member. */
324 union yyalloc
325 {
326 short yyss;
327 YYSTYPE yyvs;
328 };
329
330 /* The size of the maximum gap between one aligned stack and the next. */
331 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
332
333 /* The size of an array large to enough to hold all stacks, each with
334 N elements. */
335 # define YYSTACK_BYTES(N) \
336 ((N) * (sizeof (short) + sizeof (YYSTYPE)) \
337 + YYSTACK_GAP_MAXIMUM)
338
339 /* Copy COUNT objects from FROM to TO. The source and destination do
340 not overlap. */
341 # ifndef YYCOPY
342 # if defined (__GNUC__) && 1 < __GNUC__
343 # define YYCOPY(To, From, Count) \
344 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
345 # else
346 # define YYCOPY(To, From, Count) \
347 do \
348 { \
349 register YYSIZE_T yyi; \
350 for (yyi = 0; yyi < (Count); yyi++) \
351 (To)[yyi] = (From)[yyi]; \
352 } \
353 while (0)
354 # endif
355 # endif
356
357 /* Relocate STACK from its old location to the new one. The
358 local variables YYSIZE and YYSTACKSIZE give the old and new number of
359 elements in the stack, and YYPTR gives the new location of the
360 stack. Advance YYPTR to a properly aligned location for the next
361 stack. */
362 # define YYSTACK_RELOCATE(Stack) \
363 do \
364 { \
365 YYSIZE_T yynewbytes; \
366 YYCOPY (&yyptr->Stack, Stack, yysize); \
367 Stack = &yyptr->Stack; \
368 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
369 yyptr += yynewbytes / sizeof (*yyptr); \
370 } \
371 while (0)
372
373 #endif
374
375 #if defined (__STDC__) || defined (__cplusplus)
376 typedef signed char yysigned_char;
377 #else
378 typedef short yysigned_char;
379 #endif
380
381 /* YYFINAL -- State number of the termination state. */
382 #define YYFINAL 94
383 /* YYLAST -- Last index in YYTABLE. */
384 #define YYLAST 804
385
386 /* YYNTOKENS -- Number of terminals. */
387 #define YYNTOKENS 68
388 /* YYNNTS -- Number of nonterminals. */
389 #define YYNNTS 31
390 /* YYNRULES -- Number of rules. */
391 #define YYNRULES 159
392 /* YYNRULES -- Number of states. */
393 #define YYNSTATES 242
394
395 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
396 #define YYUNDEFTOK 2
397 #define YYMAXUTOK 298
398
399 #define YYTRANSLATE(YYX) \
400 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
401
402 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
403 static const unsigned char yytranslate[] =
404 {
405 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
406 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
407 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
408 2, 2, 2, 61, 2, 2, 2, 51, 37, 2,
409 57, 64, 49, 47, 29, 48, 55, 50, 2, 2,
410 2, 2, 2, 2, 2, 2, 2, 2, 67, 2,
411 40, 31, 41, 32, 46, 2, 2, 2, 2, 2,
412 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
413 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
414 2, 56, 2, 63, 36, 2, 2, 2, 2, 2,
415 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
416 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
417 2, 2, 2, 65, 35, 66, 62, 2, 2, 2,
418 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
419 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
420 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
421 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
422 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
423 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
424 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
425 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
426 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
427 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
428 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
429 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
430 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
431 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
432 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
433 25, 26, 27, 28, 30, 33, 34, 38, 39, 42,
434 43, 44, 45, 52, 53, 54, 58, 59, 60
435 };
436
437 #if YYDEBUG
438 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
439 YYRHS. */
440 static const unsigned short yyprhs[] =
441 {
442 0, 0, 3, 5, 7, 9, 11, 15, 18, 21,
443 24, 27, 30, 33, 36, 39, 42, 45, 49, 53,
444 58, 62, 66, 71, 76, 77, 83, 85, 86, 88,
445 92, 94, 98, 103, 108, 112, 116, 120, 124, 128,
446 132, 136, 140, 144, 148, 152, 156, 160, 164, 168,
447 172, 176, 180, 184, 188, 194, 198, 202, 204, 206,
448 208, 210, 212, 217, 219, 221, 223, 225, 227, 231,
449 235, 239, 244, 246, 249, 251, 254, 256, 257, 261,
450 263, 265, 267, 268, 270, 273, 275, 278, 280, 284,
451 287, 289, 292, 294, 297, 301, 304, 308, 310, 314,
452 316, 318, 320, 322, 325, 329, 332, 336, 340, 344,
453 347, 350, 354, 359, 363, 367, 372, 376, 381, 385,
454 390, 393, 397, 400, 404, 407, 411, 413, 416, 419,
455 422, 425, 428, 431, 433, 436, 438, 444, 447, 450,
456 452, 456, 458, 460, 462, 464, 466, 470, 472, 477,
457 480, 483, 485, 487, 489, 491, 493, 495, 497, 499
458 };
459
460 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
461 static const yysigned_char yyrhs[] =
462 {
463 69, 0, -1, 71, -1, 70, -1, 89, -1, 72,
464 -1, 71, 29, 72, -1, 49, 72, -1, 37, 72,
465 -1, 48, 72, -1, 61, 72, -1, 62, 72, -1,
466 53, 72, -1, 52, 72, -1, 72, 53, -1, 72,
467 52, -1, 13, 72, -1, 72, 58, 97, -1, 72,
468 58, 79, -1, 72, 58, 49, 72, -1, 72, 55,
469 97, -1, 72, 55, 79, -1, 72, 55, 49, 72,
470 -1, 72, 56, 71, 63, -1, -1, 72, 57, 73,
471 75, 64, -1, 65, -1, -1, 72, -1, 75, 29,
472 72, -1, 66, -1, 74, 75, 76, -1, 74, 89,
473 76, 72, -1, 57, 89, 64, 72, -1, 57, 71,
474 64, -1, 72, 46, 72, -1, 72, 49, 72, -1,
475 72, 50, 72, -1, 72, 51, 72, -1, 72, 47,
476 72, -1, 72, 48, 72, -1, 72, 45, 72, -1,
477 72, 44, 72, -1, 72, 39, 72, -1, 72, 38,
478 72, -1, 72, 43, 72, -1, 72, 42, 72, -1,
479 72, 40, 72, -1, 72, 41, 72, -1, 72, 37,
480 72, -1, 72, 36, 72, -1, 72, 35, 72, -1,
481 72, 34, 72, -1, 72, 33, 72, -1, 72, 32,
482 72, 67, 72, -1, 72, 31, 72, -1, 72, 26,
483 72, -1, 3, -1, 8, -1, 4, -1, 78, -1,
484 25, -1, 13, 57, 89, 64, -1, 5, -1, 27,
485 -1, 28, -1, 59, -1, 60, -1, 77, 15, 97,
486 -1, 77, 15, 97, -1, 90, 15, 97, -1, 90,
487 15, 62, 97, -1, 79, -1, 15, 97, -1, 98,
488 -1, 46, 6, -1, 96, -1, -1, 81, 80, 81,
489 -1, 82, -1, 96, -1, 83, -1, -1, 49, -1,
490 49, 85, -1, 37, -1, 37, 85, -1, 86, -1,
491 57, 85, 64, -1, 86, 87, -1, 87, -1, 86,
492 88, -1, 88, -1, 56, 63, -1, 56, 3, 63,
493 -1, 57, 64, -1, 57, 93, 64, -1, 94, -1,
494 90, 15, 49, -1, 7, -1, 21, -1, 19, -1,
495 20, -1, 19, 21, -1, 19, 18, 21, -1, 19,
496 18, -1, 18, 19, 21, -1, 14, 19, 21, -1,
497 19, 14, 21, -1, 19, 14, -1, 19, 19, -1,
498 19, 19, 21, -1, 19, 19, 18, 21, -1, 19,
499 19, 18, -1, 18, 19, 19, -1, 18, 19, 19,
500 21, -1, 14, 19, 19, -1, 14, 19, 19, 21,
501 -1, 19, 19, 14, -1, 19, 19, 14, 21, -1,
502 20, 21, -1, 20, 18, 21, -1, 20, 18, -1,
503 14, 20, 21, -1, 20, 14, -1, 20, 14, 21,
504 -1, 24, -1, 19, 24, -1, 9, 97, -1, 10,
505 97, -1, 11, 97, -1, 12, 97, -1, 14, 92,
506 -1, 14, -1, 18, 92, -1, 18, -1, 16, 97,
507 40, 89, 41, -1, 83, 90, -1, 90, 83, -1,
508 91, -1, 90, 15, 97, -1, 7, -1, 21, -1,
509 19, -1, 20, -1, 89, -1, 93, 29, 89, -1,
510 90, -1, 94, 84, 85, 84, -1, 22, 23, -1,
511 23, 22, -1, 95, -1, 22, -1, 23, -1, 6,
512 -1, 59, -1, 7, -1, 8, -1, 6, -1, 59,
513 -1
514 };
515
516 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
517 static const unsigned short yyrline[] =
518 {
519 0, 230, 230, 231, 234, 241, 242, 247, 251, 255,
520 259, 263, 267, 271, 275, 279, 283, 287, 293, 301,
521 305, 311, 319, 323, 330, 327, 337, 341, 344, 348,
522 352, 355, 362, 368, 374, 380, 384, 388, 392, 396,
523 400, 404, 408, 412, 416, 420, 424, 428, 432, 436,
524 440, 444, 448, 452, 456, 460, 464, 470, 477, 488,
525 495, 498, 502, 510, 535, 542, 551, 559, 565, 576,
526 592, 606, 631, 632, 666, 723, 729, 730, 733, 736,
527 737, 741, 742, 745, 747, 749, 751, 753, 756, 758,
528 763, 770, 772, 776, 778, 782, 784, 796, 797, 802,
529 804, 806, 808, 810, 812, 814, 816, 818, 820, 822,
530 824, 826, 828, 830, 832, 834, 836, 838, 840, 842,
531 844, 846, 848, 850, 852, 854, 856, 858, 860, 863,
532 866, 869, 872, 874, 876, 878, 883, 887, 889, 891,
533 939, 964, 965, 971, 977, 986, 991, 998, 999, 1003,
534 1004, 1007, 1011, 1013, 1017, 1018, 1019, 1020, 1023, 1024
535 };
536 #endif
537
538 #if YYDEBUG || YYERROR_VERBOSE
539 /* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
540 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
541 static const char *const yytname[] =
542 {
543 "$end", "error", "$undefined", "INT", "FLOAT", "STRING", "NAME",
544 "TYPENAME", "NAME_OR_INT", "STRUCT", "CLASS", "UNION", "ENUM", "SIZEOF",
545 "UNSIGNED", "COLONCOLON", "TEMPLATE", "ERROR", "SIGNED_KEYWORD", "LONG",
546 "SHORT", "INT_KEYWORD", "CONST_KEYWORD", "VOLATILE_KEYWORD",
547 "DOUBLE_KEYWORD", "VARIABLE", "ASSIGN_MODIFY", "TRUEKEYWORD",
548 "FALSEKEYWORD", "','", "ABOVE_COMMA", "'='", "'?'", "OROR", "ANDAND",
549 "'|'", "'^'", "'&'", "NOTEQUAL", "EQUAL", "'<'", "'>'", "GEQ", "LEQ",
550 "RSH", "LSH", "'@'", "'+'", "'-'", "'*'", "'/'", "'%'", "DECREMENT",
551 "INCREMENT", "UNARY", "'.'", "'['", "'('", "ARROW", "BLOCKNAME",
552 "FILENAME", "'!'", "'~'", "']'", "')'", "'{'", "'}'", "':'", "$accept",
553 "start", "type_exp", "exp1", "exp", "@1", "lcurly", "arglist", "rcurly",
554 "block", "variable", "qualified_name", "space_identifier",
555 "const_or_volatile", "cv_with_space_id",
556 "const_or_volatile_or_space_identifier_noopt",
557 "const_or_volatile_or_space_identifier", "abs_decl", "direct_abs_decl",
558 "array_mod", "func_mod", "type", "typebase", "qualified_type",
559 "typename", "nonempty_typelist", "ptype", "const_and_volatile",
560 "const_or_volatile_noopt", "name", "name_not_typename", 0
561 };
562 #endif
563
564 # ifdef YYPRINT
565 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
566 token YYLEX-NUM. */
567 static const unsigned short yytoknum[] =
568 {
569 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
570 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
571 275, 276, 277, 278, 279, 280, 281, 282, 283, 44,
572 284, 61, 63, 285, 286, 124, 94, 38, 287, 288,
573 60, 62, 289, 290, 291, 292, 64, 43, 45, 42,
574 47, 37, 293, 294, 295, 46, 91, 40, 296, 297,
575 298, 33, 126, 93, 41, 123, 125, 58
576 };
577 # endif
578
579 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
580 static const unsigned char yyr1[] =
581 {
582 0, 68, 69, 69, 70, 71, 71, 72, 72, 72,
583 72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
584 72, 72, 72, 72, 73, 72, 74, 75, 75, 75,
585 76, 72, 72, 72, 72, 72, 72, 72, 72, 72,
586 72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
587 72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
588 72, 72, 72, 72, 72, 72, 77, 77, 77, 78,
589 79, 79, 78, 78, 78, 80, 81, 81, 82, 83,
590 83, 84, 84, 85, 85, 85, 85, 85, 86, 86,
591 86, 86, 86, 87, 87, 88, 88, 89, 89, 90,
592 90, 90, 90, 90, 90, 90, 90, 90, 90, 90,
593 90, 90, 90, 90, 90, 90, 90, 90, 90, 90,
594 90, 90, 90, 90, 90, 90, 90, 90, 90, 90,
595 90, 90, 90, 90, 90, 90, 90, 90, 90, 90,
596 91, 92, 92, 92, 92, 93, 93, 94, 94, 95,
597 95, 96, 96, 96, 97, 97, 97, 97, 98, 98
598 };
599
600 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
601 static const unsigned char yyr2[] =
602 {
603 0, 2, 1, 1, 1, 1, 3, 2, 2, 2,
604 2, 2, 2, 2, 2, 2, 2, 3, 3, 4,
605 3, 3, 4, 4, 0, 5, 1, 0, 1, 3,
606 1, 3, 4, 4, 3, 3, 3, 3, 3, 3,
607 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
608 3, 3, 3, 3, 5, 3, 3, 1, 1, 1,
609 1, 1, 4, 1, 1, 1, 1, 1, 3, 3,
610 3, 4, 1, 2, 1, 2, 1, 0, 3, 1,
611 1, 1, 0, 1, 2, 1, 2, 1, 3, 2,
612 1, 2, 1, 2, 3, 2, 3, 1, 3, 1,
613 1, 1, 1, 2, 3, 2, 3, 3, 3, 2,
614 2, 3, 4, 3, 3, 4, 3, 4, 3, 4,
615 2, 3, 2, 3, 2, 3, 1, 2, 2, 2,
616 2, 2, 2, 1, 2, 1, 5, 2, 2, 1,
617 3, 1, 1, 1, 1, 1, 3, 1, 4, 2,
618 2, 1, 1, 1, 1, 1, 1, 1, 1, 1
619 };
620
621 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
622 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
623 means the default is an error. */
624 static const unsigned char yydefact[] =
625 {
626 77, 57, 59, 63, 158, 99, 58, 0, 0, 0,
627 0, 77, 133, 0, 0, 135, 101, 102, 100, 152,
628 153, 126, 61, 64, 65, 77, 77, 77, 77, 77,
629 77, 159, 67, 77, 77, 26, 0, 3, 2, 5,
630 27, 0, 60, 72, 0, 79, 77, 4, 147, 139,
631 97, 151, 80, 74, 154, 156, 157, 155, 128, 129,
632 130, 131, 77, 16, 77, 141, 143, 144, 142, 132,
633 73, 0, 143, 144, 134, 109, 105, 110, 103, 127,
634 124, 122, 120, 149, 150, 8, 9, 7, 13, 12,
635 0, 0, 10, 11, 1, 77, 77, 77, 77, 77,
636 77, 77, 77, 77, 77, 77, 77, 77, 77, 77,
637 77, 77, 77, 77, 77, 77, 77, 77, 15, 14,
638 77, 77, 24, 77, 28, 0, 0, 0, 0, 77,
639 137, 0, 138, 81, 0, 0, 0, 116, 107, 123,
640 77, 114, 106, 108, 104, 118, 113, 111, 125, 121,
641 34, 77, 6, 56, 55, 0, 53, 52, 51, 50,
642 49, 44, 43, 47, 48, 46, 45, 42, 41, 35,
643 39, 40, 36, 37, 38, 156, 77, 21, 20, 0,
644 27, 77, 18, 17, 77, 30, 31, 77, 69, 75,
645 78, 76, 0, 98, 0, 70, 85, 83, 0, 77,
646 82, 87, 90, 92, 62, 117, 0, 147, 115, 119,
647 112, 33, 77, 22, 23, 0, 19, 29, 32, 140,
648 71, 86, 84, 0, 93, 95, 0, 145, 0, 148,
649 77, 89, 91, 136, 0, 54, 25, 94, 88, 77,
650 96, 146
651 };
652
653 /* YYDEFGOTO[NTERM-NUM]. */
654 static const short yydefgoto[] =
655 {
656 -1, 36, 37, 90, 39, 180, 40, 125, 186, 41,
657 42, 43, 129, 44, 45, 46, 134, 200, 201, 202,
658 203, 227, 64, 49, 69, 228, 50, 51, 52, 195,
659 53
660 };
661
662 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
663 STATE-NUM. */
664 #define YYPACT_NINF -101
665 static const short yypact[] =
666 {
667 320, -101, -101, -101, -101, -101, -101, 30, 30, 30,
668 30, 383, 45, 30, 30, 200, 152, 36, -101, -11,
669 17, -101, -101, -101, -101, 320, 320, 320, 320, 320,
670 320, 29, -101, 320, 320, -101, 84, -101, 39, 597,
671 257, 56, -101, -101, 57, -101, 172, -101, 68, -101,
672 55, -101, 67, -101, -101, -101, -101, -101, -101, -101,
673 -101, -101, 320, 460, 87, -101, 40, 95, -101, -101,
674 -101, 99, 190, -101, -101, 156, 159, 223, -101, -101,
675 164, 176, -101, -101, -101, 460, 460, 460, 460, 460,
676 -15, 158, 460, 460, -101, 320, 320, 320, 320, 320,
677 320, 320, 320, 320, 320, 320, 320, 320, 320, 320,
678 320, 320, 320, 320, 320, 320, 320, 320, -101, -101,
679 194, 320, -101, 531, 597, -19, 160, 30, 218, -1,
680 71, 20, -101, -101, -14, 171, 26, 215, -101, -101,
681 172, 217, -101, -101, -101, 221, 224, -101, -101, -101,
682 -101, 320, 597, 597, 597, 560, 622, 646, 669, 691,
683 712, 731, 731, 746, 746, 746, 746, 240, 240, 303,
684 366, 366, 460, 460, 460, 83, 320, -101, -101, -18,
685 257, 320, -101, -101, 320, -101, -101, 320, 231, -101,
686 -101, -101, 30, -101, 30, 210, 118, 63, 4, 472,
687 2, 112, -101, -101, 446, -101, 206, 85, -101, -101,
688 -101, 460, 320, 460, -101, -13, 460, 597, 460, -101,
689 -101, -101, -101, 185, -101, -101, 186, -101, -9, -101,
690 114, -101, -101, -101, 11, 526, -101, -101, -101, 172,
691 -101, -101
692 };
693
694 /* YYPGOTO[NTERM-NUM]. */
695 static const short yypgoto[] =
696 {
697 -101, -101, -101, 6, 47, -101, -101, 69, 126, -101,
698 -101, -67, -101, 125, -101, -35, 58, -100, -101, 54,
699 73, 1, 0, -101, 241, -101, -101, -101, 128, -5,
700 -101
701 };
702
703 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
704 positive, shift that token. If negative, reduce the rule which
705 number is the opposite. If zero, do what YYDEFACT says.
706 If YYTABLE_NINF, syntax error. */
707 #define YYTABLE_NINF -141
708 static const short yytable[] =
709 {
710 48, 47, 58, 59, 60, 61, 38, 223, 70, 71,
711 184, 95, 83, 132, 95, 133, 184, 54, 55, 56,
712 239, 19, 20, 196, 19, 20, 54, 55, 56, 132,
713 48, 91, 54, 55, 56, 197, 54, 55, 56, 84,
714 48, 126, 198, 199, -66, 214, 130, 185, -77, 150,
715 80, 236, 65, 177, 81, 240, 182, 82, 63, 137,
716 193, 138, 48, 135, 66, 67, 68, 224, 95, 193,
717 57, 127, 85, 86, 87, 88, 89, 19, 20, 57,
718 92, 93, 194, 131, 94, 57, 192, 124, 194, 57,
719 19, 20, -82, 19, 20, 132, 221, 222, -99, 226,
720 234, -77, 136, 128, -82, -99, -99, 19, 20, 19,
721 20, -82, -82, -76, -77, 178, 139, -77, 183, 198,
722 199, 5, 188, 7, 8, 9, 10, 179, 12, -99,
723 14, -77, 15, 16, 17, 18, 19, 20, 21, 140,
724 207, 206, 152, 153, 154, 155, 156, 157, 158, 159,
725 160, 161, 162, 163, 164, 165, 166, 167, 168, 169,
726 170, 171, 172, 173, 174, 133, 75, 197, 198, 230,
727 76, 77, 132, 78, 198, 199, 79, 143, 225, 5,
728 144, 7, 8, 9, 10, 148, 12, 219, 14, 220,
729 15, 16, 17, 18, 19, 20, 21, 149, 211, 207,
730 54, 175, 56, 7, 8, 9, 10, 65, 12, 141,
731 14, 142, 15, 16, 17, 18, 19, 20, 21, 72,
732 73, 68, 151, 213, 189, -140, 185, 124, 216, 219,
733 207, 217, -140, -140, 218, 204, 205, 145, 208, 207,
734 241, 146, 209, 176, 147, 210, -68, 233, 237, 215,
735 238, 211, 187, 57, 190, 231, 74, 191, 229, 235,
736 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
737 11, 12, 13, 14, 232, 15, 16, 17, 18, 19,
738 20, 21, 22, 0, 23, 24, 112, 113, 114, 115,
739 116, 117, 118, 119, 25, 120, 121, 122, 123, 0,
740 0, 0, 0, -77, 0, 26, 27, 0, 0, 28,
741 29, 0, 0, 0, 30, 0, 31, 32, 33, 34,
742 0, 0, 35, 1, 2, 3, 4, 5, 6, 7,
743 8, 9, 10, 11, 12, 13, 14, 0, 15, 16,
744 17, 18, 19, 20, 21, 22, 0, 23, 24, 0,
745 113, 114, 115, 116, 117, 118, 119, 25, 120, 121,
746 122, 123, 0, 0, 0, 0, 0, 0, 26, 27,
747 0, 0, 28, 29, 0, 0, 0, 30, 0, 31,
748 32, 33, 34, 0, 0, 35, 1, 2, 3, 4,
749 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
750 0, 15, 16, 17, 18, 19, 20, 21, 22, 0,
751 23, 24, 0, 0, 0, 115, 116, 117, 118, 119,
752 25, 120, 121, 122, 123, 0, 0, 0, 0, 0,
753 0, 26, 27, 0, 0, 28, 29, 0, 0, 0,
754 62, 0, 31, 32, 33, 34, 0, 0, 35, 1,
755 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
756 12, 13, 14, 0, 15, 16, 17, 18, 19, 20,
757 21, 22, 0, 23, 24, 0, 0, 0, 0, 5,
758 0, 7, 8, 9, 10, 0, 12, 0, 14, 0,
759 15, 16, 17, 18, 19, 20, 21, 0, 28, 29,
760 0, 0, 0, 30, 0, 31, 32, 33, 34, 196,
761 0, 35, 118, 119, 0, 120, 121, 122, 123, 0,
762 0, 197, 0, 0, 0, 0, 0, 0, 198, 199,
763 0, 0, 0, 0, 0, 0, 225, 54, 175, 56,
764 7, 8, 9, 10, 0, 12, 0, 14, 0, 15,
765 16, 17, 18, 19, 20, 21, 0, 0, 98, 99,
766 100, 101, 102, 103, 104, 105, 106, 107, 108, 109,
767 110, 111, 112, 113, 114, 115, 116, 117, 118, 119,
768 181, 120, 121, 122, 123, 0, 96, 0, 0, 0,
769 57, 97, 98, 99, 100, 101, 102, 103, 104, 105,
770 106, 107, 108, 109, 110, 111, 112, 113, 114, 115,
771 116, 117, 118, 119, 0, 120, 121, 122, 123, 0,
772 0, 0, 0, 96, 0, 0, 0, 212, 97, 98,
773 99, 100, 101, 102, 103, 104, 105, 106, 107, 108,
774 109, 110, 111, 112, 113, 114, 115, 116, 117, 118,
775 119, 0, 120, 121, 122, 123, 100, 101, 102, 103,
776 104, 105, 106, 107, 108, 109, 110, 111, 112, 113,
777 114, 115, 116, 117, 118, 119, 0, 120, 121, 122,
778 123, 101, 102, 103, 104, 105, 106, 107, 108, 109,
779 110, 111, 112, 113, 114, 115, 116, 117, 118, 119,
780 0, 120, 121, 122, 123, 102, 103, 104, 105, 106,
781 107, 108, 109, 110, 111, 112, 113, 114, 115, 116,
782 117, 118, 119, 0, 120, 121, 122, 123, 103, 104,
783 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
784 115, 116, 117, 118, 119, 0, 120, 121, 122, 123,
785 104, 105, 106, 107, 108, 109, 110, 111, 112, 113,
786 114, 115, 116, 117, 118, 119, 0, 120, 121, 122,
787 123, 106, 107, 108, 109, 110, 111, 112, 113, 114,
788 115, 116, 117, 118, 119, 0, 120, 121, 122, 123,
789 110, 111, 112, 113, 114, 115, 116, 117, 118, 119,
790 0, 120, 121, 122, 123
791 };
792
793 static const short yycheck[] =
794 {
795 0, 0, 7, 8, 9, 10, 0, 3, 13, 14,
796 29, 29, 23, 48, 29, 50, 29, 6, 7, 8,
797 29, 22, 23, 37, 22, 23, 6, 7, 8, 64,
798 30, 30, 6, 7, 8, 49, 6, 7, 8, 22,
799 40, 40, 56, 57, 15, 63, 46, 66, 46, 64,
800 14, 64, 7, 120, 18, 64, 123, 21, 11, 19,
801 49, 21, 62, 62, 19, 20, 21, 63, 29, 49,
802 59, 15, 25, 26, 27, 28, 29, 22, 23, 59,
803 33, 34, 62, 15, 0, 59, 15, 40, 62, 59,
804 22, 23, 37, 22, 23, 130, 196, 197, 15, 199,
805 15, 46, 15, 46, 49, 22, 23, 22, 23, 22,
806 23, 56, 57, 46, 46, 120, 21, 46, 123, 56,
807 57, 7, 127, 9, 10, 11, 12, 121, 14, 46,
808 16, 46, 18, 19, 20, 21, 22, 23, 24, 40,
809 140, 140, 95, 96, 97, 98, 99, 100, 101, 102,
810 103, 104, 105, 106, 107, 108, 109, 110, 111, 112,
811 113, 114, 115, 116, 117, 200, 14, 49, 56, 57,
812 18, 19, 207, 21, 56, 57, 24, 21, 64, 7,
813 21, 9, 10, 11, 12, 21, 14, 192, 16, 194,
814 18, 19, 20, 21, 22, 23, 24, 21, 151, 199,
815 6, 7, 8, 9, 10, 11, 12, 7, 14, 19,
816 16, 21, 18, 19, 20, 21, 22, 23, 24, 19,
817 20, 21, 64, 176, 6, 15, 66, 180, 181, 234,
818 230, 184, 22, 23, 187, 64, 21, 14, 21, 239,
819 239, 18, 21, 49, 21, 21, 15, 41, 63, 180,
820 64, 204, 126, 59, 129, 201, 15, 129, 200, 212,
821 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
822 13, 14, 15, 16, 201, 18, 19, 20, 21, 22,
823 23, 24, 25, -1, 27, 28, 46, 47, 48, 49,
824 50, 51, 52, 53, 37, 55, 56, 57, 58, -1,
825 -1, -1, -1, 46, -1, 48, 49, -1, -1, 52,
826 53, -1, -1, -1, 57, -1, 59, 60, 61, 62,
827 -1, -1, 65, 3, 4, 5, 6, 7, 8, 9,
828 10, 11, 12, 13, 14, 15, 16, -1, 18, 19,
829 20, 21, 22, 23, 24, 25, -1, 27, 28, -1,
830 47, 48, 49, 50, 51, 52, 53, 37, 55, 56,
831 57, 58, -1, -1, -1, -1, -1, -1, 48, 49,
832 -1, -1, 52, 53, -1, -1, -1, 57, -1, 59,
833 60, 61, 62, -1, -1, 65, 3, 4, 5, 6,
834 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
835 -1, 18, 19, 20, 21, 22, 23, 24, 25, -1,
836 27, 28, -1, -1, -1, 49, 50, 51, 52, 53,
837 37, 55, 56, 57, 58, -1, -1, -1, -1, -1,
838 -1, 48, 49, -1, -1, 52, 53, -1, -1, -1,
839 57, -1, 59, 60, 61, 62, -1, -1, 65, 3,
840 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
841 14, 15, 16, -1, 18, 19, 20, 21, 22, 23,
842 24, 25, -1, 27, 28, -1, -1, -1, -1, 7,
843 -1, 9, 10, 11, 12, -1, 14, -1, 16, -1,
844 18, 19, 20, 21, 22, 23, 24, -1, 52, 53,
845 -1, -1, -1, 57, -1, 59, 60, 61, 62, 37,
846 -1, 65, 52, 53, -1, 55, 56, 57, 58, -1,
847 -1, 49, -1, -1, -1, -1, -1, -1, 56, 57,
848 -1, -1, -1, -1, -1, -1, 64, 6, 7, 8,
849 9, 10, 11, 12, -1, 14, -1, 16, -1, 18,
850 19, 20, 21, 22, 23, 24, -1, -1, 32, 33,
851 34, 35, 36, 37, 38, 39, 40, 41, 42, 43,
852 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
853 49, 55, 56, 57, 58, -1, 26, -1, -1, -1,
854 59, 31, 32, 33, 34, 35, 36, 37, 38, 39,
855 40, 41, 42, 43, 44, 45, 46, 47, 48, 49,
856 50, 51, 52, 53, -1, 55, 56, 57, 58, -1,
857 -1, -1, -1, 26, -1, -1, -1, 67, 31, 32,
858 33, 34, 35, 36, 37, 38, 39, 40, 41, 42,
859 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
860 53, -1, 55, 56, 57, 58, 34, 35, 36, 37,
861 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
862 48, 49, 50, 51, 52, 53, -1, 55, 56, 57,
863 58, 35, 36, 37, 38, 39, 40, 41, 42, 43,
864 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
865 -1, 55, 56, 57, 58, 36, 37, 38, 39, 40,
866 41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
867 51, 52, 53, -1, 55, 56, 57, 58, 37, 38,
868 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
869 49, 50, 51, 52, 53, -1, 55, 56, 57, 58,
870 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
871 48, 49, 50, 51, 52, 53, -1, 55, 56, 57,
872 58, 40, 41, 42, 43, 44, 45, 46, 47, 48,
873 49, 50, 51, 52, 53, -1, 55, 56, 57, 58,
874 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
875 -1, 55, 56, 57, 58
876 };
877
878 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
879 symbol of state STATE-NUM. */
880 static const unsigned char yystos[] =
881 {
882 0, 3, 4, 5, 6, 7, 8, 9, 10, 11,
883 12, 13, 14, 15, 16, 18, 19, 20, 21, 22,
884 23, 24, 25, 27, 28, 37, 48, 49, 52, 53,
885 57, 59, 60, 61, 62, 65, 69, 70, 71, 72,
886 74, 77, 78, 79, 81, 82, 83, 89, 90, 91,
887 94, 95, 96, 98, 6, 7, 8, 59, 97, 97,
888 97, 97, 57, 72, 90, 7, 19, 20, 21, 92,
889 97, 97, 19, 20, 92, 14, 18, 19, 21, 24,
890 14, 18, 21, 23, 22, 72, 72, 72, 72, 72,
891 71, 89, 72, 72, 0, 29, 26, 31, 32, 33,
892 34, 35, 36, 37, 38, 39, 40, 41, 42, 43,
893 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
894 55, 56, 57, 58, 72, 75, 89, 15, 46, 80,
895 90, 15, 83, 83, 84, 89, 15, 19, 21, 21,
896 40, 19, 21, 21, 21, 14, 18, 21, 21, 21,
897 64, 64, 72, 72, 72, 72, 72, 72, 72, 72,
898 72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
899 72, 72, 72, 72, 72, 7, 49, 79, 97, 71,
900 73, 49, 79, 97, 29, 66, 76, 76, 97, 6,
901 81, 96, 15, 49, 62, 97, 37, 49, 56, 57,
902 85, 86, 87, 88, 64, 21, 89, 90, 21, 21,
903 21, 72, 67, 72, 63, 75, 72, 72, 72, 97,
904 97, 85, 85, 3, 63, 64, 85, 89, 93, 84,
905 57, 87, 88, 41, 15, 72, 64, 63, 64, 29,
906 64, 89
907 };
908
909 #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
910 # define YYSIZE_T __SIZE_TYPE__
911 #endif
912 #if ! defined (YYSIZE_T) && defined (size_t)
913 # define YYSIZE_T size_t
914 #endif
915 #if ! defined (YYSIZE_T)
916 # if defined (__STDC__) || defined (__cplusplus)
917 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
918 # define YYSIZE_T size_t
919 # endif
920 #endif
921 #if ! defined (YYSIZE_T)
922 # define YYSIZE_T unsigned int
923 #endif
924
925 #define yyerrok (yyerrstatus = 0)
926 #define yyclearin (yychar = YYEMPTY)
927 #define YYEMPTY (-2)
928 #define YYEOF 0
929
930 #define YYACCEPT goto yyacceptlab
931 #define YYABORT goto yyabortlab
932 #define YYERROR goto yyerrorlab
933
934
935 /* Like YYERROR except do call yyerror. This remains here temporarily
936 to ease the transition to the new meaning of YYERROR, for GCC.
937 Once GCC version 2 has supplanted version 1, this can go. */
938
939 #define YYFAIL goto yyerrlab
940
941 #define YYRECOVERING() (!!yyerrstatus)
942
943 #define YYBACKUP(Token, Value) \
944 do \
945 if (yychar == YYEMPTY && yylen == 1) \
946 { \
947 yychar = (Token); \
948 yylval = (Value); \
949 yytoken = YYTRANSLATE (yychar); \
950 YYPOPSTACK; \
951 goto yybackup; \
952 } \
953 else \
954 { \
955 yyerror ("syntax error: cannot back up");\
956 YYERROR; \
957 } \
958 while (0)
959
960 #define YYTERROR 1
961 #define YYERRCODE 256
962
963 /* YYLLOC_DEFAULT -- Compute the default location (before the actions
964 are run). */
965
966 #ifndef YYLLOC_DEFAULT
967 # define YYLLOC_DEFAULT(Current, Rhs, N) \
968 ((Current).first_line = (Rhs)[1].first_line, \
969 (Current).first_column = (Rhs)[1].first_column, \
970 (Current).last_line = (Rhs)[N].last_line, \
971 (Current).last_column = (Rhs)[N].last_column)
972 #endif
973
974 /* YYLEX -- calling `yylex' with the right arguments. */
975
976 #ifdef YYLEX_PARAM
977 # define YYLEX yylex (YYLEX_PARAM)
978 #else
979 # define YYLEX yylex ()
980 #endif
981
982 /* Enable debugging if requested. */
983 #if YYDEBUG
984
985 # ifndef YYFPRINTF
986 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
987 # define YYFPRINTF fprintf
988 # endif
989
990 # define YYDPRINTF(Args) \
991 do { \
992 if (yydebug) \
993 YYFPRINTF Args; \
994 } while (0)
995
996 # define YYDSYMPRINT(Args) \
997 do { \
998 if (yydebug) \
999 yysymprint Args; \
1000 } while (0)
1001
1002 # define YYDSYMPRINTF(Title, Token, Value, Location) \
1003 do { \
1004 if (yydebug) \
1005 { \
1006 YYFPRINTF (stderr, "%s ", Title); \
1007 yysymprint (stderr, \
1008 Token, Value); \
1009 YYFPRINTF (stderr, "\n"); \
1010 } \
1011 } while (0)
1012
1013 /*------------------------------------------------------------------.
1014 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
1015 | TOP (included). |
1016 `------------------------------------------------------------------*/
1017
1018 #if defined (__STDC__) || defined (__cplusplus)
1019 static void
yy_stack_print(short * bottom,short * top)1020 yy_stack_print (short *bottom, short *top)
1021 #else
1022 static void
1023 yy_stack_print (bottom, top)
1024 short *bottom;
1025 short *top;
1026 #endif
1027 {
1028 YYFPRINTF (stderr, "Stack now");
1029 for (/* Nothing. */; bottom <= top; ++bottom)
1030 YYFPRINTF (stderr, " %d", *bottom);
1031 YYFPRINTF (stderr, "\n");
1032 }
1033
1034 # define YY_STACK_PRINT(Bottom, Top) \
1035 do { \
1036 if (yydebug) \
1037 yy_stack_print ((Bottom), (Top)); \
1038 } while (0)
1039
1040
1041 /*------------------------------------------------.
1042 | Report that the YYRULE is going to be reduced. |
1043 `------------------------------------------------*/
1044
1045 #if defined (__STDC__) || defined (__cplusplus)
1046 static void
yy_reduce_print(int yyrule)1047 yy_reduce_print (int yyrule)
1048 #else
1049 static void
1050 yy_reduce_print (yyrule)
1051 int yyrule;
1052 #endif
1053 {
1054 int yyi;
1055 unsigned int yylno = yyrline[yyrule];
1056 YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ",
1057 yyrule - 1, yylno);
1058 /* Print the symbols being reduced, and their result. */
1059 for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
1060 YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]);
1061 YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]);
1062 }
1063
1064 # define YY_REDUCE_PRINT(Rule) \
1065 do { \
1066 if (yydebug) \
1067 yy_reduce_print (Rule); \
1068 } while (0)
1069
1070 /* Nonzero means print parse trace. It is left uninitialized so that
1071 multiple parsers can coexist. */
1072 int yydebug;
1073 #else /* !YYDEBUG */
1074 # define YYDPRINTF(Args)
1075 # define YYDSYMPRINT(Args)
1076 # define YYDSYMPRINTF(Title, Token, Value, Location)
1077 # define YY_STACK_PRINT(Bottom, Top)
1078 # define YY_REDUCE_PRINT(Rule)
1079 #endif /* !YYDEBUG */
1080
1081
1082 /* YYINITDEPTH -- initial size of the parser's stacks. */
1083 #ifndef YYINITDEPTH
1084 # define YYINITDEPTH 200
1085 #endif
1086
1087 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
1088 if the built-in stack extension method is used).
1089
1090 Do not make this value too large; the results are undefined if
1091 SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
1092 evaluated with infinite-precision integer arithmetic. */
1093
1094 #if defined (YYMAXDEPTH) && YYMAXDEPTH == 0
1095 # undef YYMAXDEPTH
1096 #endif
1097
1098 #ifndef YYMAXDEPTH
1099 # define YYMAXDEPTH 10000
1100 #endif
1101
1102
1103
1104 #if YYERROR_VERBOSE
1105
1106 # ifndef yystrlen
1107 # if defined (__GLIBC__) && defined (_STRING_H)
1108 # define yystrlen strlen
1109 # else
1110 /* Return the length of YYSTR. */
1111 static YYSIZE_T
1112 # if defined (__STDC__) || defined (__cplusplus)
yystrlen(const char * yystr)1113 yystrlen (const char *yystr)
1114 # else
1115 yystrlen (yystr)
1116 const char *yystr;
1117 # endif
1118 {
1119 register const char *yys = yystr;
1120
1121 while (*yys++ != '\0')
1122 continue;
1123
1124 return yys - yystr - 1;
1125 }
1126 # endif
1127 # endif
1128
1129 # ifndef yystpcpy
1130 # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
1131 # define yystpcpy stpcpy
1132 # else
1133 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
1134 YYDEST. */
1135 static char *
1136 # if defined (__STDC__) || defined (__cplusplus)
yystpcpy(char * yydest,const char * yysrc)1137 yystpcpy (char *yydest, const char *yysrc)
1138 # else
1139 yystpcpy (yydest, yysrc)
1140 char *yydest;
1141 const char *yysrc;
1142 # endif
1143 {
1144 register char *yyd = yydest;
1145 register const char *yys = yysrc;
1146
1147 while ((*yyd++ = *yys++) != '\0')
1148 continue;
1149
1150 return yyd - 1;
1151 }
1152 # endif
1153 # endif
1154
1155 #endif /* !YYERROR_VERBOSE */
1156
1157
1158
1159 #if YYDEBUG
1160 /*--------------------------------.
1161 | Print this symbol on YYOUTPUT. |
1162 `--------------------------------*/
1163
1164 #if defined (__STDC__) || defined (__cplusplus)
1165 static void
yysymprint(FILE * yyoutput,int yytype,YYSTYPE * yyvaluep)1166 yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep)
1167 #else
1168 static void
1169 yysymprint (yyoutput, yytype, yyvaluep)
1170 FILE *yyoutput;
1171 int yytype;
1172 YYSTYPE *yyvaluep;
1173 #endif
1174 {
1175 /* Pacify ``unused variable'' warnings. */
1176 (void) yyvaluep;
1177
1178 if (yytype < YYNTOKENS)
1179 {
1180 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
1181 # ifdef YYPRINT
1182 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
1183 # endif
1184 }
1185 else
1186 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
1187
1188 switch (yytype)
1189 {
1190 default:
1191 break;
1192 }
1193 YYFPRINTF (yyoutput, ")");
1194 }
1195
1196 #endif /* ! YYDEBUG */
1197 /*-----------------------------------------------.
1198 | Release the memory associated to this symbol. |
1199 `-----------------------------------------------*/
1200
1201 #if defined (__STDC__) || defined (__cplusplus)
1202 static void
yydestruct(int yytype,YYSTYPE * yyvaluep)1203 yydestruct (int yytype, YYSTYPE *yyvaluep)
1204 #else
1205 static void
1206 yydestruct (yytype, yyvaluep)
1207 int yytype;
1208 YYSTYPE *yyvaluep;
1209 #endif
1210 {
1211 /* Pacify ``unused variable'' warnings. */
1212 (void) yyvaluep;
1213
1214 switch (yytype)
1215 {
1216
1217 default:
1218 break;
1219 }
1220 }
1221
1222
1223 /* Prevent warnings from -Wmissing-prototypes. */
1224
1225 #ifdef YYPARSE_PARAM
1226 # if defined (__STDC__) || defined (__cplusplus)
1227 int yyparse (void *YYPARSE_PARAM);
1228 # else
1229 int yyparse ();
1230 # endif
1231 #else /* ! YYPARSE_PARAM */
1232 #if defined (__STDC__) || defined (__cplusplus)
1233 int yyparse (void);
1234 #else
1235 int yyparse ();
1236 #endif
1237 #endif /* ! YYPARSE_PARAM */
1238
1239
1240
1241 /* The lookahead symbol. */
1242 int yychar;
1243
1244 /* The semantic value of the lookahead symbol. */
1245 YYSTYPE yylval;
1246
1247 /* Number of syntax errors so far. */
1248 int yynerrs;
1249
1250
1251
1252 /*----------.
1253 | yyparse. |
1254 `----------*/
1255
1256 #ifdef YYPARSE_PARAM
1257 # if defined (__STDC__) || defined (__cplusplus)
yyparse(void * YYPARSE_PARAM)1258 int yyparse (void *YYPARSE_PARAM)
1259 # else
1260 int yyparse (YYPARSE_PARAM)
1261 void *YYPARSE_PARAM;
1262 # endif
1263 #else /* ! YYPARSE_PARAM */
1264 #if defined (__STDC__) || defined (__cplusplus)
1265 int
1266 yyparse (void)
1267 #else
1268 int
1269 yyparse ()
1270
1271 #endif
1272 #endif
1273 {
1274
1275 register int yystate;
1276 register int yyn;
1277 int yyresult;
1278 /* Number of tokens to shift before error messages enabled. */
1279 int yyerrstatus;
1280 /* Lookahead token as an internal (translated) token number. */
1281 int yytoken = 0;
1282
1283 /* Three stacks and their tools:
1284 `yyss': related to states,
1285 `yyvs': related to semantic values,
1286 `yyls': related to locations.
1287
1288 Refer to the stacks thru separate pointers, to allow yyoverflow
1289 to xreallocate them elsewhere. */
1290
1291 /* The state stack. */
1292 short yyssa[YYINITDEPTH];
1293 short *yyss = yyssa;
1294 register short *yyssp;
1295
1296 /* The semantic value stack. */
1297 YYSTYPE yyvsa[YYINITDEPTH];
1298 YYSTYPE *yyvs = yyvsa;
1299 register YYSTYPE *yyvsp;
1300
1301
1302
1303 #define YYPOPSTACK (yyvsp--, yyssp--)
1304
1305 YYSIZE_T yystacksize = YYINITDEPTH;
1306
1307 /* The variables used to return semantic value and location from the
1308 action routines. */
1309 YYSTYPE yyval;
1310
1311
1312 /* When reducing, the number of symbols on the RHS of the reduced
1313 rule. */
1314 int yylen;
1315
1316 YYDPRINTF ((stderr, "Starting parse\n"));
1317
1318 yystate = 0;
1319 yyerrstatus = 0;
1320 yynerrs = 0;
1321 yychar = YYEMPTY; /* Cause a token to be read. */
1322
1323 /* Initialize stack pointers.
1324 Waste one element of value and location stack
1325 so that they stay on the same level as the state stack.
1326 The wasted elements are never initialized. */
1327
1328 yyssp = yyss;
1329 yyvsp = yyvs;
1330
1331 goto yysetstate;
1332
1333 /*------------------------------------------------------------.
1334 | yynewstate -- Push a new state, which is found in yystate. |
1335 `------------------------------------------------------------*/
1336 yynewstate:
1337 /* In all cases, when you get here, the value and location stacks
1338 have just been pushed. so pushing a state here evens the stacks.
1339 */
1340 yyssp++;
1341
1342 yysetstate:
1343 *yyssp = yystate;
1344
1345 if (yyss + yystacksize - 1 <= yyssp)
1346 {
1347 /* Get the current used size of the three stacks, in elements. */
1348 YYSIZE_T yysize = yyssp - yyss + 1;
1349
1350 #ifdef yyoverflow
1351 {
1352 /* Give user a chance to xreallocate the stack. Use copies of
1353 these so that the &'s don't force the real ones into
1354 memory. */
1355 YYSTYPE *yyvs1 = yyvs;
1356 short *yyss1 = yyss;
1357
1358
1359 /* Each stack pointer address is followed by the size of the
1360 data in use in that stack, in bytes. This used to be a
1361 conditional around just the two extra args, but that might
1362 be undefined if yyoverflow is a macro. */
1363 yyoverflow ("parser stack overflow",
1364 &yyss1, yysize * sizeof (*yyssp),
1365 &yyvs1, yysize * sizeof (*yyvsp),
1366
1367 &yystacksize);
1368
1369 yyss = yyss1;
1370 yyvs = yyvs1;
1371 }
1372 #else /* no yyoverflow */
1373 # ifndef YYSTACK_RELOCATE
1374 goto yyoverflowlab;
1375 # else
1376 /* Extend the stack our own way. */
1377 if (YYMAXDEPTH <= yystacksize)
1378 goto yyoverflowlab;
1379 yystacksize *= 2;
1380 if (YYMAXDEPTH < yystacksize)
1381 yystacksize = YYMAXDEPTH;
1382
1383 {
1384 short *yyss1 = yyss;
1385 union yyalloc *yyptr =
1386 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1387 if (! yyptr)
1388 goto yyoverflowlab;
1389 YYSTACK_RELOCATE (yyss);
1390 YYSTACK_RELOCATE (yyvs);
1391
1392 # undef YYSTACK_RELOCATE
1393 if (yyss1 != yyssa)
1394 YYSTACK_FREE (yyss1);
1395 }
1396 # endif
1397 #endif /* no yyoverflow */
1398
1399 yyssp = yyss + yysize - 1;
1400 yyvsp = yyvs + yysize - 1;
1401
1402
1403 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1404 (unsigned long int) yystacksize));
1405
1406 if (yyss + yystacksize - 1 <= yyssp)
1407 YYABORT;
1408 }
1409
1410 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1411
1412 goto yybackup;
1413
1414 /*-----------.
1415 | yybackup. |
1416 `-----------*/
1417 yybackup:
1418
1419 /* Do appropriate processing given the current state. */
1420 /* Read a lookahead token if we need one and don't already have one. */
1421 /* yyresume: */
1422
1423 /* First try to decide what to do without reference to lookahead token. */
1424
1425 yyn = yypact[yystate];
1426 if (yyn == YYPACT_NINF)
1427 goto yydefault;
1428
1429 /* Not known => get a lookahead token if don't already have one. */
1430
1431 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1432 if (yychar == YYEMPTY)
1433 {
1434 YYDPRINTF ((stderr, "Reading a token: "));
1435 yychar = YYLEX;
1436 }
1437
1438 if (yychar <= YYEOF)
1439 {
1440 yychar = yytoken = YYEOF;
1441 YYDPRINTF ((stderr, "Now at end of input.\n"));
1442 }
1443 else
1444 {
1445 yytoken = YYTRANSLATE (yychar);
1446 YYDSYMPRINTF ("Next token is", yytoken, &yylval, &yylloc);
1447 }
1448
1449 /* If the proper action on seeing token YYTOKEN is to reduce or to
1450 detect an error, take that action. */
1451 yyn += yytoken;
1452 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1453 goto yydefault;
1454 yyn = yytable[yyn];
1455 if (yyn <= 0)
1456 {
1457 if (yyn == 0 || yyn == YYTABLE_NINF)
1458 goto yyerrlab;
1459 yyn = -yyn;
1460 goto yyreduce;
1461 }
1462
1463 if (yyn == YYFINAL)
1464 YYACCEPT;
1465
1466 /* Shift the lookahead token. */
1467 YYDPRINTF ((stderr, "Shifting token %s, ", yytname[yytoken]));
1468
1469 /* Discard the token being shifted unless it is eof. */
1470 if (yychar != YYEOF)
1471 yychar = YYEMPTY;
1472
1473 *++yyvsp = yylval;
1474
1475
1476 /* Count tokens shifted since error; after three, turn off error
1477 status. */
1478 if (yyerrstatus)
1479 yyerrstatus--;
1480
1481 yystate = yyn;
1482 goto yynewstate;
1483
1484
1485 /*-----------------------------------------------------------.
1486 | yydefault -- do the default action for the current state. |
1487 `-----------------------------------------------------------*/
1488 yydefault:
1489 yyn = yydefact[yystate];
1490 if (yyn == 0)
1491 goto yyerrlab;
1492 goto yyreduce;
1493
1494
1495 /*-----------------------------.
1496 | yyreduce -- Do a reduction. |
1497 `-----------------------------*/
1498 yyreduce:
1499 /* yyn is the number of a rule to reduce with. */
1500 yylen = yyr2[yyn];
1501
1502 /* If YYLEN is nonzero, implement the default value of the action:
1503 `$$ = $1'.
1504
1505 Otherwise, the following line sets YYVAL to garbage.
1506 This behavior is undocumented and Bison
1507 users should not rely upon it. Assigning to YYVAL
1508 unconditionally makes the parser a bit smaller, and it avoids a
1509 GCC warning that YYVAL may be used uninitialized. */
1510 yyval = yyvsp[1-yylen];
1511
1512
1513 YY_REDUCE_PRINT (yyn);
1514 switch (yyn)
1515 {
1516 case 4:
1517 #line 235 "c-exp.y"
1518 { write_exp_elt_opcode(OP_TYPE);
1519 write_exp_elt_type(yyvsp[0].tval);
1520 write_exp_elt_opcode(OP_TYPE);}
1521 break;
1522
1523 case 6:
1524 #line 243 "c-exp.y"
1525 { write_exp_elt_opcode (BINOP_COMMA); }
1526 break;
1527
1528 case 7:
1529 #line 248 "c-exp.y"
1530 { write_exp_elt_opcode (UNOP_IND); }
1531 break;
1532
1533 case 8:
1534 #line 252 "c-exp.y"
1535 { write_exp_elt_opcode (UNOP_ADDR); }
1536 break;
1537
1538 case 9:
1539 #line 256 "c-exp.y"
1540 { write_exp_elt_opcode (UNOP_NEG); }
1541 break;
1542
1543 case 10:
1544 #line 260 "c-exp.y"
1545 { write_exp_elt_opcode (UNOP_LOGICAL_NOT); }
1546 break;
1547
1548 case 11:
1549 #line 264 "c-exp.y"
1550 { write_exp_elt_opcode (UNOP_COMPLEMENT); }
1551 break;
1552
1553 case 12:
1554 #line 268 "c-exp.y"
1555 { write_exp_elt_opcode (UNOP_PREINCREMENT); }
1556 break;
1557
1558 case 13:
1559 #line 272 "c-exp.y"
1560 { write_exp_elt_opcode (UNOP_PREDECREMENT); }
1561 break;
1562
1563 case 14:
1564 #line 276 "c-exp.y"
1565 { write_exp_elt_opcode (UNOP_POSTINCREMENT); }
1566 break;
1567
1568 case 15:
1569 #line 280 "c-exp.y"
1570 { write_exp_elt_opcode (UNOP_POSTDECREMENT); }
1571 break;
1572
1573 case 16:
1574 #line 284 "c-exp.y"
1575 { write_exp_elt_opcode (UNOP_SIZEOF); }
1576 break;
1577
1578 case 17:
1579 #line 288 "c-exp.y"
1580 { write_exp_elt_opcode (STRUCTOP_PTR);
1581 write_exp_string (yyvsp[0].sval);
1582 write_exp_elt_opcode (STRUCTOP_PTR); }
1583 break;
1584
1585 case 18:
1586 #line 294 "c-exp.y"
1587 { /* exp->type::name becomes exp->*(&type::name) */
1588 /* Note: this doesn't work if name is a
1589 static member! FIXME */
1590 write_exp_elt_opcode (UNOP_ADDR);
1591 write_exp_elt_opcode (STRUCTOP_MPTR); }
1592 break;
1593
1594 case 19:
1595 #line 302 "c-exp.y"
1596 { write_exp_elt_opcode (STRUCTOP_MPTR); }
1597 break;
1598
1599 case 20:
1600 #line 306 "c-exp.y"
1601 { write_exp_elt_opcode (STRUCTOP_STRUCT);
1602 write_exp_string (yyvsp[0].sval);
1603 write_exp_elt_opcode (STRUCTOP_STRUCT); }
1604 break;
1605
1606 case 21:
1607 #line 312 "c-exp.y"
1608 { /* exp.type::name becomes exp.*(&type::name) */
1609 /* Note: this doesn't work if name is a
1610 static member! FIXME */
1611 write_exp_elt_opcode (UNOP_ADDR);
1612 write_exp_elt_opcode (STRUCTOP_MEMBER); }
1613 break;
1614
1615 case 22:
1616 #line 320 "c-exp.y"
1617 { write_exp_elt_opcode (STRUCTOP_MEMBER); }
1618 break;
1619
1620 case 23:
1621 #line 324 "c-exp.y"
1622 { write_exp_elt_opcode (BINOP_SUBSCRIPT); }
1623 break;
1624
1625 case 24:
1626 #line 330 "c-exp.y"
1627 { start_arglist (); }
1628 break;
1629
1630 case 25:
1631 #line 332 "c-exp.y"
1632 { write_exp_elt_opcode (OP_FUNCALL);
1633 write_exp_elt_longcst ((LONGEST) end_arglist ());
1634 write_exp_elt_opcode (OP_FUNCALL); }
1635 break;
1636
1637 case 26:
1638 #line 338 "c-exp.y"
1639 { start_arglist (); }
1640 break;
1641
1642 case 28:
1643 #line 345 "c-exp.y"
1644 { arglist_len = 1; }
1645 break;
1646
1647 case 29:
1648 #line 349 "c-exp.y"
1649 { arglist_len++; }
1650 break;
1651
1652 case 30:
1653 #line 353 "c-exp.y"
1654 { yyval.lval = end_arglist () - 1; }
1655 break;
1656
1657 case 31:
1658 #line 356 "c-exp.y"
1659 { write_exp_elt_opcode (OP_ARRAY);
1660 write_exp_elt_longcst ((LONGEST) 0);
1661 write_exp_elt_longcst ((LONGEST) yyvsp[0].lval);
1662 write_exp_elt_opcode (OP_ARRAY); }
1663 break;
1664
1665 case 32:
1666 #line 363 "c-exp.y"
1667 { write_exp_elt_opcode (UNOP_MEMVAL);
1668 write_exp_elt_type (yyvsp[-2].tval);
1669 write_exp_elt_opcode (UNOP_MEMVAL); }
1670 break;
1671
1672 case 33:
1673 #line 369 "c-exp.y"
1674 { write_exp_elt_opcode (UNOP_CAST);
1675 write_exp_elt_type (yyvsp[-2].tval);
1676 write_exp_elt_opcode (UNOP_CAST); }
1677 break;
1678
1679 case 34:
1680 #line 375 "c-exp.y"
1681 { }
1682 break;
1683
1684 case 35:
1685 #line 381 "c-exp.y"
1686 { write_exp_elt_opcode (BINOP_REPEAT); }
1687 break;
1688
1689 case 36:
1690 #line 385 "c-exp.y"
1691 { write_exp_elt_opcode (BINOP_MUL); }
1692 break;
1693
1694 case 37:
1695 #line 389 "c-exp.y"
1696 { write_exp_elt_opcode (BINOP_DIV); }
1697 break;
1698
1699 case 38:
1700 #line 393 "c-exp.y"
1701 { write_exp_elt_opcode (BINOP_REM); }
1702 break;
1703
1704 case 39:
1705 #line 397 "c-exp.y"
1706 { write_exp_elt_opcode (BINOP_ADD); }
1707 break;
1708
1709 case 40:
1710 #line 401 "c-exp.y"
1711 { write_exp_elt_opcode (BINOP_SUB); }
1712 break;
1713
1714 case 41:
1715 #line 405 "c-exp.y"
1716 { write_exp_elt_opcode (BINOP_LSH); }
1717 break;
1718
1719 case 42:
1720 #line 409 "c-exp.y"
1721 { write_exp_elt_opcode (BINOP_RSH); }
1722 break;
1723
1724 case 43:
1725 #line 413 "c-exp.y"
1726 { write_exp_elt_opcode (BINOP_EQUAL); }
1727 break;
1728
1729 case 44:
1730 #line 417 "c-exp.y"
1731 { write_exp_elt_opcode (BINOP_NOTEQUAL); }
1732 break;
1733
1734 case 45:
1735 #line 421 "c-exp.y"
1736 { write_exp_elt_opcode (BINOP_LEQ); }
1737 break;
1738
1739 case 46:
1740 #line 425 "c-exp.y"
1741 { write_exp_elt_opcode (BINOP_GEQ); }
1742 break;
1743
1744 case 47:
1745 #line 429 "c-exp.y"
1746 { write_exp_elt_opcode (BINOP_LESS); }
1747 break;
1748
1749 case 48:
1750 #line 433 "c-exp.y"
1751 { write_exp_elt_opcode (BINOP_GTR); }
1752 break;
1753
1754 case 49:
1755 #line 437 "c-exp.y"
1756 { write_exp_elt_opcode (BINOP_BITWISE_AND); }
1757 break;
1758
1759 case 50:
1760 #line 441 "c-exp.y"
1761 { write_exp_elt_opcode (BINOP_BITWISE_XOR); }
1762 break;
1763
1764 case 51:
1765 #line 445 "c-exp.y"
1766 { write_exp_elt_opcode (BINOP_BITWISE_IOR); }
1767 break;
1768
1769 case 52:
1770 #line 449 "c-exp.y"
1771 { write_exp_elt_opcode (BINOP_LOGICAL_AND); }
1772 break;
1773
1774 case 53:
1775 #line 453 "c-exp.y"
1776 { write_exp_elt_opcode (BINOP_LOGICAL_OR); }
1777 break;
1778
1779 case 54:
1780 #line 457 "c-exp.y"
1781 { write_exp_elt_opcode (TERNOP_COND); }
1782 break;
1783
1784 case 55:
1785 #line 461 "c-exp.y"
1786 { write_exp_elt_opcode (BINOP_ASSIGN); }
1787 break;
1788
1789 case 56:
1790 #line 465 "c-exp.y"
1791 { write_exp_elt_opcode (BINOP_ASSIGN_MODIFY);
1792 write_exp_elt_opcode (yyvsp[-1].opcode);
1793 write_exp_elt_opcode (BINOP_ASSIGN_MODIFY); }
1794 break;
1795
1796 case 57:
1797 #line 471 "c-exp.y"
1798 { write_exp_elt_opcode (OP_LONG);
1799 write_exp_elt_type (yyvsp[0].typed_val_int.type);
1800 write_exp_elt_longcst ((LONGEST)(yyvsp[0].typed_val_int.val));
1801 write_exp_elt_opcode (OP_LONG); }
1802 break;
1803
1804 case 58:
1805 #line 478 "c-exp.y"
1806 { YYSTYPE val;
1807 parse_number (yyvsp[0].ssym.stoken.ptr, yyvsp[0].ssym.stoken.length, 0, &val);
1808 write_exp_elt_opcode (OP_LONG);
1809 write_exp_elt_type (val.typed_val_int.type);
1810 write_exp_elt_longcst ((LONGEST)val.typed_val_int.val);
1811 write_exp_elt_opcode (OP_LONG);
1812 }
1813 break;
1814
1815 case 59:
1816 #line 489 "c-exp.y"
1817 { write_exp_elt_opcode (OP_DOUBLE);
1818 write_exp_elt_type (yyvsp[0].typed_val_float.type);
1819 write_exp_elt_dblcst (yyvsp[0].typed_val_float.dval);
1820 write_exp_elt_opcode (OP_DOUBLE); }
1821 break;
1822
1823 case 62:
1824 #line 503 "c-exp.y"
1825 { write_exp_elt_opcode (OP_LONG);
1826 write_exp_elt_type (builtin_type (current_gdbarch)->builtin_int);
1827 CHECK_TYPEDEF (yyvsp[-1].tval);
1828 write_exp_elt_longcst ((LONGEST) TYPE_LENGTH (yyvsp[-1].tval));
1829 write_exp_elt_opcode (OP_LONG); }
1830 break;
1831
1832 case 63:
1833 #line 511 "c-exp.y"
1834 { /* C strings are converted into array constants with
1835 an explicit null byte added at the end. Thus
1836 the array upper bound is the string length.
1837 There is no such thing in C as a completely empty
1838 string. */
1839 char *sp = yyvsp[0].sval.ptr; int count = yyvsp[0].sval.length;
1840 while (count-- > 0)
1841 {
1842 write_exp_elt_opcode (OP_LONG);
1843 write_exp_elt_type (builtin_type (current_gdbarch)->builtin_char);
1844 write_exp_elt_longcst ((LONGEST)(*sp++));
1845 write_exp_elt_opcode (OP_LONG);
1846 }
1847 write_exp_elt_opcode (OP_LONG);
1848 write_exp_elt_type (builtin_type (current_gdbarch)->builtin_char);
1849 write_exp_elt_longcst ((LONGEST)'\0');
1850 write_exp_elt_opcode (OP_LONG);
1851 write_exp_elt_opcode (OP_ARRAY);
1852 write_exp_elt_longcst ((LONGEST) 0);
1853 write_exp_elt_longcst ((LONGEST) (yyvsp[0].sval.length));
1854 write_exp_elt_opcode (OP_ARRAY); }
1855 break;
1856
1857 case 64:
1858 #line 536 "c-exp.y"
1859 { write_exp_elt_opcode (OP_LONG);
1860 write_exp_elt_type (builtin_type (current_gdbarch)->builtin_bool);
1861 write_exp_elt_longcst ((LONGEST) 1);
1862 write_exp_elt_opcode (OP_LONG); }
1863 break;
1864
1865 case 65:
1866 #line 543 "c-exp.y"
1867 { write_exp_elt_opcode (OP_LONG);
1868 write_exp_elt_type (builtin_type (current_gdbarch)->builtin_bool);
1869 write_exp_elt_longcst ((LONGEST) 0);
1870 write_exp_elt_opcode (OP_LONG); }
1871 break;
1872
1873 case 66:
1874 #line 552 "c-exp.y"
1875 {
1876 if (yyvsp[0].ssym.sym)
1877 yyval.bval = SYMBOL_BLOCK_VALUE (yyvsp[0].ssym.sym);
1878 else
1879 error ("No file or function \"%s\".",
1880 copy_name (yyvsp[0].ssym.stoken));
1881 }
1882 break;
1883
1884 case 67:
1885 #line 560 "c-exp.y"
1886 {
1887 yyval.bval = yyvsp[0].bval;
1888 }
1889 break;
1890
1891 case 68:
1892 #line 566 "c-exp.y"
1893 { struct symbol *tem
1894 = lookup_symbol (copy_name (yyvsp[0].sval), yyvsp[-2].bval,
1895 VAR_DOMAIN, (int *) NULL,
1896 (struct symtab **) NULL);
1897 if (!tem || SYMBOL_CLASS (tem) != LOC_BLOCK)
1898 error ("No function \"%s\" in specified context.",
1899 copy_name (yyvsp[0].sval));
1900 yyval.bval = SYMBOL_BLOCK_VALUE (tem); }
1901 break;
1902
1903 case 69:
1904 #line 577 "c-exp.y"
1905 { struct symbol *sym;
1906 sym = lookup_symbol (copy_name (yyvsp[0].sval), yyvsp[-2].bval,
1907 VAR_DOMAIN, (int *) NULL,
1908 (struct symtab **) NULL);
1909 if (sym == 0)
1910 error ("No symbol \"%s\" in specified context.",
1911 copy_name (yyvsp[0].sval));
1912
1913 write_exp_elt_opcode (OP_VAR_VALUE);
1914 /* block_found is set by lookup_symbol. */
1915 write_exp_elt_block (block_found);
1916 write_exp_elt_sym (sym);
1917 write_exp_elt_opcode (OP_VAR_VALUE); }
1918 break;
1919
1920 case 70:
1921 #line 593 "c-exp.y"
1922 {
1923 struct type *type = yyvsp[-2].tval;
1924 if (TYPE_CODE (type) != TYPE_CODE_STRUCT
1925 && TYPE_CODE (type) != TYPE_CODE_UNION
1926 && TYPE_CODE (type) != TYPE_CODE_NAMESPACE)
1927 error ("`%s' is not defined as an aggregate type.",
1928 TYPE_NAME (type));
1929
1930 write_exp_elt_opcode (OP_SCOPE);
1931 write_exp_elt_type (type);
1932 write_exp_string (yyvsp[0].sval);
1933 write_exp_elt_opcode (OP_SCOPE);
1934 }
1935 break;
1936
1937 case 71:
1938 #line 607 "c-exp.y"
1939 {
1940 struct type *type = yyvsp[-3].tval;
1941 struct stoken tmp_token;
1942 if (TYPE_CODE (type) != TYPE_CODE_STRUCT
1943 && TYPE_CODE (type) != TYPE_CODE_UNION
1944 && TYPE_CODE (type) != TYPE_CODE_NAMESPACE)
1945 error ("`%s' is not defined as an aggregate type.",
1946 TYPE_NAME (type));
1947
1948 tmp_token.ptr = (char*) alloca (yyvsp[0].sval.length + 2);
1949 tmp_token.length = yyvsp[0].sval.length + 1;
1950 tmp_token.ptr[0] = '~';
1951 memcpy (tmp_token.ptr+1, yyvsp[0].sval.ptr, yyvsp[0].sval.length);
1952 tmp_token.ptr[tmp_token.length] = 0;
1953
1954 /* Check for valid destructor name. */
1955 destructor_name_p (tmp_token.ptr, type);
1956 write_exp_elt_opcode (OP_SCOPE);
1957 write_exp_elt_type (type);
1958 write_exp_string (tmp_token);
1959 write_exp_elt_opcode (OP_SCOPE);
1960 }
1961 break;
1962
1963 case 73:
1964 #line 633 "c-exp.y"
1965 {
1966 char *name = copy_name (yyvsp[0].sval);
1967 struct symbol *sym;
1968 struct minimal_symbol *msymbol;
1969
1970 sym =
1971 lookup_symbol (name, (const struct block *) NULL,
1972 VAR_DOMAIN, (int *) NULL,
1973 (struct symtab **) NULL);
1974 if (sym)
1975 {
1976 write_exp_elt_opcode (OP_VAR_VALUE);
1977 write_exp_elt_block (NULL);
1978 write_exp_elt_sym (sym);
1979 write_exp_elt_opcode (OP_VAR_VALUE);
1980 break;
1981 }
1982
1983 msymbol = lookup_minimal_symbol (name, NULL, NULL);
1984 if (msymbol != NULL)
1985 {
1986 write_exp_msymbol (msymbol,
1987 lookup_function_type (builtin_type (current_gdbarch)->builtin_int),
1988 builtin_type (current_gdbarch)->builtin_int);
1989 }
1990 else
1991 if (!have_full_symbols () && !have_partial_symbols ())
1992 error ("No symbol table is loaded. Use the \"file\" command.");
1993 else
1994 error ("No symbol \"%s\" in current context.", name);
1995 }
1996 break;
1997
1998 case 74:
1999 #line 667 "c-exp.y"
2000 { struct symbol *sym = yyvsp[0].ssym.sym;
2001
2002 if (sym)
2003 {
2004 if (symbol_read_needs_frame (sym))
2005 {
2006 if (innermost_block == 0 ||
2007 contained_in (block_found,
2008 innermost_block))
2009 innermost_block = block_found;
2010 }
2011
2012 write_exp_elt_opcode (OP_VAR_VALUE);
2013 /* We want to use the selected frame, not
2014 another more inner frame which happens to
2015 be in the same block. */
2016 write_exp_elt_block (NULL);
2017 write_exp_elt_sym (sym);
2018 write_exp_elt_opcode (OP_VAR_VALUE);
2019 }
2020 else if (yyvsp[0].ssym.is_a_field_of_this)
2021 {
2022 /* C++: it hangs off of `this'. Must
2023 not inadvertently convert from a method call
2024 to data ref. */
2025 if (innermost_block == 0 ||
2026 contained_in (block_found, innermost_block))
2027 innermost_block = block_found;
2028 write_exp_elt_opcode (OP_THIS);
2029 write_exp_elt_opcode (OP_THIS);
2030 write_exp_elt_opcode (STRUCTOP_PTR);
2031 write_exp_string (yyvsp[0].ssym.stoken);
2032 write_exp_elt_opcode (STRUCTOP_PTR);
2033 }
2034 else
2035 {
2036 struct minimal_symbol *msymbol;
2037 char *arg = copy_name (yyvsp[0].ssym.stoken);
2038
2039 msymbol =
2040 lookup_minimal_symbol (arg, NULL, NULL);
2041 if (msymbol != NULL)
2042 {
2043 write_exp_msymbol (msymbol,
2044 lookup_function_type (builtin_type (current_gdbarch)->builtin_int),
2045 builtin_type (current_gdbarch)->builtin_int);
2046 }
2047 else if (!have_full_symbols () && !have_partial_symbols ())
2048 error ("No symbol table is loaded. Use the \"file\" command.");
2049 else
2050 error ("No symbol \"%s\" in current context.",
2051 copy_name (yyvsp[0].ssym.stoken));
2052 }
2053 }
2054 break;
2055
2056 case 75:
2057 #line 724 "c-exp.y"
2058 { push_type_address_space (copy_name (yyvsp[0].ssym.stoken));
2059 push_type (tp_space_identifier);
2060 }
2061 break;
2062
2063 case 83:
2064 #line 746 "c-exp.y"
2065 { push_type (tp_pointer); yyval.voidval = 0; }
2066 break;
2067
2068 case 84:
2069 #line 748 "c-exp.y"
2070 { push_type (tp_pointer); yyval.voidval = yyvsp[0].voidval; }
2071 break;
2072
2073 case 85:
2074 #line 750 "c-exp.y"
2075 { push_type (tp_reference); yyval.voidval = 0; }
2076 break;
2077
2078 case 86:
2079 #line 752 "c-exp.y"
2080 { push_type (tp_reference); yyval.voidval = yyvsp[0].voidval; }
2081 break;
2082
2083 case 88:
2084 #line 757 "c-exp.y"
2085 { yyval.voidval = yyvsp[-1].voidval; }
2086 break;
2087
2088 case 89:
2089 #line 759 "c-exp.y"
2090 {
2091 push_type_int (yyvsp[0].lval);
2092 push_type (tp_array);
2093 }
2094 break;
2095
2096 case 90:
2097 #line 764 "c-exp.y"
2098 {
2099 push_type_int (yyvsp[0].lval);
2100 push_type (tp_array);
2101 yyval.voidval = 0;
2102 }
2103 break;
2104
2105 case 91:
2106 #line 771 "c-exp.y"
2107 { push_type (tp_function); }
2108 break;
2109
2110 case 92:
2111 #line 773 "c-exp.y"
2112 { push_type (tp_function); }
2113 break;
2114
2115 case 93:
2116 #line 777 "c-exp.y"
2117 { yyval.lval = -1; }
2118 break;
2119
2120 case 94:
2121 #line 779 "c-exp.y"
2122 { yyval.lval = yyvsp[-1].typed_val_int.val; }
2123 break;
2124
2125 case 95:
2126 #line 783 "c-exp.y"
2127 { yyval.voidval = 0; }
2128 break;
2129
2130 case 96:
2131 #line 785 "c-exp.y"
2132 { free (yyvsp[-1].tvec); yyval.voidval = 0; }
2133 break;
2134
2135 case 98:
2136 #line 798 "c-exp.y"
2137 { yyval.tval = lookup_member_type (builtin_type (current_gdbarch)->builtin_int, yyvsp[-2].tval); }
2138 break;
2139
2140 case 99:
2141 #line 803 "c-exp.y"
2142 { yyval.tval = yyvsp[0].tsym.type; }
2143 break;
2144
2145 case 100:
2146 #line 805 "c-exp.y"
2147 { yyval.tval = builtin_type (current_gdbarch)->builtin_int; }
2148 break;
2149
2150 case 101:
2151 #line 807 "c-exp.y"
2152 { yyval.tval = builtin_type (current_gdbarch)->builtin_long; }
2153 break;
2154
2155 case 102:
2156 #line 809 "c-exp.y"
2157 { yyval.tval = builtin_type (current_gdbarch)->builtin_short; }
2158 break;
2159
2160 case 103:
2161 #line 811 "c-exp.y"
2162 { yyval.tval = builtin_type (current_gdbarch)->builtin_long; }
2163 break;
2164
2165 case 104:
2166 #line 813 "c-exp.y"
2167 { yyval.tval = builtin_type (current_gdbarch)->builtin_long; }
2168 break;
2169
2170 case 105:
2171 #line 815 "c-exp.y"
2172 { yyval.tval = builtin_type (current_gdbarch)->builtin_long; }
2173 break;
2174
2175 case 106:
2176 #line 817 "c-exp.y"
2177 { yyval.tval = builtin_type (current_gdbarch)->builtin_long; }
2178 break;
2179
2180 case 107:
2181 #line 819 "c-exp.y"
2182 { yyval.tval = builtin_type (current_gdbarch)->builtin_unsigned_long; }
2183 break;
2184
2185 case 108:
2186 #line 821 "c-exp.y"
2187 { yyval.tval = builtin_type (current_gdbarch)->builtin_unsigned_long; }
2188 break;
2189
2190 case 109:
2191 #line 823 "c-exp.y"
2192 { yyval.tval = builtin_type (current_gdbarch)->builtin_unsigned_long; }
2193 break;
2194
2195 case 110:
2196 #line 825 "c-exp.y"
2197 { yyval.tval = builtin_type (current_gdbarch)->builtin_long_long; }
2198 break;
2199
2200 case 111:
2201 #line 827 "c-exp.y"
2202 { yyval.tval = builtin_type (current_gdbarch)->builtin_long_long; }
2203 break;
2204
2205 case 112:
2206 #line 829 "c-exp.y"
2207 { yyval.tval = builtin_type (current_gdbarch)->builtin_long_long; }
2208 break;
2209
2210 case 113:
2211 #line 831 "c-exp.y"
2212 { yyval.tval = builtin_type (current_gdbarch)->builtin_long_long; }
2213 break;
2214
2215 case 114:
2216 #line 833 "c-exp.y"
2217 { yyval.tval = builtin_type (current_gdbarch)->builtin_long_long; }
2218 break;
2219
2220 case 115:
2221 #line 835 "c-exp.y"
2222 { yyval.tval = builtin_type (current_gdbarch)->builtin_long_long; }
2223 break;
2224
2225 case 116:
2226 #line 837 "c-exp.y"
2227 { yyval.tval = builtin_type (current_gdbarch)->builtin_unsigned_long_long; }
2228 break;
2229
2230 case 117:
2231 #line 839 "c-exp.y"
2232 { yyval.tval = builtin_type (current_gdbarch)->builtin_unsigned_long_long; }
2233 break;
2234
2235 case 118:
2236 #line 841 "c-exp.y"
2237 { yyval.tval = builtin_type (current_gdbarch)->builtin_unsigned_long_long; }
2238 break;
2239
2240 case 119:
2241 #line 843 "c-exp.y"
2242 { yyval.tval = builtin_type (current_gdbarch)->builtin_unsigned_long_long; }
2243 break;
2244
2245 case 120:
2246 #line 845 "c-exp.y"
2247 { yyval.tval = builtin_type (current_gdbarch)->builtin_short; }
2248 break;
2249
2250 case 121:
2251 #line 847 "c-exp.y"
2252 { yyval.tval = builtin_type (current_gdbarch)->builtin_short; }
2253 break;
2254
2255 case 122:
2256 #line 849 "c-exp.y"
2257 { yyval.tval = builtin_type (current_gdbarch)->builtin_short; }
2258 break;
2259
2260 case 123:
2261 #line 851 "c-exp.y"
2262 { yyval.tval = builtin_type (current_gdbarch)->builtin_unsigned_short; }
2263 break;
2264
2265 case 124:
2266 #line 853 "c-exp.y"
2267 { yyval.tval = builtin_type (current_gdbarch)->builtin_unsigned_short; }
2268 break;
2269
2270 case 125:
2271 #line 855 "c-exp.y"
2272 { yyval.tval = builtin_type (current_gdbarch)->builtin_unsigned_short; }
2273 break;
2274
2275 case 126:
2276 #line 857 "c-exp.y"
2277 { yyval.tval = builtin_type (current_gdbarch)->builtin_double; }
2278 break;
2279
2280 case 127:
2281 #line 859 "c-exp.y"
2282 { yyval.tval = builtin_type (current_gdbarch)->builtin_long_double; }
2283 break;
2284
2285 case 128:
2286 #line 861 "c-exp.y"
2287 { yyval.tval = lookup_struct (copy_name (yyvsp[0].sval),
2288 expression_context_block); }
2289 break;
2290
2291 case 129:
2292 #line 864 "c-exp.y"
2293 { yyval.tval = lookup_struct (copy_name (yyvsp[0].sval),
2294 expression_context_block); }
2295 break;
2296
2297 case 130:
2298 #line 867 "c-exp.y"
2299 { yyval.tval = lookup_union (copy_name (yyvsp[0].sval),
2300 expression_context_block); }
2301 break;
2302
2303 case 131:
2304 #line 870 "c-exp.y"
2305 { yyval.tval = lookup_enum (copy_name (yyvsp[0].sval),
2306 expression_context_block); }
2307 break;
2308
2309 case 132:
2310 #line 873 "c-exp.y"
2311 { yyval.tval = lookup_unsigned_typename (TYPE_NAME(yyvsp[0].tsym.type)); }
2312 break;
2313
2314 case 133:
2315 #line 875 "c-exp.y"
2316 { yyval.tval = builtin_type (current_gdbarch)->builtin_unsigned_int; }
2317 break;
2318
2319 case 134:
2320 #line 877 "c-exp.y"
2321 { yyval.tval = lookup_signed_typename (TYPE_NAME(yyvsp[0].tsym.type)); }
2322 break;
2323
2324 case 135:
2325 #line 879 "c-exp.y"
2326 { yyval.tval = builtin_type (current_gdbarch)->builtin_int; }
2327 break;
2328
2329 case 136:
2330 #line 884 "c-exp.y"
2331 { yyval.tval = lookup_template_type(copy_name(yyvsp[-3].sval), yyvsp[-1].tval,
2332 expression_context_block);
2333 }
2334 break;
2335
2336 case 137:
2337 #line 888 "c-exp.y"
2338 { yyval.tval = follow_types (yyvsp[0].tval); }
2339 break;
2340
2341 case 138:
2342 #line 890 "c-exp.y"
2343 { yyval.tval = follow_types (yyvsp[-1].tval); }
2344 break;
2345
2346 case 140:
2347 #line 940 "c-exp.y"
2348 {
2349 struct type *type = yyvsp[-2].tval;
2350 struct type *new_type;
2351 char *ncopy = alloca (yyvsp[0].sval.length + 1);
2352
2353 memcpy (ncopy, yyvsp[0].sval.ptr, yyvsp[0].sval.length);
2354 ncopy[yyvsp[0].sval.length] = '\0';
2355
2356 if (TYPE_CODE (type) != TYPE_CODE_STRUCT
2357 && TYPE_CODE (type) != TYPE_CODE_UNION
2358 && TYPE_CODE (type) != TYPE_CODE_NAMESPACE)
2359 error ("`%s' is not defined as an aggregate type.",
2360 TYPE_NAME (type));
2361
2362 new_type = cp_lookup_nested_type (type, ncopy,
2363 expression_context_block);
2364 if (new_type == NULL)
2365 error ("No type \"%s\" within class or namespace \"%s\".",
2366 ncopy, TYPE_NAME (type));
2367
2368 yyval.tval = new_type;
2369 }
2370 break;
2371
2372 case 142:
2373 #line 966 "c-exp.y"
2374 {
2375 yyval.tsym.stoken.ptr = "int";
2376 yyval.tsym.stoken.length = 3;
2377 yyval.tsym.type = builtin_type (current_gdbarch)->builtin_int;
2378 }
2379 break;
2380
2381 case 143:
2382 #line 972 "c-exp.y"
2383 {
2384 yyval.tsym.stoken.ptr = "long";
2385 yyval.tsym.stoken.length = 4;
2386 yyval.tsym.type = builtin_type (current_gdbarch)->builtin_long;
2387 }
2388 break;
2389
2390 case 144:
2391 #line 978 "c-exp.y"
2392 {
2393 yyval.tsym.stoken.ptr = "short";
2394 yyval.tsym.stoken.length = 5;
2395 yyval.tsym.type = builtin_type (current_gdbarch)->builtin_short;
2396 }
2397 break;
2398
2399 case 145:
2400 #line 987 "c-exp.y"
2401 { yyval.tvec = (struct type **) xmalloc (sizeof (struct type *) * 2);
2402 yyval.ivec[0] = 1; /* Number of types in vector */
2403 yyval.tvec[1] = yyvsp[0].tval;
2404 }
2405 break;
2406
2407 case 146:
2408 #line 992 "c-exp.y"
2409 { int len = sizeof (struct type *) * (++(yyvsp[-2].ivec[0]) + 1);
2410 yyval.tvec = (struct type **) xrealloc ((char *) yyvsp[-2].tvec, len);
2411 yyval.tvec[yyval.ivec[0]] = yyvsp[0].tval;
2412 }
2413 break;
2414
2415 case 148:
2416 #line 1000 "c-exp.y"
2417 { yyval.tval = follow_types (yyvsp[-3].tval); }
2418 break;
2419
2420 case 151:
2421 #line 1008 "c-exp.y"
2422 { push_type (tp_const);
2423 push_type (tp_volatile);
2424 }
2425 break;
2426
2427 case 152:
2428 #line 1012 "c-exp.y"
2429 { push_type (tp_const); }
2430 break;
2431
2432 case 153:
2433 #line 1014 "c-exp.y"
2434 { push_type (tp_volatile); }
2435 break;
2436
2437 case 154:
2438 #line 1017 "c-exp.y"
2439 { yyval.sval = yyvsp[0].ssym.stoken; }
2440 break;
2441
2442 case 155:
2443 #line 1018 "c-exp.y"
2444 { yyval.sval = yyvsp[0].ssym.stoken; }
2445 break;
2446
2447 case 156:
2448 #line 1019 "c-exp.y"
2449 { yyval.sval = yyvsp[0].tsym.stoken; }
2450 break;
2451
2452 case 157:
2453 #line 1020 "c-exp.y"
2454 { yyval.sval = yyvsp[0].ssym.stoken; }
2455 break;
2456
2457
2458 }
2459
2460 /* Line 1000 of yacc.c. */
2461
2462 yyvsp -= yylen;
2463 yyssp -= yylen;
2464
2465
2466 YY_STACK_PRINT (yyss, yyssp);
2467
2468 *++yyvsp = yyval;
2469
2470
2471 /* Now `shift' the result of the reduction. Determine what state
2472 that goes to, based on the state we popped back to and the rule
2473 number reduced by. */
2474
2475 yyn = yyr1[yyn];
2476
2477 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
2478 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
2479 yystate = yytable[yystate];
2480 else
2481 yystate = yydefgoto[yyn - YYNTOKENS];
2482
2483 goto yynewstate;
2484
2485
2486 /*------------------------------------.
2487 | yyerrlab -- here on detecting error |
2488 `------------------------------------*/
2489 yyerrlab:
2490 /* If not already recovering from an error, report this error. */
2491 if (!yyerrstatus)
2492 {
2493 ++yynerrs;
2494 #if YYERROR_VERBOSE
2495 yyn = yypact[yystate];
2496
2497 if (YYPACT_NINF < yyn && yyn < YYLAST)
2498 {
2499 YYSIZE_T yysize = 0;
2500 int yytype = YYTRANSLATE (yychar);
2501 const char* yyprefix;
2502 char *yymsg;
2503 int yyx;
2504
2505 /* Start YYX at -YYN if negative to avoid negative indexes in
2506 YYCHECK. */
2507 int yyxbegin = yyn < 0 ? -yyn : 0;
2508
2509 /* Stay within bounds of both yycheck and yytname. */
2510 int yychecklim = YYLAST - yyn;
2511 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
2512 int yycount = 0;
2513
2514 yyprefix = ", expecting ";
2515 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
2516 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
2517 {
2518 yysize += yystrlen (yyprefix) + yystrlen (yytname [yyx]);
2519 yycount += 1;
2520 if (yycount == 5)
2521 {
2522 yysize = 0;
2523 break;
2524 }
2525 }
2526 yysize += (sizeof ("syntax error, unexpected ")
2527 + yystrlen (yytname[yytype]));
2528 yymsg = (char *) YYSTACK_ALLOC (yysize);
2529 if (yymsg != 0)
2530 {
2531 char *yyp = yystpcpy (yymsg, "syntax error, unexpected ");
2532 yyp = yystpcpy (yyp, yytname[yytype]);
2533
2534 if (yycount < 5)
2535 {
2536 yyprefix = ", expecting ";
2537 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
2538 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
2539 {
2540 yyp = yystpcpy (yyp, yyprefix);
2541 yyp = yystpcpy (yyp, yytname[yyx]);
2542 yyprefix = " or ";
2543 }
2544 }
2545 yyerror (yymsg);
2546 YYSTACK_FREE (yymsg);
2547 }
2548 else
2549 yyerror ("syntax error; also virtual memory exhausted");
2550 }
2551 else
2552 #endif /* YYERROR_VERBOSE */
2553 yyerror ("syntax error");
2554 }
2555
2556
2557
2558 if (yyerrstatus == 3)
2559 {
2560 /* If just tried and failed to reuse lookahead token after an
2561 error, discard it. */
2562
2563 if (yychar <= YYEOF)
2564 {
2565 /* If at end of input, pop the error token,
2566 then the rest of the stack, then return failure. */
2567 if (yychar == YYEOF)
2568 for (;;)
2569 {
2570 YYPOPSTACK;
2571 if (yyssp == yyss)
2572 YYABORT;
2573 YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
2574 yydestruct (yystos[*yyssp], yyvsp);
2575 }
2576 }
2577 else
2578 {
2579 YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc);
2580 yydestruct (yytoken, &yylval);
2581 yychar = YYEMPTY;
2582
2583 }
2584 }
2585
2586 /* Else will try to reuse lookahead token after shifting the error
2587 token. */
2588 goto yyerrlab1;
2589
2590
2591 /*---------------------------------------------------.
2592 | yyerrorlab -- error raised explicitly by YYERROR. |
2593 `---------------------------------------------------*/
2594 yyerrorlab:
2595
2596 #ifdef __GNUC__
2597 /* Pacify GCC when the user code never invokes YYERROR and the label
2598 yyerrorlab therefore never appears in user code. */
2599 if (0)
2600 goto yyerrorlab;
2601 #endif
2602
2603 yyvsp -= yylen;
2604 yyssp -= yylen;
2605 yystate = *yyssp;
2606 goto yyerrlab1;
2607
2608
2609 /*-------------------------------------------------------------.
2610 | yyerrlab1 -- common code for both syntax error and YYERROR. |
2611 `-------------------------------------------------------------*/
2612 yyerrlab1:
2613 yyerrstatus = 3; /* Each real token shifted decrements this. */
2614
2615 for (;;)
2616 {
2617 yyn = yypact[yystate];
2618 if (yyn != YYPACT_NINF)
2619 {
2620 yyn += YYTERROR;
2621 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
2622 {
2623 yyn = yytable[yyn];
2624 if (0 < yyn)
2625 break;
2626 }
2627 }
2628
2629 /* Pop the current state because it cannot handle the error token. */
2630 if (yyssp == yyss)
2631 YYABORT;
2632
2633 YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
2634 yydestruct (yystos[yystate], yyvsp);
2635 YYPOPSTACK;
2636 yystate = *yyssp;
2637 YY_STACK_PRINT (yyss, yyssp);
2638 }
2639
2640 if (yyn == YYFINAL)
2641 YYACCEPT;
2642
2643 YYDPRINTF ((stderr, "Shifting error token, "));
2644
2645 *++yyvsp = yylval;
2646
2647
2648 yystate = yyn;
2649 goto yynewstate;
2650
2651
2652 /*-------------------------------------.
2653 | yyacceptlab -- YYACCEPT comes here. |
2654 `-------------------------------------*/
2655 yyacceptlab:
2656 yyresult = 0;
2657 goto yyreturn;
2658
2659 /*-----------------------------------.
2660 | yyabortlab -- YYABORT comes here. |
2661 `-----------------------------------*/
2662 yyabortlab:
2663 yyresult = 1;
2664 goto yyreturn;
2665
2666 #ifndef yyoverflow
2667 /*----------------------------------------------.
2668 | yyoverflowlab -- parser overflow comes here. |
2669 `----------------------------------------------*/
2670 yyoverflowlab:
2671 yyerror ("parser stack overflow");
2672 yyresult = 2;
2673 /* Fall through. */
2674 #endif
2675
2676 yyreturn:
2677 #ifndef yyoverflow
2678 if (yyss != yyssa)
2679 YYSTACK_FREE (yyss);
2680 #endif
2681 return yyresult;
2682 }
2683
2684
2685 #line 1034 "c-exp.y"
2686
2687
2688 /* Take care of parsing a number (anything that starts with a digit).
2689 Set yylval and return the token type; update lexptr.
2690 LEN is the number of characters in it. */
2691
2692 /*** Needs some error checking for the float case ***/
2693
2694 static int
parse_number(p,len,parsed_float,putithere)2695 parse_number (p, len, parsed_float, putithere)
2696 char *p;
2697 int len;
2698 int parsed_float;
2699 YYSTYPE *putithere;
2700 {
2701 /* FIXME: Shouldn't these be unsigned? We don't deal with negative values
2702 here, and we do kind of silly things like cast to unsigned. */
2703 LONGEST n = 0;
2704 LONGEST prevn = 0;
2705 ULONGEST un;
2706
2707 int i = 0;
2708 int c;
2709 int base = input_radix;
2710 int unsigned_p = 0;
2711
2712 /* Number of "L" suffixes encountered. */
2713 int long_p = 0;
2714
2715 /* We have found a "L" or "U" suffix. */
2716 int found_suffix = 0;
2717
2718 ULONGEST high_bit;
2719 struct type *signed_type;
2720 struct type *unsigned_type;
2721
2722 if (parsed_float)
2723 {
2724 /* It's a float since it contains a point or an exponent. */
2725 char c;
2726 int num = 0; /* number of tokens scanned by scanf */
2727 char saved_char = p[len];
2728
2729 p[len] = 0; /* null-terminate the token */
2730 if (sizeof (putithere->typed_val_float.dval) <= sizeof (float))
2731 num = sscanf (p, "%g%c", (float *) &putithere->typed_val_float.dval,&c);
2732 else if (sizeof (putithere->typed_val_float.dval) <= sizeof (double))
2733 num = sscanf (p, "%lg%c", (double *) &putithere->typed_val_float.dval,&c);
2734 else
2735 {
2736 #ifdef SCANF_HAS_LONG_DOUBLE
2737 num = sscanf (p, "%Lg%c", &putithere->typed_val_float.dval,&c);
2738 #else
2739 /* Scan it into a double, then assign it to the long double.
2740 This at least wins with values representable in the range
2741 of doubles. */
2742 double temp;
2743 num = sscanf (p, "%lg%c", &temp,&c);
2744 putithere->typed_val_float.dval = temp;
2745 #endif
2746 }
2747 p[len] = saved_char; /* restore the input stream */
2748 if (num != 1) /* check scanf found ONLY a float ... */
2749 return ERROR;
2750 /* See if it has `f' or `l' suffix (float or long double). */
2751
2752 c = tolower (p[len - 1]);
2753
2754 if (c == 'f')
2755 putithere->typed_val_float.type = builtin_type (current_gdbarch)->builtin_float;
2756 else if (c == 'l')
2757 putithere->typed_val_float.type = builtin_type (current_gdbarch)->builtin_long_double;
2758 else if (isdigit (c) || c == '.')
2759 putithere->typed_val_float.type = builtin_type (current_gdbarch)->builtin_double;
2760 else
2761 return ERROR;
2762
2763 return FLOAT;
2764 }
2765
2766 /* Handle base-switching prefixes 0x, 0t, 0d, 0 */
2767 if (p[0] == '0')
2768 switch (p[1])
2769 {
2770 case 'x':
2771 case 'X':
2772 if (len >= 3)
2773 {
2774 p += 2;
2775 base = 16;
2776 len -= 2;
2777 }
2778 break;
2779
2780 case 't':
2781 case 'T':
2782 case 'd':
2783 case 'D':
2784 if (len >= 3)
2785 {
2786 p += 2;
2787 base = 10;
2788 len -= 2;
2789 }
2790 break;
2791
2792 default:
2793 base = 8;
2794 break;
2795 }
2796
2797 while (len-- > 0)
2798 {
2799 c = *p++;
2800 if (c >= 'A' && c <= 'Z')
2801 c += 'a' - 'A';
2802 if (c != 'l' && c != 'u')
2803 n *= base;
2804 if (c >= '0' && c <= '9')
2805 {
2806 if (found_suffix)
2807 return ERROR;
2808 n += i = c - '0';
2809 }
2810 else
2811 {
2812 if (base > 10 && c >= 'a' && c <= 'f')
2813 {
2814 if (found_suffix)
2815 return ERROR;
2816 n += i = c - 'a' + 10;
2817 }
2818 else if (c == 'l')
2819 {
2820 ++long_p;
2821 found_suffix = 1;
2822 }
2823 else if (c == 'u')
2824 {
2825 unsigned_p = 1;
2826 found_suffix = 1;
2827 }
2828 else
2829 return ERROR; /* Char not a digit */
2830 }
2831 if (i >= base)
2832 return ERROR; /* Invalid digit in this base */
2833
2834 /* Portably test for overflow (only works for nonzero values, so make
2835 a second check for zero). FIXME: Can't we just make n and prevn
2836 unsigned and avoid this? */
2837 if (c != 'l' && c != 'u' && (prevn >= n) && n != 0)
2838 unsigned_p = 1; /* Try something unsigned */
2839
2840 /* Portably test for unsigned overflow.
2841 FIXME: This check is wrong; for example it doesn't find overflow
2842 on 0x123456789 when LONGEST is 32 bits. */
2843 if (c != 'l' && c != 'u' && n != 0)
2844 {
2845 if ((unsigned_p && (ULONGEST) prevn >= (ULONGEST) n))
2846 error ("Numeric constant too large.");
2847 }
2848 prevn = n;
2849 }
2850
2851 /* An integer constant is an int, a long, or a long long. An L
2852 suffix forces it to be long; an LL suffix forces it to be long
2853 long. If not forced to a larger size, it gets the first type of
2854 the above that it fits in. To figure out whether it fits, we
2855 shift it right and see whether anything remains. Note that we
2856 can't shift sizeof (LONGEST) * HOST_CHAR_BIT bits or more in one
2857 operation, because many compilers will warn about such a shift
2858 (which always produces a zero result). Sometimes TARGET_INT_BIT
2859 or TARGET_LONG_BIT will be that big, sometimes not. To deal with
2860 the case where it is we just always shift the value more than
2861 once, with fewer bits each time. */
2862
2863 un = (ULONGEST)n >> 2;
2864 if (long_p == 0
2865 && (un >> (TARGET_INT_BIT - 2)) == 0)
2866 {
2867 high_bit = ((ULONGEST)1) << (TARGET_INT_BIT-1);
2868
2869 /* A large decimal (not hex or octal) constant (between INT_MAX
2870 and UINT_MAX) is a long or unsigned long, according to ANSI,
2871 never an unsigned int, but this code treats it as unsigned
2872 int. This probably should be fixed. GCC gives a warning on
2873 such constants. */
2874
2875 unsigned_type = builtin_type (current_gdbarch)->builtin_unsigned_int;
2876 signed_type = builtin_type (current_gdbarch)->builtin_int;
2877 }
2878 else if (long_p <= 1
2879 && (un >> (TARGET_LONG_BIT - 2)) == 0)
2880 {
2881 high_bit = ((ULONGEST)1) << (TARGET_LONG_BIT-1);
2882 unsigned_type = builtin_type (current_gdbarch)->builtin_unsigned_long;
2883 signed_type = builtin_type (current_gdbarch)->builtin_long;
2884 }
2885 else
2886 {
2887 int shift;
2888 if (sizeof (ULONGEST) * HOST_CHAR_BIT < TARGET_LONG_LONG_BIT)
2889 /* A long long does not fit in a LONGEST. */
2890 shift = (sizeof (ULONGEST) * HOST_CHAR_BIT - 1);
2891 else
2892 shift = (TARGET_LONG_LONG_BIT - 1);
2893 high_bit = (ULONGEST) 1 << shift;
2894 unsigned_type = builtin_type (current_gdbarch)->builtin_unsigned_long_long;
2895 signed_type = builtin_type (current_gdbarch)->builtin_long_long;
2896 }
2897
2898 putithere->typed_val_int.val = n;
2899
2900 /* If the high bit of the worked out type is set then this number
2901 has to be unsigned. */
2902
2903 if (unsigned_p || (n & high_bit))
2904 {
2905 putithere->typed_val_int.type = unsigned_type;
2906 }
2907 else
2908 {
2909 putithere->typed_val_int.type = signed_type;
2910 }
2911
2912 return INT;
2913 }
2914
2915 struct token
2916 {
2917 char *operator;
2918 int token;
2919 enum exp_opcode opcode;
2920 };
2921
2922 static const struct token tokentab3[] =
2923 {
2924 {">>=", ASSIGN_MODIFY, BINOP_RSH},
2925 {"<<=", ASSIGN_MODIFY, BINOP_LSH}
2926 };
2927
2928 static const struct token tokentab2[] =
2929 {
2930 {"+=", ASSIGN_MODIFY, BINOP_ADD},
2931 {"-=", ASSIGN_MODIFY, BINOP_SUB},
2932 {"*=", ASSIGN_MODIFY, BINOP_MUL},
2933 {"/=", ASSIGN_MODIFY, BINOP_DIV},
2934 {"%=", ASSIGN_MODIFY, BINOP_REM},
2935 {"|=", ASSIGN_MODIFY, BINOP_BITWISE_IOR},
2936 {"&=", ASSIGN_MODIFY, BINOP_BITWISE_AND},
2937 {"^=", ASSIGN_MODIFY, BINOP_BITWISE_XOR},
2938 {"++", INCREMENT, BINOP_END},
2939 {"--", DECREMENT, BINOP_END},
2940 {"->", ARROW, BINOP_END},
2941 {"&&", ANDAND, BINOP_END},
2942 {"||", OROR, BINOP_END},
2943 {"::", COLONCOLON, BINOP_END},
2944 {"<<", LSH, BINOP_END},
2945 {">>", RSH, BINOP_END},
2946 {"==", EQUAL, BINOP_END},
2947 {"!=", NOTEQUAL, BINOP_END},
2948 {"<=", LEQ, BINOP_END},
2949 {">=", GEQ, BINOP_END}
2950 };
2951
2952 /* Read one token, getting characters through lexptr. */
2953
2954 static int
yylex()2955 yylex ()
2956 {
2957 int c;
2958 int namelen;
2959 unsigned int i;
2960 char *tokstart;
2961 char *tokptr;
2962 int tempbufindex;
2963 static char *tempbuf;
2964 static int tempbufsize;
2965 struct symbol * sym_class = NULL;
2966 char * token_string = NULL;
2967 int class_prefix = 0;
2968 int unquoted_expr;
2969
2970 retry:
2971
2972 /* Check if this is a macro invocation that we need to expand. */
2973 if (! scanning_macro_expansion ())
2974 {
2975 char *expanded = macro_expand_next (&lexptr,
2976 expression_macro_lookup_func,
2977 expression_macro_lookup_baton);
2978
2979 if (expanded)
2980 scan_macro_expansion (expanded);
2981 }
2982
2983 prev_lexptr = lexptr;
2984 unquoted_expr = 1;
2985
2986 tokstart = lexptr;
2987 /* See if it is a special token of length 3. */
2988 for (i = 0; i < sizeof tokentab3 / sizeof tokentab3[0]; i++)
2989 if (strncmp (tokstart, tokentab3[i].operator, 3) == 0)
2990 {
2991 lexptr += 3;
2992 yylval.opcode = tokentab3[i].opcode;
2993 return tokentab3[i].token;
2994 }
2995
2996 /* See if it is a special token of length 2. */
2997 for (i = 0; i < sizeof tokentab2 / sizeof tokentab2[0]; i++)
2998 if (strncmp (tokstart, tokentab2[i].operator, 2) == 0)
2999 {
3000 lexptr += 2;
3001 yylval.opcode = tokentab2[i].opcode;
3002 return tokentab2[i].token;
3003 }
3004
3005 switch (c = *tokstart)
3006 {
3007 case 0:
3008 /* If we were just scanning the result of a macro expansion,
3009 then we need to resume scanning the original text.
3010 Otherwise, we were already scanning the original text, and
3011 we're really done. */
3012 if (scanning_macro_expansion ())
3013 {
3014 finished_macro_expansion ();
3015 goto retry;
3016 }
3017 else
3018 return 0;
3019
3020 case ' ':
3021 case '\t':
3022 case '\n':
3023 lexptr++;
3024 goto retry;
3025
3026 case '\'':
3027 /* We either have a character constant ('0' or '\177' for example)
3028 or we have a quoted symbol reference ('foo(int,int)' in C++
3029 for example). */
3030 lexptr++;
3031 c = *lexptr++;
3032 if (c == '\\')
3033 c = parse_escape (&lexptr);
3034 else if (c == '\'')
3035 error ("Empty character constant.");
3036 else if (! host_char_to_target (c, &c))
3037 {
3038 int toklen = lexptr - tokstart + 1;
3039 char *tok = alloca (toklen + 1);
3040 memcpy (tok, tokstart, toklen);
3041 tok[toklen] = '\0';
3042 error ("There is no character corresponding to %s in the target "
3043 "character set `%s'.", tok, target_charset ());
3044 }
3045
3046 yylval.typed_val_int.val = c;
3047 yylval.typed_val_int.type = builtin_type (current_gdbarch)->builtin_char;
3048
3049 c = *lexptr++;
3050 if (c != '\'')
3051 {
3052 namelen = skip_quoted (tokstart) - tokstart;
3053 if (namelen > 2)
3054 {
3055 lexptr = tokstart + namelen;
3056 unquoted_expr = 0;
3057 if (lexptr[-1] != '\'')
3058 error ("Unmatched single quote.");
3059 namelen -= 2;
3060 tokstart++;
3061 goto tryname;
3062 }
3063 error ("Invalid character constant.");
3064 }
3065 return INT;
3066
3067 case '(':
3068 paren_depth++;
3069 lexptr++;
3070 return c;
3071
3072 case ')':
3073 if (paren_depth == 0)
3074 return 0;
3075 paren_depth--;
3076 lexptr++;
3077 return c;
3078
3079 case ',':
3080 if (comma_terminates
3081 && paren_depth == 0
3082 && ! scanning_macro_expansion ())
3083 return 0;
3084 lexptr++;
3085 return c;
3086
3087 case '.':
3088 /* Might be a floating point number. */
3089 if (lexptr[1] < '0' || lexptr[1] > '9')
3090 goto symbol; /* Nope, must be a symbol. */
3091 /* FALL THRU into number case. */
3092
3093 case '0':
3094 case '1':
3095 case '2':
3096 case '3':
3097 case '4':
3098 case '5':
3099 case '6':
3100 case '7':
3101 case '8':
3102 case '9':
3103 {
3104 /* It's a number. */
3105 int got_dot = 0, got_e = 0, toktype;
3106 char *p = tokstart;
3107 int hex = input_radix > 10;
3108
3109 if (c == '0' && (p[1] == 'x' || p[1] == 'X'))
3110 {
3111 p += 2;
3112 hex = 1;
3113 }
3114 else if (c == '0' && (p[1]=='t' || p[1]=='T' || p[1]=='d' || p[1]=='D'))
3115 {
3116 p += 2;
3117 hex = 0;
3118 }
3119
3120 for (;; ++p)
3121 {
3122 /* This test includes !hex because 'e' is a valid hex digit
3123 and thus does not indicate a floating point number when
3124 the radix is hex. */
3125 if (!hex && !got_e && (*p == 'e' || *p == 'E'))
3126 got_dot = got_e = 1;
3127 /* This test does not include !hex, because a '.' always indicates
3128 a decimal floating point number regardless of the radix. */
3129 else if (!got_dot && *p == '.')
3130 got_dot = 1;
3131 else if (got_e && (p[-1] == 'e' || p[-1] == 'E')
3132 && (*p == '-' || *p == '+'))
3133 /* This is the sign of the exponent, not the end of the
3134 number. */
3135 continue;
3136 /* We will take any letters or digits. parse_number will
3137 complain if past the radix, or if L or U are not final. */
3138 else if ((*p < '0' || *p > '9')
3139 && ((*p < 'a' || *p > 'z')
3140 && (*p < 'A' || *p > 'Z')))
3141 break;
3142 }
3143 toktype = parse_number (tokstart, p - tokstart, got_dot|got_e, &yylval);
3144 if (toktype == ERROR)
3145 {
3146 char *err_copy = (char *) alloca (p - tokstart + 1);
3147
3148 memcpy (err_copy, tokstart, p - tokstart);
3149 err_copy[p - tokstart] = 0;
3150 error ("Invalid number \"%s\".", err_copy);
3151 }
3152 lexptr = p;
3153 return toktype;
3154 }
3155
3156 case '+':
3157 case '-':
3158 case '*':
3159 case '/':
3160 case '%':
3161 case '|':
3162 case '&':
3163 case '^':
3164 case '~':
3165 case '!':
3166 case '@':
3167 case '<':
3168 case '>':
3169 case '[':
3170 case ']':
3171 case '?':
3172 case ':':
3173 case '=':
3174 case '{':
3175 case '}':
3176 symbol:
3177 lexptr++;
3178 return c;
3179
3180 case '"':
3181
3182 /* Build the gdb internal form of the input string in tempbuf,
3183 translating any standard C escape forms seen. Note that the
3184 buffer is null byte terminated *only* for the convenience of
3185 debugging gdb itself and printing the buffer contents when
3186 the buffer contains no embedded nulls. Gdb does not depend
3187 upon the buffer being null byte terminated, it uses the length
3188 string instead. This allows gdb to handle C strings (as well
3189 as strings in other languages) with embedded null bytes */
3190
3191 tokptr = ++tokstart;
3192 tempbufindex = 0;
3193
3194 do {
3195 char *char_start_pos = tokptr;
3196
3197 /* Grow the static temp buffer if necessary, including allocating
3198 the first one on demand. */
3199 if (tempbufindex + 1 >= tempbufsize)
3200 {
3201 tempbuf = (char *) xrealloc (tempbuf, tempbufsize += 64);
3202 }
3203 switch (*tokptr)
3204 {
3205 case '\0':
3206 case '"':
3207 /* Do nothing, loop will terminate. */
3208 break;
3209 case '\\':
3210 tokptr++;
3211 c = parse_escape (&tokptr);
3212 if (c == -1)
3213 {
3214 continue;
3215 }
3216 tempbuf[tempbufindex++] = c;
3217 break;
3218 default:
3219 c = *tokptr++;
3220 if (! host_char_to_target (c, &c))
3221 {
3222 int len = tokptr - char_start_pos;
3223 char *copy = alloca (len + 1);
3224 memcpy (copy, char_start_pos, len);
3225 copy[len] = '\0';
3226
3227 error ("There is no character corresponding to `%s' "
3228 "in the target character set `%s'.",
3229 copy, target_charset ());
3230 }
3231 tempbuf[tempbufindex++] = c;
3232 break;
3233 }
3234 } while ((*tokptr != '"') && (*tokptr != '\0'));
3235 if (*tokptr++ != '"')
3236 {
3237 error ("Unterminated string in expression.");
3238 }
3239 tempbuf[tempbufindex] = '\0'; /* See note above */
3240 yylval.sval.ptr = tempbuf;
3241 yylval.sval.length = tempbufindex;
3242 lexptr = tokptr;
3243 return (STRING);
3244 }
3245
3246 if (!(c == '_' || c == '$'
3247 || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')))
3248 /* We must have come across a bad character (e.g. ';'). */
3249 error ("Invalid character '%c' in expression.", c);
3250
3251 /* It's a name. See how long it is. */
3252 namelen = 0;
3253 for (c = tokstart[namelen];
3254 (c == '_' || c == '$' || (c >= '0' && c <= '9')
3255 || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '<');)
3256 {
3257 /* Template parameter lists are part of the name.
3258 FIXME: This mishandles `print $a<4&&$a>3'. */
3259
3260 if (c == '<')
3261 {
3262 /* Scan ahead to get rest of the template specification. Note
3263 that we look ahead only when the '<' adjoins non-whitespace
3264 characters; for comparison expressions, e.g. "a < b > c",
3265 there must be spaces before the '<', etc. */
3266
3267 char * p = find_template_name_end (tokstart + namelen);
3268 if (p)
3269 namelen = p - tokstart;
3270 break;
3271 }
3272 c = tokstart[++namelen];
3273 }
3274
3275 /* The token "if" terminates the expression and is NOT removed from
3276 the input stream. It doesn't count if it appears in the
3277 expansion of a macro. */
3278 if (namelen == 2
3279 && tokstart[0] == 'i'
3280 && tokstart[1] == 'f'
3281 && ! scanning_macro_expansion ())
3282 {
3283 return 0;
3284 }
3285
3286 lexptr += namelen;
3287
3288 tryname:
3289
3290 /* Catch specific keywords. Should be done with a data structure. */
3291 switch (namelen)
3292 {
3293 case 8:
3294 if (strncmp (tokstart, "unsigned", 8) == 0)
3295 return UNSIGNED;
3296 if (current_language->la_language == language_cplus
3297 && strncmp (tokstart, "template", 8) == 0)
3298 return TEMPLATE;
3299 if (strncmp (tokstart, "volatile", 8) == 0)
3300 return VOLATILE_KEYWORD;
3301 break;
3302 case 6:
3303 if (strncmp (tokstart, "struct", 6) == 0)
3304 return STRUCT;
3305 if (strncmp (tokstart, "signed", 6) == 0)
3306 return SIGNED_KEYWORD;
3307 if (strncmp (tokstart, "sizeof", 6) == 0)
3308 return SIZEOF;
3309 if (strncmp (tokstart, "double", 6) == 0)
3310 return DOUBLE_KEYWORD;
3311 break;
3312 case 5:
3313 if (current_language->la_language == language_cplus)
3314 {
3315 if (strncmp (tokstart, "false", 5) == 0)
3316 return FALSEKEYWORD;
3317 if (strncmp (tokstart, "class", 5) == 0)
3318 return CLASS;
3319 }
3320 if (strncmp (tokstart, "union", 5) == 0)
3321 return UNION;
3322 if (strncmp (tokstart, "short", 5) == 0)
3323 return SHORT;
3324 if (strncmp (tokstart, "const", 5) == 0)
3325 return CONST_KEYWORD;
3326 break;
3327 case 4:
3328 if (strncmp (tokstart, "enum", 4) == 0)
3329 return ENUM;
3330 if (strncmp (tokstart, "long", 4) == 0)
3331 return LONG;
3332 if (current_language->la_language == language_cplus)
3333 {
3334 if (strncmp (tokstart, "true", 4) == 0)
3335 return TRUEKEYWORD;
3336 }
3337 break;
3338 case 3:
3339 if (strncmp (tokstart, "int", 3) == 0)
3340 return INT_KEYWORD;
3341 break;
3342 default:
3343 break;
3344 }
3345
3346 yylval.sval.ptr = tokstart;
3347 yylval.sval.length = namelen;
3348
3349 if (*tokstart == '$')
3350 {
3351 write_dollar_variable (yylval.sval);
3352 return VARIABLE;
3353 }
3354
3355 /* Look ahead and see if we can consume more of the input
3356 string to get a reasonable class/namespace spec or a
3357 fully-qualified name. This is a kludge to get around the
3358 HP aCC compiler's generation of symbol names with embedded
3359 colons for namespace and nested classes. */
3360
3361 /* NOTE: carlton/2003-09-24: I don't entirely understand the
3362 HP-specific code, either here or in linespec. Having said that,
3363 I suspect that we're actually moving towards their model: we want
3364 symbols whose names are fully qualified, which matches the
3365 description above. */
3366 if (unquoted_expr)
3367 {
3368 /* Only do it if not inside single quotes */
3369 sym_class = parse_nested_classes_for_hpacc (yylval.sval.ptr, yylval.sval.length,
3370 &token_string, &class_prefix, &lexptr);
3371 if (sym_class)
3372 {
3373 /* Replace the current token with the bigger one we found */
3374 yylval.sval.ptr = token_string;
3375 yylval.sval.length = strlen (token_string);
3376 }
3377 }
3378
3379 /* Use token-type BLOCKNAME for symbols that happen to be defined as
3380 functions or symtabs. If this is not so, then ...
3381 Use token-type TYPENAME for symbols that happen to be defined
3382 currently as names of types; NAME for other symbols.
3383 The caller is not constrained to care about the distinction. */
3384 {
3385 char *tmp = copy_name (yylval.sval);
3386 struct symbol *sym;
3387 int is_a_field_of_this = 0;
3388 int hextype;
3389
3390 sym = lookup_symbol (tmp, expression_context_block,
3391 VAR_DOMAIN,
3392 current_language->la_language == language_cplus
3393 ? &is_a_field_of_this : (int *) NULL,
3394 (struct symtab **) NULL);
3395 /* Call lookup_symtab, not lookup_partial_symtab, in case there are
3396 no psymtabs (coff, xcoff, or some future change to blow away the
3397 psymtabs once once symbols are read). */
3398 if (sym && SYMBOL_CLASS (sym) == LOC_BLOCK)
3399 {
3400 yylval.ssym.sym = sym;
3401 yylval.ssym.is_a_field_of_this = is_a_field_of_this;
3402 return BLOCKNAME;
3403 }
3404 else if (!sym)
3405 { /* See if it's a file name. */
3406 struct symtab *symtab;
3407
3408 symtab = lookup_symtab (tmp);
3409
3410 if (symtab)
3411 {
3412 yylval.bval = BLOCKVECTOR_BLOCK (BLOCKVECTOR (symtab), STATIC_BLOCK);
3413 return FILENAME;
3414 }
3415 }
3416
3417 if (sym && SYMBOL_CLASS (sym) == LOC_TYPEDEF)
3418 {
3419 /* NOTE: carlton/2003-09-25: There used to be code here to
3420 handle nested types. It didn't work very well. See the
3421 comment before qualified_type for more info. */
3422 yylval.tsym.type = SYMBOL_TYPE (sym);
3423 return TYPENAME;
3424 }
3425 yylval.tsym.type
3426 = language_lookup_primitive_type_by_name (current_language,
3427 current_gdbarch, tmp);
3428 if (yylval.tsym.type != NULL)
3429 return TYPENAME;
3430
3431 /* Input names that aren't symbols but ARE valid hex numbers,
3432 when the input radix permits them, can be names or numbers
3433 depending on the parse. Note we support radixes > 16 here. */
3434 if (!sym &&
3435 ((tokstart[0] >= 'a' && tokstart[0] < 'a' + input_radix - 10) ||
3436 (tokstart[0] >= 'A' && tokstart[0] < 'A' + input_radix - 10)))
3437 {
3438 YYSTYPE newlval; /* Its value is ignored. */
3439 hextype = parse_number (tokstart, namelen, 0, &newlval);
3440 if (hextype == INT)
3441 {
3442 yylval.ssym.sym = sym;
3443 yylval.ssym.is_a_field_of_this = is_a_field_of_this;
3444 return NAME_OR_INT;
3445 }
3446 }
3447
3448 /* Any other kind of symbol */
3449 yylval.ssym.sym = sym;
3450 yylval.ssym.is_a_field_of_this = is_a_field_of_this;
3451 return NAME;
3452 }
3453 }
3454
3455 void
yyerror(msg)3456 yyerror (msg)
3457 char *msg;
3458 {
3459 if (prev_lexptr)
3460 lexptr = prev_lexptr;
3461
3462 error ("A %s in expression, near `%s'.", (msg ? msg : "error"), lexptr);
3463 }
3464
3465
3466