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