No empty .Rs/.Re
[netbsd-mini2440.git] / gnu / dist / gdb6 / gdb / cp-name-parser.c
blob8f799d9a3d5b50e7c88e0282dd395e0526460e68
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 NAME = 260,
59 STRUCT = 261,
60 CLASS = 262,
61 UNION = 263,
62 ENUM = 264,
63 SIZEOF = 265,
64 UNSIGNED = 266,
65 COLONCOLON = 267,
66 TEMPLATE = 268,
67 ERROR = 269,
68 NEW = 270,
69 DELETE = 271,
70 OPERATOR = 272,
71 STATIC_CAST = 273,
72 REINTERPRET_CAST = 274,
73 DYNAMIC_CAST = 275,
74 SIGNED_KEYWORD = 276,
75 LONG = 277,
76 SHORT = 278,
77 INT_KEYWORD = 279,
78 CONST_KEYWORD = 280,
79 VOLATILE_KEYWORD = 281,
80 DOUBLE_KEYWORD = 282,
81 BOOL = 283,
82 ELLIPSIS = 284,
83 RESTRICT = 285,
84 VOID = 286,
85 FLOAT_KEYWORD = 287,
86 CHAR = 288,
87 WCHAR_T = 289,
88 ASSIGN_MODIFY = 290,
89 TRUEKEYWORD = 291,
90 FALSEKEYWORD = 292,
91 DEMANGLER_SPECIAL = 293,
92 CONSTRUCTION_VTABLE = 294,
93 CONSTRUCTION_IN = 295,
94 GLOBAL = 296,
95 OROR = 297,
96 ANDAND = 298,
97 NOTEQUAL = 299,
98 EQUAL = 300,
99 GEQ = 301,
100 LEQ = 302,
101 RSH = 303,
102 LSH = 304,
103 DECREMENT = 305,
104 INCREMENT = 306,
105 UNARY = 307,
106 ARROW = 308
108 #endif
109 #define INT 258
110 #define FLOAT 259
111 #define NAME 260
112 #define STRUCT 261
113 #define CLASS 262
114 #define UNION 263
115 #define ENUM 264
116 #define SIZEOF 265
117 #define UNSIGNED 266
118 #define COLONCOLON 267
119 #define TEMPLATE 268
120 #define ERROR 269
121 #define NEW 270
122 #define DELETE 271
123 #define OPERATOR 272
124 #define STATIC_CAST 273
125 #define REINTERPRET_CAST 274
126 #define DYNAMIC_CAST 275
127 #define SIGNED_KEYWORD 276
128 #define LONG 277
129 #define SHORT 278
130 #define INT_KEYWORD 279
131 #define CONST_KEYWORD 280
132 #define VOLATILE_KEYWORD 281
133 #define DOUBLE_KEYWORD 282
134 #define BOOL 283
135 #define ELLIPSIS 284
136 #define RESTRICT 285
137 #define VOID 286
138 #define FLOAT_KEYWORD 287
139 #define CHAR 288
140 #define WCHAR_T 289
141 #define ASSIGN_MODIFY 290
142 #define TRUEKEYWORD 291
143 #define FALSEKEYWORD 292
144 #define DEMANGLER_SPECIAL 293
145 #define CONSTRUCTION_VTABLE 294
146 #define CONSTRUCTION_IN 295
147 #define GLOBAL 296
148 #define OROR 297
149 #define ANDAND 298
150 #define NOTEQUAL 299
151 #define EQUAL 300
152 #define GEQ 301
153 #define LEQ 302
154 #define RSH 303
155 #define LSH 304
156 #define DECREMENT 305
157 #define INCREMENT 306
158 #define UNARY 307
159 #define ARROW 308
164 /* Copy the first part of user declarations. */
165 #line 33 "cp-name-parser.y"
168 #include <stdio.h>
169 #include <stdlib.h>
170 #include <unistd.h>
171 #include <string.h>
173 #include "safe-ctype.h"
174 #include "libiberty.h"
175 #include "demangle.h"
177 /* Bison does not make it easy to create a parser without global
178 state, unfortunately. Here are all the global variables used
179 in this parser. */
181 /* LEXPTR is the current pointer into our lex buffer. PREV_LEXPTR
182 is the start of the last token lexed, only used for diagnostics.
183 ERROR_LEXPTR is the first place an error occurred. GLOBAL_ERRMSG
184 is the first error message encountered. */
186 static const char *lexptr, *prev_lexptr, *error_lexptr, *global_errmsg;
188 /* The components built by the parser are allocated ahead of time,
189 and cached in this structure. */
191 struct demangle_info {
192 int used;
193 struct demangle_component comps[1];
196 static struct demangle_info *demangle_info;
197 #define d_grab() (&demangle_info->comps[demangle_info->used++])
199 /* The parse tree created by the parser is stored here after a successful
200 parse. */
202 static struct demangle_component *global_result;
204 /* Prototypes for helper functions used when constructing the parse
205 tree. */
207 static struct demangle_component *d_qualify (struct demangle_component *, int,
208 int);
210 static struct demangle_component *d_int_type (int);
212 static struct demangle_component *d_unary (const char *,
213 struct demangle_component *);
214 static struct demangle_component *d_binary (const char *,
215 struct demangle_component *,
216 struct demangle_component *);
218 /* Flags passed to d_qualify. */
220 #define QUAL_CONST 1
221 #define QUAL_RESTRICT 2
222 #define QUAL_VOLATILE 4
224 /* Flags passed to d_int_type. */
226 #define INT_CHAR (1 << 0)
227 #define INT_SHORT (1 << 1)
228 #define INT_LONG (1 << 2)
229 #define INT_LLONG (1 << 3)
231 #define INT_SIGNED (1 << 4)
232 #define INT_UNSIGNED (1 << 5)
234 /* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc),
235 as well as gratuitiously global symbol names, so we can have multiple
236 yacc generated parsers in gdb. Note that these are only the variables
237 produced by yacc. If other parser generators (bison, byacc, etc) produce
238 additional global names that conflict at link time, then those parser
239 generators need to be fixed instead of adding those names to this list. */
241 #define yymaxdepth cpname_maxdepth
242 #define yyparse cpname_parse
243 #define yylex cpname_lex
244 #define yyerror cpname_error
245 #define yylval cpname_lval
246 #define yychar cpname_char
247 #define yydebug cpname_debug
248 #define yypact cpname_pact
249 #define yyr1 cpname_r1
250 #define yyr2 cpname_r2
251 #define yydef cpname_def
252 #define yychk cpname_chk
253 #define yypgo cpname_pgo
254 #define yyact cpname_act
255 #define yyexca cpname_exca
256 #define yyerrflag cpname_errflag
257 #define yynerrs cpname_nerrs
258 #define yyps cpname_ps
259 #define yypv cpname_pv
260 #define yys cpname_s
261 #define yy_yys cpname_yys
262 #define yystate cpname_state
263 #define yytmp cpname_tmp
264 #define yyv cpname_v
265 #define yy_yyv cpname_yyv
266 #define yyval cpname_val
267 #define yylloc cpname_lloc
268 #define yyreds cpname_reds /* With YYDEBUG defined */
269 #define yytoks cpname_toks /* With YYDEBUG defined */
270 #define yyname cpname_name /* With YYDEBUG defined */
271 #define yyrule cpname_rule /* With YYDEBUG defined */
272 #define yylhs cpname_yylhs
273 #define yylen cpname_yylen
274 #define yydefred cpname_yydefred
275 #define yydgoto cpname_yydgoto
276 #define yysindex cpname_yysindex
277 #define yyrindex cpname_yyrindex
278 #define yygindex cpname_yygindex
279 #define yytable cpname_yytable
280 #define yycheck cpname_yycheck
282 int yyparse (void);
283 static int yylex (void);
284 static void yyerror (char *);
286 /* Enable yydebug for the stand-alone parser. */
287 #ifdef TEST_CPNAMES
288 # define YYDEBUG 1
289 #endif
291 /* Helper functions. These wrap the demangler tree interface, handle
292 allocation from our global store, and return the allocated component. */
294 static struct demangle_component *
295 fill_comp (enum demangle_component_type d_type, struct demangle_component *lhs,
296 struct demangle_component *rhs)
298 struct demangle_component *ret = d_grab ();
299 cplus_demangle_fill_component (ret, d_type, lhs, rhs);
300 return ret;
303 static struct demangle_component *
304 make_empty (enum demangle_component_type d_type)
306 struct demangle_component *ret = d_grab ();
307 ret->type = d_type;
308 return ret;
311 static struct demangle_component *
312 make_operator (const char *name, int args)
314 struct demangle_component *ret = d_grab ();
315 cplus_demangle_fill_operator (ret, name, args);
316 return ret;
319 static struct demangle_component *
320 make_dtor (enum gnu_v3_dtor_kinds kind, struct demangle_component *name)
322 struct demangle_component *ret = d_grab ();
323 cplus_demangle_fill_dtor (ret, kind, name);
324 return ret;
327 static struct demangle_component *
328 make_builtin_type (const char *name)
330 struct demangle_component *ret = d_grab ();
331 cplus_demangle_fill_builtin_type (ret, name);
332 return ret;
335 static struct demangle_component *
336 make_name (const char *name, int len)
338 struct demangle_component *ret = d_grab ();
339 cplus_demangle_fill_name (ret, name, len);
340 return ret;
343 #define d_left(dc) (dc)->u.s_binary.left
344 #define d_right(dc) (dc)->u.s_binary.right
348 /* Enabling traces. */
349 #ifndef YYDEBUG
350 # define YYDEBUG 0
351 #endif
353 /* Enabling verbose error messages. */
354 #ifdef YYERROR_VERBOSE
355 # undef YYERROR_VERBOSE
356 # define YYERROR_VERBOSE 1
357 #else
358 # define YYERROR_VERBOSE 0
359 #endif
361 #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
362 #line 216 "cp-name-parser.y"
363 typedef union YYSTYPE {
364 struct demangle_component *comp;
365 struct nested {
366 struct demangle_component *comp;
367 struct demangle_component **last;
368 } nested;
369 struct {
370 struct demangle_component *comp, *last;
371 } nested1;
372 struct {
373 struct demangle_component *comp, **last;
374 struct nested fn;
375 struct demangle_component *start;
376 int fold_flag;
377 } abstract;
378 int lval;
379 struct {
380 int val;
381 struct demangle_component *type;
382 } typed_val_int;
383 const char *opname;
384 } YYSTYPE;
385 /* Line 191 of yacc.c. */
386 #line 387 "cp-name-parser.c.tmp"
387 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
388 # define YYSTYPE_IS_DECLARED 1
389 # define YYSTYPE_IS_TRIVIAL 1
390 #endif
394 /* Copy the second part of user declarations. */
395 #line 292 "cp-name-parser.y"
397 enum {
398 GLOBAL_CONSTRUCTORS = DEMANGLE_COMPONENT_LITERAL + 20,
399 GLOBAL_DESTRUCTORS = DEMANGLE_COMPONENT_LITERAL + 21
403 /* Line 214 of yacc.c. */
404 #line 405 "cp-name-parser.c.tmp"
406 #if ! defined (yyoverflow) || YYERROR_VERBOSE
408 # ifndef YYFREE
409 # define YYFREE free
410 # endif
411 # ifndef YYMALLOC
412 # define YYMALLOC xmalloc
413 # endif
415 /* The parser invokes alloca or xmalloc; define the necessary symbols. */
417 # ifdef YYSTACK_USE_ALLOCA
418 # if YYSTACK_USE_ALLOCA
419 # define YYSTACK_ALLOC alloca
420 # endif
421 # else
422 # if defined (alloca) || defined (_ALLOCA_H)
423 # define YYSTACK_ALLOC alloca
424 # else
425 # ifdef __GNUC__
426 # define YYSTACK_ALLOC __builtin_alloca
427 # endif
428 # endif
429 # endif
431 # ifdef YYSTACK_ALLOC
432 /* Pacify GCC's `empty if-body' warning. */
433 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
434 # else
435 # if defined (__STDC__) || defined (__cplusplus)
436 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
437 # define YYSIZE_T size_t
438 # endif
439 # define YYSTACK_ALLOC YYMALLOC
440 # define YYSTACK_FREE YYFREE
441 # endif
442 #endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
445 #if (! defined (yyoverflow) \
446 && (! defined (__cplusplus) \
447 || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL)))
449 /* A type that is properly aligned for any stack member. */
450 union yyalloc
452 short yyss;
453 YYSTYPE yyvs;
456 /* The size of the maximum gap between one aligned stack and the next. */
457 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
459 /* The size of an array large to enough to hold all stacks, each with
460 N elements. */
461 # define YYSTACK_BYTES(N) \
462 ((N) * (sizeof (short) + sizeof (YYSTYPE)) \
463 + YYSTACK_GAP_MAXIMUM)
465 /* Copy COUNT objects from FROM to TO. The source and destination do
466 not overlap. */
467 # ifndef YYCOPY
468 # if defined (__GNUC__) && 1 < __GNUC__
469 # define YYCOPY(To, From, Count) \
470 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
471 # else
472 # define YYCOPY(To, From, Count) \
473 do \
475 register YYSIZE_T yyi; \
476 for (yyi = 0; yyi < (Count); yyi++) \
477 (To)[yyi] = (From)[yyi]; \
479 while (0)
480 # endif
481 # endif
483 /* Relocate STACK from its old location to the new one. The
484 local variables YYSIZE and YYSTACKSIZE give the old and new number of
485 elements in the stack, and YYPTR gives the new location of the
486 stack. Advance YYPTR to a properly aligned location for the next
487 stack. */
488 # define YYSTACK_RELOCATE(Stack) \
489 do \
491 YYSIZE_T yynewbytes; \
492 YYCOPY (&yyptr->Stack, Stack, yysize); \
493 Stack = &yyptr->Stack; \
494 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
495 yyptr += yynewbytes / sizeof (*yyptr); \
497 while (0)
499 #endif
501 #if defined (__STDC__) || defined (__cplusplus)
502 typedef signed char yysigned_char;
503 #else
504 typedef short yysigned_char;
505 #endif
507 /* YYFINAL -- State number of the termination state. */
508 #define YYFINAL 85
509 /* YYLAST -- Last index in YYTABLE. */
510 #define YYLAST 1199
512 /* YYNTOKENS -- Number of terminals. */
513 #define YYNTOKENS 76
514 /* YYNNTS -- Number of nonterminals. */
515 #define YYNNTS 40
516 /* YYNRULES -- Number of rules. */
517 #define YYNRULES 195
518 /* YYNRULES -- Number of states. */
519 #define YYNSTATES 330
521 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
522 #define YYUNDEFTOK 2
523 #define YYMAXUTOK 308
525 #define YYTRANSLATE(YYX) \
526 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
528 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
529 static const unsigned char yytranslate[] =
531 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
532 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
533 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
534 2, 2, 2, 73, 2, 2, 2, 64, 50, 2,
535 74, 42, 62, 60, 43, 61, 68, 63, 2, 2,
536 2, 2, 2, 2, 2, 2, 2, 2, 75, 2,
537 53, 44, 54, 45, 59, 2, 2, 2, 2, 2,
538 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
539 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
540 2, 69, 2, 71, 49, 2, 2, 2, 2, 2,
541 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
542 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
543 2, 2, 2, 2, 48, 2, 72, 2, 2, 2,
544 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
545 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
546 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
547 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
548 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
549 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
550 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
551 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
552 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
553 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
554 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
555 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
556 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
557 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
558 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
559 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
560 35, 36, 37, 38, 39, 40, 41, 46, 47, 51,
561 52, 55, 56, 57, 58, 65, 66, 67, 70
564 #if YYDEBUG
565 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
566 YYRHS. */
567 static const unsigned short yyprhs[] =
569 0, 0, 3, 5, 7, 9, 11, 12, 15, 18,
570 22, 26, 29, 32, 35, 40, 42, 45, 48, 53,
571 58, 61, 64, 67, 70, 73, 76, 79, 82, 85,
572 88, 91, 94, 97, 100, 103, 106, 109, 112, 115,
573 118, 121, 124, 127, 130, 133, 137, 140, 144, 148,
574 151, 154, 156, 160, 163, 165, 170, 173, 175, 178,
575 181, 183, 186, 188, 190, 192, 194, 197, 200, 202,
576 205, 209, 212, 216, 221, 223, 227, 229, 232, 235,
577 240, 242, 244, 247, 251, 256, 260, 265, 270, 274,
578 275, 277, 279, 281, 283, 285, 288, 290, 292, 294,
579 296, 298, 300, 302, 305, 307, 309, 311, 314, 316,
580 318, 320, 323, 325, 329, 334, 337, 341, 344, 346,
581 350, 353, 356, 358, 362, 365, 369, 372, 377, 381,
582 383, 386, 388, 392, 395, 398, 400, 402, 405, 407,
583 412, 415, 417, 420, 423, 425, 429, 432, 435, 437,
584 440, 442, 444, 449, 454, 459, 462, 465, 468, 471,
585 475, 477, 481, 484, 487, 490, 493, 498, 506, 514,
586 522, 527, 531, 535, 539, 543, 547, 551, 555, 559,
587 563, 567, 571, 575, 579, 583, 587, 591, 595, 599,
588 603, 609, 611, 613, 618, 620
591 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
592 static const yysigned_char yyrhs[] =
594 77, 0, -1, 78, -1, 109, -1, 81, -1, 80,
595 -1, -1, 12, 78, -1, 105, 112, -1, 105, 96,
596 79, -1, 89, 96, 79, -1, 84, 79, -1, 84,
597 108, -1, 38, 78, -1, 39, 78, 40, 78, -1,
598 41, -1, 17, 15, -1, 17, 16, -1, 17, 15,
599 69, 71, -1, 17, 16, 69, 71, -1, 17, 60,
600 -1, 17, 61, -1, 17, 62, -1, 17, 63, -1,
601 17, 64, -1, 17, 49, -1, 17, 50, -1, 17,
602 48, -1, 17, 72, -1, 17, 73, -1, 17, 44,
603 -1, 17, 53, -1, 17, 54, -1, 17, 35, -1,
604 17, 58, -1, 17, 57, -1, 17, 52, -1, 17,
605 51, -1, 17, 56, -1, 17, 55, -1, 17, 47,
606 -1, 17, 46, -1, 17, 66, -1, 17, 65, -1,
607 17, 43, -1, 17, 70, 62, -1, 17, 70, -1,
608 17, 74, 42, -1, 17, 69, 71, -1, 17, 105,
609 -1, 91, 83, -1, 83, -1, 12, 91, 83, -1,
610 12, 83, -1, 82, -1, 82, 53, 93, 54, -1,
611 72, 5, -1, 87, -1, 12, 87, -1, 91, 5,
612 -1, 5, -1, 91, 92, -1, 92, -1, 86, -1,
613 89, -1, 90, -1, 12, 90, -1, 91, 85, -1,
614 85, -1, 5, 12, -1, 91, 5, 12, -1, 92,
615 12, -1, 91, 92, 12, -1, 5, 53, 93, 54,
616 -1, 94, -1, 93, 43, 94, -1, 105, -1, 105,
617 106, -1, 50, 78, -1, 50, 74, 78, 42, -1,
618 114, -1, 105, -1, 105, 106, -1, 95, 43, 105,
619 -1, 95, 43, 105, 106, -1, 95, 43, 29, -1,
620 74, 95, 42, 97, -1, 74, 31, 42, 97, -1,
621 74, 42, 97, -1, -1, 99, -1, 30, -1, 26,
622 -1, 25, -1, 98, -1, 98, 99, -1, 24, -1,
623 21, -1, 11, -1, 33, -1, 22, -1, 23, -1,
624 100, -1, 101, 100, -1, 101, -1, 32, -1, 27,
625 -1, 22, 27, -1, 28, -1, 34, -1, 31, -1,
626 62, 97, -1, 50, -1, 91, 62, 97, -1, 12,
627 91, 62, 97, -1, 69, 71, -1, 69, 3, 71,
628 -1, 102, 99, -1, 102, -1, 99, 102, 99, -1,
629 99, 102, -1, 87, 99, -1, 87, -1, 99, 87,
630 99, -1, 99, 87, -1, 12, 87, 99, -1, 12,
631 87, -1, 99, 12, 87, 99, -1, 99, 12, 87,
632 -1, 103, -1, 103, 106, -1, 107, -1, 74, 106,
633 42, -1, 107, 96, -1, 107, 104, -1, 104, -1,
634 103, -1, 103, 108, -1, 107, -1, 107, 96, 12,
635 78, -1, 96, 79, -1, 105, -1, 105, 106, -1,
636 103, 110, -1, 111, -1, 74, 110, 42, -1, 111,
637 96, -1, 111, 104, -1, 88, -1, 103, 112, -1,
638 88, -1, 113, -1, 88, 96, 12, 78, -1, 113,
639 96, 12, 78, -1, 74, 103, 110, 42, -1, 113,
640 96, -1, 113, 104, -1, 88, 96, -1, 88, 104,
641 -1, 74, 115, 42, -1, 114, -1, 114, 54, 114,
642 -1, 50, 78, -1, 61, 114, -1, 73, 114, -1,
643 72, 114, -1, 74, 109, 42, 114, -1, 18, 53,
644 109, 54, 74, 115, 42, -1, 20, 53, 109, 54,
645 74, 115, 42, -1, 19, 53, 109, 54, 74, 115,
646 42, -1, 105, 74, 115, 42, -1, 114, 62, 114,
647 -1, 114, 63, 114, -1, 114, 64, 114, -1, 114,
648 60, 114, -1, 114, 61, 114, -1, 114, 58, 114,
649 -1, 114, 57, 114, -1, 114, 52, 114, -1, 114,
650 51, 114, -1, 114, 56, 114, -1, 114, 55, 114,
651 -1, 114, 53, 114, -1, 114, 50, 114, -1, 114,
652 49, 114, -1, 114, 48, 114, -1, 114, 47, 114,
653 -1, 114, 46, 114, -1, 114, 70, 5, -1, 114,
654 68, 5, -1, 114, 45, 114, 75, 114, -1, 3,
655 -1, 4, -1, 10, 74, 109, 42, -1, 36, -1,
656 37, -1
659 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
660 static const unsigned short yyrline[] =
662 0, 342, 342, 346, 348, 350, 355, 356, 363, 372,
663 375, 379, 382, 401, 405, 407, 413, 415, 417, 419,
664 421, 423, 425, 427, 429, 431, 433, 435, 437, 439,
665 441, 443, 445, 447, 449, 451, 453, 455, 457, 459,
666 461, 463, 465, 467, 469, 471, 473, 475, 477, 485,
667 490, 495, 499, 504, 512, 513, 515, 527, 528, 534,
668 536, 537, 539, 542, 543, 546, 547, 551, 553, 556,
669 562, 569, 575, 586, 590, 593, 604, 605, 609, 611,
670 613, 616, 620, 625, 630, 636, 646, 650, 654, 662,
671 663, 666, 668, 670, 674, 675, 682, 684, 686, 688,
672 690, 692, 696, 697, 701, 703, 705, 707, 709, 711,
673 713, 717, 723, 727, 735, 745, 749, 765, 767, 768,
674 770, 773, 775, 776, 778, 781, 783, 785, 787, 792,
675 795, 800, 807, 811, 822, 828, 846, 849, 857, 859,
676 870, 877, 878, 884, 888, 892, 894, 899, 904, 917,
677 921, 926, 934, 939, 948, 952, 957, 962, 966, 972,
678 978, 981, 988, 993, 997, 1001, 1008, 1024, 1031, 1038,
679 1051, 1062, 1066, 1070, 1074, 1078, 1082, 1086, 1090, 1094,
680 1098, 1102, 1106, 1110, 1114, 1118, 1122, 1126, 1131, 1135,
681 1139, 1146, 1150, 1153, 1158, 1167
683 #endif
685 #if YYDEBUG || YYERROR_VERBOSE
686 /* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
687 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
688 static const char *const yytname[] =
690 "$end", "error", "$undefined", "INT", "FLOAT", "NAME", "STRUCT",
691 "CLASS", "UNION", "ENUM", "SIZEOF", "UNSIGNED", "COLONCOLON", "TEMPLATE",
692 "ERROR", "NEW", "DELETE", "OPERATOR", "STATIC_CAST", "REINTERPRET_CAST",
693 "DYNAMIC_CAST", "SIGNED_KEYWORD", "LONG", "SHORT", "INT_KEYWORD",
694 "CONST_KEYWORD", "VOLATILE_KEYWORD", "DOUBLE_KEYWORD", "BOOL",
695 "ELLIPSIS", "RESTRICT", "VOID", "FLOAT_KEYWORD", "CHAR", "WCHAR_T",
696 "ASSIGN_MODIFY", "TRUEKEYWORD", "FALSEKEYWORD", "DEMANGLER_SPECIAL",
697 "CONSTRUCTION_VTABLE", "CONSTRUCTION_IN", "GLOBAL", "')'", "','", "'='",
698 "'?'", "OROR", "ANDAND", "'|'", "'^'", "'&'", "NOTEQUAL", "EQUAL", "'<'",
699 "'>'", "GEQ", "LEQ", "RSH", "LSH", "'@'", "'+'", "'-'", "'*'", "'/'",
700 "'%'", "DECREMENT", "INCREMENT", "UNARY", "'.'", "'['", "ARROW", "']'",
701 "'~'", "'!'", "'('", "':'", "$accept", "result", "start", "start_opt",
702 "function", "demangler_special", "operator", "conversion_op",
703 "conversion_op_name", "unqualified_name", "colon_name", "name",
704 "colon_ext_name", "colon_ext_only", "ext_only_name", "nested_name",
705 "template", "template_params", "template_arg", "function_args",
706 "function_arglist", "qualifiers_opt", "qualifier", "qualifiers",
707 "int_part", "int_seq", "builtin_type", "ptr_operator", "array_indicator",
708 "typespec_2", "abstract_declarator", "direct_abstract_declarator",
709 "abstract_declarator_fn", "type", "declarator", "direct_declarator",
710 "declarator_1", "direct_declarator_1", "exp", "exp1", 0
712 #endif
714 # ifdef YYPRINT
715 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
716 token YYLEX-NUM. */
717 static const unsigned short yytoknum[] =
719 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
720 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
721 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
722 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
723 295, 296, 41, 44, 61, 63, 297, 298, 124, 94,
724 38, 299, 300, 60, 62, 301, 302, 303, 304, 64,
725 43, 45, 42, 47, 37, 305, 306, 307, 46, 91,
726 308, 93, 126, 33, 40, 58
728 # endif
730 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
731 static const unsigned char yyr1[] =
733 0, 76, 77, 78, 78, 78, 79, 79, 80, 80,
734 80, 80, 80, 81, 81, 81, 82, 82, 82, 82,
735 82, 82, 82, 82, 82, 82, 82, 82, 82, 82,
736 82, 82, 82, 82, 82, 82, 82, 82, 82, 82,
737 82, 82, 82, 82, 82, 82, 82, 82, 82, 83,
738 84, 84, 84, 84, 85, 85, 85, 86, 86, 87,
739 87, 87, 87, 88, 88, 89, 89, 90, 90, 91,
740 91, 91, 91, 92, 93, 93, 94, 94, 94, 94,
741 94, 95, 95, 95, 95, 95, 96, 96, 96, 97,
742 97, 98, 98, 98, 99, 99, 100, 100, 100, 100,
743 100, 100, 101, 101, 102, 102, 102, 102, 102, 102,
744 102, 103, 103, 103, 103, 104, 104, 105, 105, 105,
745 105, 105, 105, 105, 105, 105, 105, 105, 105, 106,
746 106, 106, 107, 107, 107, 107, 108, 108, 108, 108,
747 108, 109, 109, 110, 110, 111, 111, 111, 111, 112,
748 112, 112, 112, 112, 113, 113, 113, 113, 113, 114,
749 115, 115, 115, 114, 114, 114, 114, 114, 114, 114,
750 114, 114, 114, 114, 114, 114, 114, 114, 114, 114,
751 114, 114, 114, 114, 114, 114, 114, 114, 114, 114,
752 114, 114, 114, 114, 114, 114
755 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
756 static const unsigned char yyr2[] =
758 0, 2, 1, 1, 1, 1, 0, 2, 2, 3,
759 3, 2, 2, 2, 4, 1, 2, 2, 4, 4,
760 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
761 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
762 2, 2, 2, 2, 2, 3, 2, 3, 3, 2,
763 2, 1, 3, 2, 1, 4, 2, 1, 2, 2,
764 1, 2, 1, 1, 1, 1, 2, 2, 1, 2,
765 3, 2, 3, 4, 1, 3, 1, 2, 2, 4,
766 1, 1, 2, 3, 4, 3, 4, 4, 3, 0,
767 1, 1, 1, 1, 1, 2, 1, 1, 1, 1,
768 1, 1, 1, 2, 1, 1, 1, 2, 1, 1,
769 1, 2, 1, 3, 4, 2, 3, 2, 1, 3,
770 2, 2, 1, 3, 2, 3, 2, 4, 3, 1,
771 2, 1, 3, 2, 2, 1, 1, 2, 1, 4,
772 2, 1, 2, 2, 1, 3, 2, 2, 1, 2,
773 1, 1, 4, 4, 4, 2, 2, 2, 2, 3,
774 1, 3, 2, 2, 2, 2, 4, 7, 7, 7,
775 4, 3, 3, 3, 3, 3, 3, 3, 3, 3,
776 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
777 5, 1, 1, 4, 1, 1
780 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
781 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
782 means the default is an error. */
783 static const unsigned char yydefact[] =
785 0, 60, 98, 0, 0, 97, 100, 101, 96, 93,
786 92, 106, 108, 91, 110, 105, 99, 109, 0, 0,
787 15, 0, 0, 2, 5, 4, 54, 51, 6, 68,
788 122, 0, 65, 0, 62, 94, 0, 102, 104, 118,
789 141, 3, 69, 0, 53, 126, 66, 0, 0, 16,
790 17, 33, 44, 30, 41, 40, 27, 25, 26, 37,
791 36, 31, 32, 39, 38, 35, 34, 20, 21, 22,
792 23, 24, 43, 42, 0, 46, 28, 29, 0, 0,
793 49, 107, 13, 0, 56, 1, 0, 0, 0, 112,
794 89, 0, 0, 11, 0, 0, 6, 136, 135, 138,
795 12, 121, 0, 6, 59, 50, 67, 61, 71, 95,
796 0, 124, 120, 100, 103, 117, 0, 0, 0, 63,
797 57, 150, 64, 0, 6, 129, 142, 131, 8, 151,
798 191, 192, 0, 0, 0, 0, 194, 195, 0, 0,
799 0, 0, 0, 0, 74, 76, 80, 125, 52, 0,
800 0, 48, 45, 47, 0, 0, 7, 0, 111, 90,
801 0, 115, 0, 110, 89, 0, 0, 0, 129, 81,
802 0, 0, 89, 0, 0, 140, 0, 137, 133, 134,
803 10, 70, 72, 128, 123, 119, 58, 0, 129, 157,
804 158, 9, 0, 130, 149, 133, 155, 156, 0, 0,
805 0, 0, 0, 78, 0, 163, 165, 164, 0, 141,
806 0, 160, 0, 0, 73, 0, 77, 0, 0, 0,
807 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
808 0, 0, 0, 0, 0, 0, 0, 18, 19, 14,
809 55, 89, 116, 0, 89, 88, 89, 0, 82, 132,
810 113, 0, 0, 127, 0, 148, 129, 0, 144, 0,
811 0, 141, 0, 0, 0, 0, 0, 0, 162, 0,
812 0, 159, 75, 112, 0, 0, 0, 187, 186, 185,
813 184, 183, 179, 178, 182, 181, 180, 177, 176, 174,
814 175, 171, 172, 173, 189, 188, 114, 87, 86, 85,
815 83, 139, 0, 143, 154, 146, 147, 152, 153, 193,
816 0, 0, 0, 79, 166, 161, 170, 0, 84, 145,
817 0, 0, 0, 190, 0, 0, 0, 167, 169, 168
820 /* YYDEFGOTO[NTERM-NUM]. */
821 static const short yydefgoto[] =
823 -1, 22, 156, 93, 24, 25, 26, 27, 28, 29,
824 119, 30, 255, 31, 32, 79, 34, 143, 144, 167,
825 96, 158, 35, 36, 37, 38, 39, 168, 98, 204,
826 170, 127, 100, 41, 257, 258, 128, 129, 211, 212
829 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
830 STATE-NUM. */
831 #define YYPACT_NINF -142
832 static const short yypact[] =
834 777, 9, -142, 10, 625, -142, -15, -142, -142, -142,
835 -142, -142, -142, -142, -142, -142, -142, -142, 777, 777,
836 -142, 11, 38, -142, -142, -142, -11, -142, 21, -142,
837 147, -10, -142, 32, 58, 147, 1007, -142, 375, 147,
838 274, -142, -142, 439, -142, 147, -142, 32, 76, 37,
839 62, -142, -142, -142, -142, -142, -142, -142, -142, -142,
840 -142, -142, -142, -142, -142, -142, -142, -142, -142, -142,
841 -142, -142, -142, -142, 30, 34, -142, -142, 81, 124,
842 -142, -142, -142, 94, -142, -142, 439, 9, 777, -142,
843 147, 8, 722, -142, 12, 58, 125, 359, -142, -18,
844 -142, -142, 895, 125, 54, -142, -142, 129, -142, -142,
845 76, 147, 147, -142, -142, -142, 50, 829, 722, -142,
846 -142, -18, -142, 68, 125, 435, -142, -18, -142, -18,
847 -142, -142, 74, 97, 100, 104, -142, -142, 691, 571,
848 571, 571, 512, -13, -142, 491, 1023, -142, -142, 71,
849 93, -142, -142, -142, 777, 60, -142, 139, -142, -142,
850 99, -142, 76, 136, 147, 559, 27, 33, 559, 559,
851 151, 54, 147, 129, 777, -142, 161, -142, 169, -142,
852 -142, -142, -142, 147, -142, -142, -142, 179, 723, 182,
853 -142, -142, 559, -142, -142, -142, 183, -142, 983, 983,
854 983, 983, 777, -142, 123, -7, -7, -7, 777, 491,
855 156, 997, 158, 439, -142, 357, -142, 571, 571, 571,
856 571, 571, 571, 571, 571, 571, 571, 571, 571, 571,
857 571, 571, 571, 571, 571, 198, 202, -142, -142, -142,
858 -142, 147, -142, 43, 147, -142, 147, 953, -142, -142,
859 -142, 48, 777, -142, 723, -142, 723, 171, -18, 777,
860 777, 559, 172, 163, 168, 178, 193, 512, -142, 571,
861 571, -142, -142, 802, 357, 194, 893, 1047, 1070, 1092,
862 1113, 795, 1129, 1129, 554, 554, 554, 267, 267, 142,
863 142, -7, -7, -7, -142, -142, -142, -142, -142, -142,
864 559, -142, 200, -142, -142, -142, -142, -142, -142, -142,
865 170, 173, 175, -142, -7, 1023, -142, 571, -142, -142,
866 512, 512, 512, 1023, 201, 203, 204, -142, -142, -142
869 /* YYPGOTO[NTERM-NUM]. */
870 static const short yypgoto[] =
872 -142, -142, 80, 56, -142, -142, -142, 3, -142, -2,
873 -142, -1, -32, -17, 4, 0, 247, 176, 44, -142,
874 -27, -95, -142, -25, 220, -142, 229, -6, -75, 25,
875 95, -19, 174, -141, -128, -142, 141, -142, 89, -131
878 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
879 positive, shift that token. If negative, reduce the rule which
880 number is the opposite. If zero, do what YYDEFACT says.
881 If YYTABLE_NINF, syntax error. */
882 #define YYTABLE_NINF -1
883 static const unsigned short yytable[] =
885 33, 210, 45, 47, 103, 101, 44, 46, 121, 99,
886 109, 160, 81, 124, 115, 1, 84, 171, 33, 33,
887 147, 42, 97, 122, 179, 40, 87, 4, 94, 80,
888 213, 106, 104, 88, 125, 111, 105, 104, 85, 120,
889 123, 214, 86, 40, 40, 106, 190, 45, 104, 4,
890 148, 91, 179, 171, 197, 1, 102, 262, 263, 264,
891 265, 235, 43, 236, 102, 159, 181, 117, 145, 245,
892 108, 89, 178, 104, 172, 246, 247, 250, 99, 161,
893 23, 1, 21, 90, 275, 117, 184, 185, 157, 172,
894 91, 97, 166, 121, 189, 92, 152, 94, 82, 83,
895 195, 151, 196, 213, 21, 241, 149, 43, 122, 183,
896 241, 145, 188, 40, 240, 186, 187, 169, 166, 125,
897 46, 106, 21, 153, 120, 123, 302, 169, 303, 104,
898 172, 150, 146, 210, 154, 126, 275, 174, 33, 159,
899 21, 182, 237, 169, 104, 94, 296, 159, 198, 297,
900 199, 298, 175, 200, 33, 106, 4, 201, 253, 180,
901 105, 45, 243, 40, 238, 94, 87, 209, 94, 94,
902 242, 122, 9, 10, 33, 146, 251, 13, 244, 40,
903 191, 252, 256, 306, 104, 106, 188, 120, 123, 324,
904 325, 326, 94, 249, 259, 260, 117, 267, 269, 40,
905 271, 241, 33, 294, 232, 233, 234, 295, 33, 94,
906 235, 21, 236, 304, 309, 166, 159, 310, 203, 159,
907 193, 159, 311, 261, 261, 261, 261, 40, 205, 206,
908 207, 305, 312, 40, 239, 313, 316, 122, 145, 122,
909 216, 241, 319, 327, 320, 328, 329, 321, 256, 322,
910 256, 21, 33, 120, 123, 120, 123, 272, 114, 33,
911 33, 94, 155, 193, 248, 112, 194, 0, 0, 0,
912 0, 177, 300, 33, 166, 95, 0, 40, 0, 1,
913 107, 0, 266, 193, 40, 40, 116, 0, 268, 0,
914 0, 117, 0, 0, 107, 0, 0, 0, 40, 209,
915 94, 0, 146, 0, 126, 0, 276, 277, 278, 279,
916 280, 281, 282, 283, 284, 285, 286, 287, 288, 289,
917 290, 291, 292, 293, 89, 0, 107, 230, 231, 232,
918 233, 234, 301, 0, 0, 235, 90, 236, 0, 307,
919 308, 173, 0, 91, 95, 0, 21, 0, 118, 0,
920 0, 193, 0, 268, 0, 0, 126, 0, 314, 315,
921 130, 131, 1, 0, 87, 0, 0, 132, 2, 162,
922 107, 176, 0, 0, 0, 133, 134, 135, 5, 6,
923 7, 8, 9, 10, 11, 12, 2, 13, 14, 15,
924 16, 17, 95, 136, 137, 318, 5, 113, 7, 8,
925 0, 0, 0, 0, 107, 0, 323, 273, 16, 89,
926 0, 0, 95, 107, 0, 95, 95, 0, 139, 90,
927 0, 90, 0, 95, 0, 0, 91, 0, 91, 140,
928 141, 274, 0, 92, 107, 0, 0, 0, 0, 95,
929 1, 0, 130, 131, 1, 0, 0, 116, 0, 132,
930 2, 48, 117, 0, 0, 0, 95, 133, 134, 135,
931 5, 6, 7, 8, 9, 10, 11, 12, 0, 13,
932 14, 15, 16, 17, 0, 136, 137, 0, 0, 0,
933 0, 0, 0, 0, 0, 89, 0, 0, 0, 138,
934 107, 0, 0, 0, 0, 0, 87, 90, 173, 0,
935 139, 0, 0, 176, 91, 0, 0, 21, 95, 192,
936 0, 140, 141, 142, 0, 130, 131, 1, 0, 0,
937 0, 0, 132, 2, 48, 0, 0, 0, 0, 0,
938 133, 134, 135, 5, 6, 7, 8, 9, 10, 11,
939 12, 89, 13, 14, 15, 16, 17, 95, 136, 137,
940 0, 0, 0, 90, 0, 0, 0, 0, 0, 0,
941 91, 0, 208, 0, 87, 215, 0, 0, 0, 0,
942 0, 176, 0, 139, 130, 131, 1, 0, 0, 0,
943 0, 132, 2, 48, 140, 141, 142, 0, 0, 133,
944 134, 135, 5, 6, 7, 8, 9, 10, 11, 12,
945 0, 13, 14, 15, 16, 17, 0, 136, 137, 89,
946 0, 228, 229, 0, 230, 231, 232, 233, 234, 0,
947 0, 90, 235, 0, 236, 0, 0, 0, 91, 0,
948 1, 0, 139, 165, 0, 0, 2, 48, 0, 0,
949 49, 50, 0, 140, 141, 142, 5, 6, 7, 8,
950 9, 10, 11, 12, 0, 13, 14, 15, 16, 17,
951 51, 0, 0, 0, 0, 0, 0, 0, 52, 53,
952 0, 54, 55, 56, 57, 58, 59, 60, 61, 62,
953 63, 64, 65, 66, 0, 67, 68, 69, 70, 71,
954 72, 73, 0, 0, 74, 75, 1, 76, 77, 78,
955 0, 0, 2, 3, 0, 0, 0, 0, 4, 0,
956 0, 0, 5, 6, 7, 8, 9, 10, 11, 12,
957 0, 13, 14, 15, 16, 17, 0, 1, 1, 18,
958 19, 0, 20, 2, 162, 116, 0, 0, 0, 0,
959 117, 0, 0, 5, 6, 7, 8, 9, 10, 11,
960 12, 0, 13, 163, 15, 16, 17, 0, 0, 0,
961 0, 0, 0, 21, 164, 202, 0, 0, 0, 0,
962 0, 0, 89, 89, 0, 0, 0, 0, 0, 0,
963 0, 0, 1, 0, 90, 90, 0, 0, 2, 3,
964 0, 91, 91, 0, 4, 21, 165, 254, 5, 6,
965 7, 8, 9, 10, 11, 12, 0, 13, 14, 15,
966 16, 17, 0, 2, 3, 18, 19, 0, 20, 4,
967 0, 0, 0, 5, 6, 7, 8, 9, 10, 11,
968 12, 0, 13, 14, 15, 16, 17, 0, 0, 0,
969 18, 19, 0, 20, 49, 50, 223, 224, 225, 21,
970 226, 227, 228, 229, 0, 230, 231, 232, 233, 234,
971 0, 0, 0, 235, 51, 236, 0, 0, 0, 0,
972 0, 0, 52, 53, 21, 54, 55, 56, 57, 58,
973 59, 60, 61, 62, 63, 64, 65, 66, 0, 67,
974 68, 69, 70, 71, 72, 73, 0, 0, 74, 75,
975 1, 76, 77, 78, 0, 0, 2, 48, 0, 0,
976 0, 0, 0, 0, 0, 0, 5, 6, 7, 8,
977 9, 10, 11, 12, 0, 13, 163, 15, 16, 17,
978 0, 0, 0, 0, 0, 0, 0, 164, 217, 218,
979 219, 220, 221, 222, 223, 224, 225, 0, 226, 227,
980 228, 229, 0, 230, 231, 232, 233, 234, 1, 0,
981 0, 235, 0, 236, 2, 48, 0, 0, 317, 0,
982 0, 0, 0, 0, 5, 6, 7, 8, 9, 10,
983 11, 12, 299, 13, 14, 15, 16, 17, 1, 0,
984 0, 0, 0, 0, 2, 48, 0, 0, 0, 0,
985 0, 0, 0, 0, 5, 6, 7, 8, 9, 10,
986 11, 12, 1, 13, 14, 15, 16, 17, 2, 110,
987 0, 0, 0, 0, 0, 0, 0, 0, 5, 6,
988 7, 8, 0, 0, 11, 12, 0, 0, 14, 15,
989 16, 17, 217, 218, 219, 220, 221, 222, 223, 224,
990 225, 270, 226, 227, 228, 229, 0, 230, 231, 232,
991 233, 234, 0, 0, 0, 235, 0, 236, 217, 218,
992 219, 220, 221, 222, 223, 224, 225, 0, 226, 227,
993 228, 229, 0, 230, 231, 232, 233, 234, 0, 0,
994 0, 235, 0, 236, 219, 220, 221, 222, 223, 224,
995 225, 0, 226, 227, 228, 229, 0, 230, 231, 232,
996 233, 234, 0, 0, 0, 235, 0, 236, 220, 221,
997 222, 223, 224, 225, 0, 226, 227, 228, 229, 0,
998 230, 231, 232, 233, 234, 0, 0, 0, 235, 0,
999 236, 221, 222, 223, 224, 225, 0, 226, 227, 228,
1000 229, 0, 230, 231, 232, 233, 234, 0, 0, 0,
1001 235, 0, 236, 222, 223, 224, 225, 0, 226, 227,
1002 228, 229, 0, 230, 231, 232, 233, 234, 0, 0,
1003 0, 235, 225, 236, 226, 227, 228, 229, 0, 230,
1004 231, 232, 233, 234, 0, 0, 0, 235, 0, 236
1007 static const short yycheck[] =
1009 0, 142, 3, 3, 31, 30, 3, 3, 40, 28,
1010 35, 3, 27, 40, 39, 5, 5, 5, 18, 19,
1011 45, 12, 28, 40, 99, 0, 5, 17, 28, 4,
1012 43, 33, 5, 12, 40, 36, 33, 5, 0, 40,
1013 40, 54, 53, 18, 19, 47, 121, 48, 5, 17,
1014 47, 69, 127, 5, 129, 5, 74, 198, 199, 200,
1015 201, 68, 53, 70, 74, 90, 12, 17, 43, 164,
1016 12, 50, 99, 5, 62, 42, 43, 172, 97, 71,
1017 0, 5, 72, 62, 215, 17, 111, 112, 88, 62,
1018 69, 97, 92, 125, 121, 74, 62, 97, 18, 19,
1019 127, 71, 129, 43, 72, 62, 69, 53, 125, 110,
1020 62, 86, 118, 88, 54, 116, 116, 92, 118, 125,
1021 116, 123, 72, 42, 125, 125, 254, 102, 256, 5,
1022 62, 69, 43, 274, 40, 40, 267, 12, 138, 164,
1023 72, 12, 71, 118, 5, 145, 241, 172, 74, 244,
1024 53, 246, 96, 53, 154, 157, 17, 53, 183, 103,
1025 157, 162, 162, 138, 71, 165, 5, 142, 168, 169,
1026 71, 188, 25, 26, 174, 86, 176, 30, 42, 154,
1027 124, 12, 188, 258, 5, 187, 192, 188, 188, 320,
1028 321, 322, 192, 42, 12, 12, 17, 74, 42, 174,
1029 42, 62, 202, 5, 62, 63, 64, 5, 208, 209,
1030 68, 72, 70, 42, 42, 215, 241, 54, 138, 244,
1031 125, 246, 54, 198, 199, 200, 201, 202, 139, 140,
1032 141, 258, 54, 208, 154, 42, 42, 254, 213, 256,
1033 145, 62, 42, 42, 74, 42, 42, 74, 254, 74,
1034 256, 72, 252, 254, 254, 256, 256, 213, 38, 259,
1035 260, 261, 86, 168, 169, 36, 125, -1, -1, -1,
1036 -1, 97, 247, 273, 274, 28, -1, 252, -1, 5,
1037 33, -1, 202, 188, 259, 260, 12, -1, 208, -1,
1038 -1, 17, -1, -1, 47, -1, -1, -1, 273, 274,
1039 300, -1, 213, -1, 209, -1, 217, 218, 219, 220,
1040 221, 222, 223, 224, 225, 226, 227, 228, 229, 230,
1041 231, 232, 233, 234, 50, -1, 79, 60, 61, 62,
1042 63, 64, 252, -1, -1, 68, 62, 70, -1, 259,
1043 260, 94, -1, 69, 97, -1, 72, -1, 74, -1,
1044 -1, 256, -1, 273, -1, -1, 261, -1, 269, 270,
1045 3, 4, 5, -1, 5, -1, -1, 10, 11, 12,
1046 123, 12, -1, -1, -1, 18, 19, 20, 21, 22,
1047 23, 24, 25, 26, 27, 28, 11, 30, 31, 32,
1048 33, 34, 145, 36, 37, 300, 21, 22, 23, 24,
1049 -1, -1, -1, -1, 157, -1, 317, 50, 33, 50,
1050 -1, -1, 165, 166, -1, 168, 169, -1, 61, 62,
1051 -1, 62, -1, 176, -1, -1, 69, -1, 69, 72,
1052 73, 74, -1, 74, 187, -1, -1, -1, -1, 192,
1053 5, -1, 3, 4, 5, -1, -1, 12, -1, 10,
1054 11, 12, 17, -1, -1, -1, 209, 18, 19, 20,
1055 21, 22, 23, 24, 25, 26, 27, 28, -1, 30,
1056 31, 32, 33, 34, -1, 36, 37, -1, -1, -1,
1057 -1, -1, -1, -1, -1, 50, -1, -1, -1, 50,
1058 243, -1, -1, -1, -1, -1, 5, 62, 251, -1,
1059 61, -1, -1, 12, 69, -1, -1, 72, 261, 74,
1060 -1, 72, 73, 74, -1, 3, 4, 5, -1, -1,
1061 -1, -1, 10, 11, 12, -1, -1, -1, -1, -1,
1062 18, 19, 20, 21, 22, 23, 24, 25, 26, 27,
1063 28, 50, 30, 31, 32, 33, 34, 300, 36, 37,
1064 -1, -1, -1, 62, -1, -1, -1, -1, -1, -1,
1065 69, -1, 50, -1, 5, 74, -1, -1, -1, -1,
1066 -1, 12, -1, 61, 3, 4, 5, -1, -1, -1,
1067 -1, 10, 11, 12, 72, 73, 74, -1, -1, 18,
1068 19, 20, 21, 22, 23, 24, 25, 26, 27, 28,
1069 -1, 30, 31, 32, 33, 34, -1, 36, 37, 50,
1070 -1, 57, 58, -1, 60, 61, 62, 63, 64, -1,
1071 -1, 62, 68, -1, 70, -1, -1, -1, 69, -1,
1072 5, -1, 61, 74, -1, -1, 11, 12, -1, -1,
1073 15, 16, -1, 72, 73, 74, 21, 22, 23, 24,
1074 25, 26, 27, 28, -1, 30, 31, 32, 33, 34,
1075 35, -1, -1, -1, -1, -1, -1, -1, 43, 44,
1076 -1, 46, 47, 48, 49, 50, 51, 52, 53, 54,
1077 55, 56, 57, 58, -1, 60, 61, 62, 63, 64,
1078 65, 66, -1, -1, 69, 70, 5, 72, 73, 74,
1079 -1, -1, 11, 12, -1, -1, -1, -1, 17, -1,
1080 -1, -1, 21, 22, 23, 24, 25, 26, 27, 28,
1081 -1, 30, 31, 32, 33, 34, -1, 5, 5, 38,
1082 39, -1, 41, 11, 12, 12, -1, -1, -1, -1,
1083 17, -1, -1, 21, 22, 23, 24, 25, 26, 27,
1084 28, -1, 30, 31, 32, 33, 34, -1, -1, -1,
1085 -1, -1, -1, 72, 42, 74, -1, -1, -1, -1,
1086 -1, -1, 50, 50, -1, -1, -1, -1, -1, -1,
1087 -1, -1, 5, -1, 62, 62, -1, -1, 11, 12,
1088 -1, 69, 69, -1, 17, 72, 74, 74, 21, 22,
1089 23, 24, 25, 26, 27, 28, -1, 30, 31, 32,
1090 33, 34, -1, 11, 12, 38, 39, -1, 41, 17,
1091 -1, -1, -1, 21, 22, 23, 24, 25, 26, 27,
1092 28, -1, 30, 31, 32, 33, 34, -1, -1, -1,
1093 38, 39, -1, 41, 15, 16, 51, 52, 53, 72,
1094 55, 56, 57, 58, -1, 60, 61, 62, 63, 64,
1095 -1, -1, -1, 68, 35, 70, -1, -1, -1, -1,
1096 -1, -1, 43, 44, 72, 46, 47, 48, 49, 50,
1097 51, 52, 53, 54, 55, 56, 57, 58, -1, 60,
1098 61, 62, 63, 64, 65, 66, -1, -1, 69, 70,
1099 5, 72, 73, 74, -1, -1, 11, 12, -1, -1,
1100 -1, -1, -1, -1, -1, -1, 21, 22, 23, 24,
1101 25, 26, 27, 28, -1, 30, 31, 32, 33, 34,
1102 -1, -1, -1, -1, -1, -1, -1, 42, 45, 46,
1103 47, 48, 49, 50, 51, 52, 53, -1, 55, 56,
1104 57, 58, -1, 60, 61, 62, 63, 64, 5, -1,
1105 -1, 68, -1, 70, 11, 12, -1, -1, 75, -1,
1106 -1, -1, -1, -1, 21, 22, 23, 24, 25, 26,
1107 27, 28, 29, 30, 31, 32, 33, 34, 5, -1,
1108 -1, -1, -1, -1, 11, 12, -1, -1, -1, -1,
1109 -1, -1, -1, -1, 21, 22, 23, 24, 25, 26,
1110 27, 28, 5, 30, 31, 32, 33, 34, 11, 12,
1111 -1, -1, -1, -1, -1, -1, -1, -1, 21, 22,
1112 23, 24, -1, -1, 27, 28, -1, -1, 31, 32,
1113 33, 34, 45, 46, 47, 48, 49, 50, 51, 52,
1114 53, 54, 55, 56, 57, 58, -1, 60, 61, 62,
1115 63, 64, -1, -1, -1, 68, -1, 70, 45, 46,
1116 47, 48, 49, 50, 51, 52, 53, -1, 55, 56,
1117 57, 58, -1, 60, 61, 62, 63, 64, -1, -1,
1118 -1, 68, -1, 70, 47, 48, 49, 50, 51, 52,
1119 53, -1, 55, 56, 57, 58, -1, 60, 61, 62,
1120 63, 64, -1, -1, -1, 68, -1, 70, 48, 49,
1121 50, 51, 52, 53, -1, 55, 56, 57, 58, -1,
1122 60, 61, 62, 63, 64, -1, -1, -1, 68, -1,
1123 70, 49, 50, 51, 52, 53, -1, 55, 56, 57,
1124 58, -1, 60, 61, 62, 63, 64, -1, -1, -1,
1125 68, -1, 70, 50, 51, 52, 53, -1, 55, 56,
1126 57, 58, -1, 60, 61, 62, 63, 64, -1, -1,
1127 -1, 68, 53, 70, 55, 56, 57, 58, -1, 60,
1128 61, 62, 63, 64, -1, -1, -1, 68, -1, 70
1131 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
1132 symbol of state STATE-NUM. */
1133 static const unsigned char yystos[] =
1135 0, 5, 11, 12, 17, 21, 22, 23, 24, 25,
1136 26, 27, 28, 30, 31, 32, 33, 34, 38, 39,
1137 41, 72, 77, 78, 80, 81, 82, 83, 84, 85,
1138 87, 89, 90, 91, 92, 98, 99, 100, 101, 102,
1139 105, 109, 12, 53, 83, 87, 90, 91, 12, 15,
1140 16, 35, 43, 44, 46, 47, 48, 49, 50, 51,
1141 52, 53, 54, 55, 56, 57, 58, 60, 61, 62,
1142 63, 64, 65, 66, 69, 70, 72, 73, 74, 91,
1143 105, 27, 78, 78, 5, 0, 53, 5, 12, 50,
1144 62, 69, 74, 79, 91, 92, 96, 103, 104, 107,
1145 108, 99, 74, 96, 5, 83, 85, 92, 12, 99,
1146 12, 87, 102, 22, 100, 99, 12, 17, 74, 86,
1147 87, 88, 89, 91, 96, 103, 106, 107, 112, 113,
1148 3, 4, 10, 18, 19, 20, 36, 37, 50, 61,
1149 72, 73, 74, 93, 94, 105, 114, 99, 83, 69,
1150 69, 71, 62, 42, 40, 93, 78, 91, 97, 99,
1151 3, 71, 12, 31, 42, 74, 91, 95, 103, 105,
1152 106, 5, 62, 92, 12, 79, 12, 108, 96, 104,
1153 79, 12, 12, 87, 99, 99, 87, 91, 103, 96,
1154 104, 79, 74, 106, 112, 96, 96, 104, 74, 53,
1155 53, 53, 74, 78, 105, 114, 114, 114, 50, 105,
1156 109, 114, 115, 43, 54, 74, 106, 45, 46, 47,
1157 48, 49, 50, 51, 52, 53, 55, 56, 57, 58,
1158 60, 61, 62, 63, 64, 68, 70, 71, 71, 78,
1159 54, 62, 71, 91, 42, 97, 42, 43, 106, 42,
1160 97, 91, 12, 99, 74, 88, 103, 110, 111, 12,
1161 12, 105, 109, 109, 109, 109, 78, 74, 78, 42,
1162 54, 42, 94, 50, 74, 115, 114, 114, 114, 114,
1163 114, 114, 114, 114, 114, 114, 114, 114, 114, 114,
1164 114, 114, 114, 114, 5, 5, 97, 97, 97, 29,
1165 105, 78, 110, 110, 42, 96, 104, 78, 78, 42,
1166 54, 54, 54, 42, 114, 114, 42, 75, 106, 42,
1167 74, 74, 74, 114, 115, 115, 115, 42, 42, 42
1170 #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
1171 # define YYSIZE_T __SIZE_TYPE__
1172 #endif
1173 #if ! defined (YYSIZE_T) && defined (size_t)
1174 # define YYSIZE_T size_t
1175 #endif
1176 #if ! defined (YYSIZE_T)
1177 # if defined (__STDC__) || defined (__cplusplus)
1178 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
1179 # define YYSIZE_T size_t
1180 # endif
1181 #endif
1182 #if ! defined (YYSIZE_T)
1183 # define YYSIZE_T unsigned int
1184 #endif
1186 #define yyerrok (yyerrstatus = 0)
1187 #define yyclearin (yychar = YYEMPTY)
1188 #define YYEMPTY (-2)
1189 #define YYEOF 0
1191 #define YYACCEPT goto yyacceptlab
1192 #define YYABORT goto yyabortlab
1193 #define YYERROR goto yyerrorlab
1196 /* Like YYERROR except do call yyerror. This remains here temporarily
1197 to ease the transition to the new meaning of YYERROR, for GCC.
1198 Once GCC version 2 has supplanted version 1, this can go. */
1200 #define YYFAIL goto yyerrlab
1202 #define YYRECOVERING() (!!yyerrstatus)
1204 #define YYBACKUP(Token, Value) \
1205 do \
1206 if (yychar == YYEMPTY && yylen == 1) \
1208 yychar = (Token); \
1209 yylval = (Value); \
1210 yytoken = YYTRANSLATE (yychar); \
1211 YYPOPSTACK; \
1212 goto yybackup; \
1214 else \
1216 yyerror ("syntax error: cannot back up");\
1217 YYERROR; \
1219 while (0)
1221 #define YYTERROR 1
1222 #define YYERRCODE 256
1224 /* YYLLOC_DEFAULT -- Compute the default location (before the actions
1225 are run). */
1227 #ifndef YYLLOC_DEFAULT
1228 # define YYLLOC_DEFAULT(Current, Rhs, N) \
1229 ((Current).first_line = (Rhs)[1].first_line, \
1230 (Current).first_column = (Rhs)[1].first_column, \
1231 (Current).last_line = (Rhs)[N].last_line, \
1232 (Current).last_column = (Rhs)[N].last_column)
1233 #endif
1235 /* YYLEX -- calling `yylex' with the right arguments. */
1237 #ifdef YYLEX_PARAM
1238 # define YYLEX yylex (YYLEX_PARAM)
1239 #else
1240 # define YYLEX yylex ()
1241 #endif
1243 /* Enable debugging if requested. */
1244 #if YYDEBUG
1246 # ifndef YYFPRINTF
1247 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
1248 # define YYFPRINTF fprintf
1249 # endif
1251 # define YYDPRINTF(Args) \
1252 do { \
1253 if (yydebug) \
1254 YYFPRINTF Args; \
1255 } while (0)
1257 # define YYDSYMPRINT(Args) \
1258 do { \
1259 if (yydebug) \
1260 yysymprint Args; \
1261 } while (0)
1263 # define YYDSYMPRINTF(Title, Token, Value, Location) \
1264 do { \
1265 if (yydebug) \
1267 YYFPRINTF (stderr, "%s ", Title); \
1268 yysymprint (stderr, \
1269 Token, Value); \
1270 YYFPRINTF (stderr, "\n"); \
1272 } while (0)
1274 /*------------------------------------------------------------------.
1275 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
1276 | TOP (included). |
1277 `------------------------------------------------------------------*/
1279 #if defined (__STDC__) || defined (__cplusplus)
1280 static void
1281 yy_stack_print (short *bottom, short *top)
1282 #else
1283 static void
1284 yy_stack_print (bottom, top)
1285 short *bottom;
1286 short *top;
1287 #endif
1289 YYFPRINTF (stderr, "Stack now");
1290 for (/* Nothing. */; bottom <= top; ++bottom)
1291 YYFPRINTF (stderr, " %d", *bottom);
1292 YYFPRINTF (stderr, "\n");
1295 # define YY_STACK_PRINT(Bottom, Top) \
1296 do { \
1297 if (yydebug) \
1298 yy_stack_print ((Bottom), (Top)); \
1299 } while (0)
1302 /*------------------------------------------------.
1303 | Report that the YYRULE is going to be reduced. |
1304 `------------------------------------------------*/
1306 #if defined (__STDC__) || defined (__cplusplus)
1307 static void
1308 yy_reduce_print (int yyrule)
1309 #else
1310 static void
1311 yy_reduce_print (yyrule)
1312 int yyrule;
1313 #endif
1315 int yyi;
1316 unsigned int yylno = yyrline[yyrule];
1317 YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ",
1318 yyrule - 1, yylno);
1319 /* Print the symbols being reduced, and their result. */
1320 for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
1321 YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]);
1322 YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]);
1325 # define YY_REDUCE_PRINT(Rule) \
1326 do { \
1327 if (yydebug) \
1328 yy_reduce_print (Rule); \
1329 } while (0)
1331 /* Nonzero means print parse trace. It is left uninitialized so that
1332 multiple parsers can coexist. */
1333 int yydebug;
1334 #else /* !YYDEBUG */
1335 # define YYDPRINTF(Args)
1336 # define YYDSYMPRINT(Args)
1337 # define YYDSYMPRINTF(Title, Token, Value, Location)
1338 # define YY_STACK_PRINT(Bottom, Top)
1339 # define YY_REDUCE_PRINT(Rule)
1340 #endif /* !YYDEBUG */
1343 /* YYINITDEPTH -- initial size of the parser's stacks. */
1344 #ifndef YYINITDEPTH
1345 # define YYINITDEPTH 200
1346 #endif
1348 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
1349 if the built-in stack extension method is used).
1351 Do not make this value too large; the results are undefined if
1352 SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
1353 evaluated with infinite-precision integer arithmetic. */
1355 #if defined (YYMAXDEPTH) && YYMAXDEPTH == 0
1356 # undef YYMAXDEPTH
1357 #endif
1359 #ifndef YYMAXDEPTH
1360 # define YYMAXDEPTH 10000
1361 #endif
1365 #if YYERROR_VERBOSE
1367 # ifndef yystrlen
1368 # if defined (__GLIBC__) && defined (_STRING_H)
1369 # define yystrlen strlen
1370 # else
1371 /* Return the length of YYSTR. */
1372 static YYSIZE_T
1373 # if defined (__STDC__) || defined (__cplusplus)
1374 yystrlen (const char *yystr)
1375 # else
1376 yystrlen (yystr)
1377 const char *yystr;
1378 # endif
1380 register const char *yys = yystr;
1382 while (*yys++ != '\0')
1383 continue;
1385 return yys - yystr - 1;
1387 # endif
1388 # endif
1390 # ifndef yystpcpy
1391 # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
1392 # define yystpcpy stpcpy
1393 # else
1394 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
1395 YYDEST. */
1396 static char *
1397 # if defined (__STDC__) || defined (__cplusplus)
1398 yystpcpy (char *yydest, const char *yysrc)
1399 # else
1400 yystpcpy (yydest, yysrc)
1401 char *yydest;
1402 const char *yysrc;
1403 # endif
1405 register char *yyd = yydest;
1406 register const char *yys = yysrc;
1408 while ((*yyd++ = *yys++) != '\0')
1409 continue;
1411 return yyd - 1;
1413 # endif
1414 # endif
1416 #endif /* !YYERROR_VERBOSE */
1420 #if YYDEBUG
1421 /*--------------------------------.
1422 | Print this symbol on YYOUTPUT. |
1423 `--------------------------------*/
1425 #if defined (__STDC__) || defined (__cplusplus)
1426 static void
1427 yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep)
1428 #else
1429 static void
1430 yysymprint (yyoutput, yytype, yyvaluep)
1431 FILE *yyoutput;
1432 int yytype;
1433 YYSTYPE *yyvaluep;
1434 #endif
1436 /* Pacify ``unused variable'' warnings. */
1437 (void) yyvaluep;
1439 if (yytype < YYNTOKENS)
1441 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
1442 # ifdef YYPRINT
1443 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
1444 # endif
1446 else
1447 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
1449 switch (yytype)
1451 default:
1452 break;
1454 YYFPRINTF (yyoutput, ")");
1457 #endif /* ! YYDEBUG */
1458 /*-----------------------------------------------.
1459 | Release the memory associated to this symbol. |
1460 `-----------------------------------------------*/
1462 #if defined (__STDC__) || defined (__cplusplus)
1463 static void
1464 yydestruct (int yytype, YYSTYPE *yyvaluep)
1465 #else
1466 static void
1467 yydestruct (yytype, yyvaluep)
1468 int yytype;
1469 YYSTYPE *yyvaluep;
1470 #endif
1472 /* Pacify ``unused variable'' warnings. */
1473 (void) yyvaluep;
1475 switch (yytype)
1478 default:
1479 break;
1484 /* Prevent warnings from -Wmissing-prototypes. */
1486 #ifdef YYPARSE_PARAM
1487 # if defined (__STDC__) || defined (__cplusplus)
1488 int yyparse (void *YYPARSE_PARAM);
1489 # else
1490 int yyparse ();
1491 # endif
1492 #else /* ! YYPARSE_PARAM */
1493 #if defined (__STDC__) || defined (__cplusplus)
1494 int yyparse (void);
1495 #else
1496 int yyparse ();
1497 #endif
1498 #endif /* ! YYPARSE_PARAM */
1502 /* The lookahead symbol. */
1503 int yychar;
1505 /* The semantic value of the lookahead symbol. */
1506 YYSTYPE yylval;
1508 /* Number of syntax errors so far. */
1509 int yynerrs;
1513 /*----------.
1514 | yyparse. |
1515 `----------*/
1517 #ifdef YYPARSE_PARAM
1518 # if defined (__STDC__) || defined (__cplusplus)
1519 int yyparse (void *YYPARSE_PARAM)
1520 # else
1521 int yyparse (YYPARSE_PARAM)
1522 void *YYPARSE_PARAM;
1523 # endif
1524 #else /* ! YYPARSE_PARAM */
1525 #if defined (__STDC__) || defined (__cplusplus)
1527 yyparse (void)
1528 #else
1530 yyparse ()
1532 #endif
1533 #endif
1536 register int yystate;
1537 register int yyn;
1538 int yyresult;
1539 /* Number of tokens to shift before error messages enabled. */
1540 int yyerrstatus;
1541 /* Lookahead token as an internal (translated) token number. */
1542 int yytoken = 0;
1544 /* Three stacks and their tools:
1545 `yyss': related to states,
1546 `yyvs': related to semantic values,
1547 `yyls': related to locations.
1549 Refer to the stacks thru separate pointers, to allow yyoverflow
1550 to xreallocate them elsewhere. */
1552 /* The state stack. */
1553 short yyssa[YYINITDEPTH];
1554 short *yyss = yyssa;
1555 register short *yyssp;
1557 /* The semantic value stack. */
1558 YYSTYPE yyvsa[YYINITDEPTH];
1559 YYSTYPE *yyvs = yyvsa;
1560 register YYSTYPE *yyvsp;
1564 #define YYPOPSTACK (yyvsp--, yyssp--)
1566 YYSIZE_T yystacksize = YYINITDEPTH;
1568 /* The variables used to return semantic value and location from the
1569 action routines. */
1570 YYSTYPE yyval;
1573 /* When reducing, the number of symbols on the RHS of the reduced
1574 rule. */
1575 int yylen;
1577 YYDPRINTF ((stderr, "Starting parse\n"));
1579 yystate = 0;
1580 yyerrstatus = 0;
1581 yynerrs = 0;
1582 yychar = YYEMPTY; /* Cause a token to be read. */
1584 /* Initialize stack pointers.
1585 Waste one element of value and location stack
1586 so that they stay on the same level as the state stack.
1587 The wasted elements are never initialized. */
1589 yyssp = yyss;
1590 yyvsp = yyvs;
1592 goto yysetstate;
1594 /*------------------------------------------------------------.
1595 | yynewstate -- Push a new state, which is found in yystate. |
1596 `------------------------------------------------------------*/
1597 yynewstate:
1598 /* In all cases, when you get here, the value and location stacks
1599 have just been pushed. so pushing a state here evens the stacks.
1601 yyssp++;
1603 yysetstate:
1604 *yyssp = yystate;
1606 if (yyss + yystacksize - 1 <= yyssp)
1608 /* Get the current used size of the three stacks, in elements. */
1609 YYSIZE_T yysize = yyssp - yyss + 1;
1611 #ifdef yyoverflow
1613 /* Give user a chance to xreallocate the stack. Use copies of
1614 these so that the &'s don't force the real ones into
1615 memory. */
1616 YYSTYPE *yyvs1 = yyvs;
1617 short *yyss1 = yyss;
1620 /* Each stack pointer address is followed by the size of the
1621 data in use in that stack, in bytes. This used to be a
1622 conditional around just the two extra args, but that might
1623 be undefined if yyoverflow is a macro. */
1624 yyoverflow ("parser stack overflow",
1625 &yyss1, yysize * sizeof (*yyssp),
1626 &yyvs1, yysize * sizeof (*yyvsp),
1628 &yystacksize);
1630 yyss = yyss1;
1631 yyvs = yyvs1;
1633 #else /* no yyoverflow */
1634 # ifndef YYSTACK_RELOCATE
1635 goto yyoverflowlab;
1636 # else
1637 /* Extend the stack our own way. */
1638 if (YYMAXDEPTH <= yystacksize)
1639 goto yyoverflowlab;
1640 yystacksize *= 2;
1641 if (YYMAXDEPTH < yystacksize)
1642 yystacksize = YYMAXDEPTH;
1645 short *yyss1 = yyss;
1646 union yyalloc *yyptr =
1647 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1648 if (! yyptr)
1649 goto yyoverflowlab;
1650 YYSTACK_RELOCATE (yyss);
1651 YYSTACK_RELOCATE (yyvs);
1653 # undef YYSTACK_RELOCATE
1654 if (yyss1 != yyssa)
1655 YYSTACK_FREE (yyss1);
1657 # endif
1658 #endif /* no yyoverflow */
1660 yyssp = yyss + yysize - 1;
1661 yyvsp = yyvs + yysize - 1;
1664 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1665 (unsigned long int) yystacksize));
1667 if (yyss + yystacksize - 1 <= yyssp)
1668 YYABORT;
1671 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1673 goto yybackup;
1675 /*-----------.
1676 | yybackup. |
1677 `-----------*/
1678 yybackup:
1680 /* Do appropriate processing given the current state. */
1681 /* Read a lookahead token if we need one and don't already have one. */
1682 /* yyresume: */
1684 /* First try to decide what to do without reference to lookahead token. */
1686 yyn = yypact[yystate];
1687 if (yyn == YYPACT_NINF)
1688 goto yydefault;
1690 /* Not known => get a lookahead token if don't already have one. */
1692 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1693 if (yychar == YYEMPTY)
1695 YYDPRINTF ((stderr, "Reading a token: "));
1696 yychar = YYLEX;
1699 if (yychar <= YYEOF)
1701 yychar = yytoken = YYEOF;
1702 YYDPRINTF ((stderr, "Now at end of input.\n"));
1704 else
1706 yytoken = YYTRANSLATE (yychar);
1707 YYDSYMPRINTF ("Next token is", yytoken, &yylval, &yylloc);
1710 /* If the proper action on seeing token YYTOKEN is to reduce or to
1711 detect an error, take that action. */
1712 yyn += yytoken;
1713 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1714 goto yydefault;
1715 yyn = yytable[yyn];
1716 if (yyn <= 0)
1718 if (yyn == 0 || yyn == YYTABLE_NINF)
1719 goto yyerrlab;
1720 yyn = -yyn;
1721 goto yyreduce;
1724 if (yyn == YYFINAL)
1725 YYACCEPT;
1727 /* Shift the lookahead token. */
1728 YYDPRINTF ((stderr, "Shifting token %s, ", yytname[yytoken]));
1730 /* Discard the token being shifted unless it is eof. */
1731 if (yychar != YYEOF)
1732 yychar = YYEMPTY;
1734 *++yyvsp = yylval;
1737 /* Count tokens shifted since error; after three, turn off error
1738 status. */
1739 if (yyerrstatus)
1740 yyerrstatus--;
1742 yystate = yyn;
1743 goto yynewstate;
1746 /*-----------------------------------------------------------.
1747 | yydefault -- do the default action for the current state. |
1748 `-----------------------------------------------------------*/
1749 yydefault:
1750 yyn = yydefact[yystate];
1751 if (yyn == 0)
1752 goto yyerrlab;
1753 goto yyreduce;
1756 /*-----------------------------.
1757 | yyreduce -- Do a reduction. |
1758 `-----------------------------*/
1759 yyreduce:
1760 /* yyn is the number of a rule to reduce with. */
1761 yylen = yyr2[yyn];
1763 /* If YYLEN is nonzero, implement the default value of the action:
1764 `$$ = $1'.
1766 Otherwise, the following line sets YYVAL to garbage.
1767 This behavior is undocumented and Bison
1768 users should not rely upon it. Assigning to YYVAL
1769 unconditionally makes the parser a bit smaller, and it avoids a
1770 GCC warning that YYVAL may be used uninitialized. */
1771 yyval = yyvsp[1-yylen];
1774 YY_REDUCE_PRINT (yyn);
1775 switch (yyn)
1777 case 2:
1778 #line 343 "cp-name-parser.y"
1779 { global_result = yyvsp[0].comp; }
1780 break;
1782 case 6:
1783 #line 355 "cp-name-parser.y"
1784 { yyval.comp = NULL; }
1785 break;
1787 case 7:
1788 #line 357 "cp-name-parser.y"
1789 { yyval.comp = yyvsp[0].comp; }
1790 break;
1792 case 8:
1793 #line 364 "cp-name-parser.y"
1794 { yyval.comp = yyvsp[0].nested.comp;
1795 *yyvsp[0].nested.last = yyvsp[-1].comp;
1797 break;
1799 case 9:
1800 #line 373 "cp-name-parser.y"
1801 { yyval.comp = fill_comp (DEMANGLE_COMPONENT_TYPED_NAME, yyvsp[-2].comp, yyvsp[-1].nested.comp);
1802 if (yyvsp[0].comp) yyval.comp = fill_comp (DEMANGLE_COMPONENT_LOCAL_NAME, yyval.comp, yyvsp[0].comp); }
1803 break;
1805 case 10:
1806 #line 376 "cp-name-parser.y"
1807 { yyval.comp = fill_comp (DEMANGLE_COMPONENT_TYPED_NAME, yyvsp[-2].comp, yyvsp[-1].nested.comp);
1808 if (yyvsp[0].comp) yyval.comp = fill_comp (DEMANGLE_COMPONENT_LOCAL_NAME, yyval.comp, yyvsp[0].comp); }
1809 break;
1811 case 11:
1812 #line 380 "cp-name-parser.y"
1813 { yyval.comp = yyvsp[-1].nested.comp;
1814 if (yyvsp[0].comp) yyval.comp = fill_comp (DEMANGLE_COMPONENT_LOCAL_NAME, yyval.comp, yyvsp[0].comp); }
1815 break;
1817 case 12:
1818 #line 383 "cp-name-parser.y"
1819 { if (yyvsp[0].abstract.last)
1821 /* First complete the abstract_declarator's type using
1822 the typespec from the conversion_op_name. */
1823 *yyvsp[0].abstract.last = *yyvsp[-1].nested.last;
1824 /* Then complete the conversion_op_name with the type. */
1825 *yyvsp[-1].nested.last = yyvsp[0].abstract.comp;
1827 /* If we have an arglist, build a function type. */
1828 if (yyvsp[0].abstract.fn.comp)
1829 yyval.comp = fill_comp (DEMANGLE_COMPONENT_TYPED_NAME, yyvsp[-1].nested.comp, yyvsp[0].abstract.fn.comp);
1830 else
1831 yyval.comp = yyvsp[-1].nested.comp;
1832 if (yyvsp[0].abstract.start) yyval.comp = fill_comp (DEMANGLE_COMPONENT_LOCAL_NAME, yyval.comp, yyvsp[0].abstract.start);
1834 break;
1836 case 13:
1837 #line 402 "cp-name-parser.y"
1838 { yyval.comp = make_empty (yyvsp[-1].lval);
1839 d_left (yyval.comp) = yyvsp[0].comp;
1840 d_right (yyval.comp) = NULL; }
1841 break;
1843 case 14:
1844 #line 406 "cp-name-parser.y"
1845 { yyval.comp = fill_comp (DEMANGLE_COMPONENT_CONSTRUCTION_VTABLE, yyvsp[-2].comp, yyvsp[0].comp); }
1846 break;
1848 case 15:
1849 #line 408 "cp-name-parser.y"
1850 { yyval.comp = make_empty (yyvsp[0].typed_val_int.val);
1851 d_left (yyval.comp) = yyvsp[0].typed_val_int.type;
1852 d_right (yyval.comp) = NULL; }
1853 break;
1855 case 16:
1856 #line 414 "cp-name-parser.y"
1857 { yyval.comp = make_operator ("new", 1); }
1858 break;
1860 case 17:
1861 #line 416 "cp-name-parser.y"
1862 { yyval.comp = make_operator ("delete", 1); }
1863 break;
1865 case 18:
1866 #line 418 "cp-name-parser.y"
1867 { yyval.comp = make_operator ("new[]", 1); }
1868 break;
1870 case 19:
1871 #line 420 "cp-name-parser.y"
1872 { yyval.comp = make_operator ("delete[]", 1); }
1873 break;
1875 case 20:
1876 #line 422 "cp-name-parser.y"
1877 { yyval.comp = make_operator ("+", 2); }
1878 break;
1880 case 21:
1881 #line 424 "cp-name-parser.y"
1882 { yyval.comp = make_operator ("-", 2); }
1883 break;
1885 case 22:
1886 #line 426 "cp-name-parser.y"
1887 { yyval.comp = make_operator ("*", 2); }
1888 break;
1890 case 23:
1891 #line 428 "cp-name-parser.y"
1892 { yyval.comp = make_operator ("/", 2); }
1893 break;
1895 case 24:
1896 #line 430 "cp-name-parser.y"
1897 { yyval.comp = make_operator ("%", 2); }
1898 break;
1900 case 25:
1901 #line 432 "cp-name-parser.y"
1902 { yyval.comp = make_operator ("^", 2); }
1903 break;
1905 case 26:
1906 #line 434 "cp-name-parser.y"
1907 { yyval.comp = make_operator ("&", 2); }
1908 break;
1910 case 27:
1911 #line 436 "cp-name-parser.y"
1912 { yyval.comp = make_operator ("|", 2); }
1913 break;
1915 case 28:
1916 #line 438 "cp-name-parser.y"
1917 { yyval.comp = make_operator ("~", 1); }
1918 break;
1920 case 29:
1921 #line 440 "cp-name-parser.y"
1922 { yyval.comp = make_operator ("!", 1); }
1923 break;
1925 case 30:
1926 #line 442 "cp-name-parser.y"
1927 { yyval.comp = make_operator ("=", 2); }
1928 break;
1930 case 31:
1931 #line 444 "cp-name-parser.y"
1932 { yyval.comp = make_operator ("<", 2); }
1933 break;
1935 case 32:
1936 #line 446 "cp-name-parser.y"
1937 { yyval.comp = make_operator (">", 2); }
1938 break;
1940 case 33:
1941 #line 448 "cp-name-parser.y"
1942 { yyval.comp = make_operator (yyvsp[0].opname, 2); }
1943 break;
1945 case 34:
1946 #line 450 "cp-name-parser.y"
1947 { yyval.comp = make_operator ("<<", 2); }
1948 break;
1950 case 35:
1951 #line 452 "cp-name-parser.y"
1952 { yyval.comp = make_operator (">>", 2); }
1953 break;
1955 case 36:
1956 #line 454 "cp-name-parser.y"
1957 { yyval.comp = make_operator ("==", 2); }
1958 break;
1960 case 37:
1961 #line 456 "cp-name-parser.y"
1962 { yyval.comp = make_operator ("!=", 2); }
1963 break;
1965 case 38:
1966 #line 458 "cp-name-parser.y"
1967 { yyval.comp = make_operator ("<=", 2); }
1968 break;
1970 case 39:
1971 #line 460 "cp-name-parser.y"
1972 { yyval.comp = make_operator (">=", 2); }
1973 break;
1975 case 40:
1976 #line 462 "cp-name-parser.y"
1977 { yyval.comp = make_operator ("&&", 2); }
1978 break;
1980 case 41:
1981 #line 464 "cp-name-parser.y"
1982 { yyval.comp = make_operator ("||", 2); }
1983 break;
1985 case 42:
1986 #line 466 "cp-name-parser.y"
1987 { yyval.comp = make_operator ("++", 1); }
1988 break;
1990 case 43:
1991 #line 468 "cp-name-parser.y"
1992 { yyval.comp = make_operator ("--", 1); }
1993 break;
1995 case 44:
1996 #line 470 "cp-name-parser.y"
1997 { yyval.comp = make_operator (",", 2); }
1998 break;
2000 case 45:
2001 #line 472 "cp-name-parser.y"
2002 { yyval.comp = make_operator ("->*", 2); }
2003 break;
2005 case 46:
2006 #line 474 "cp-name-parser.y"
2007 { yyval.comp = make_operator ("->", 2); }
2008 break;
2010 case 47:
2011 #line 476 "cp-name-parser.y"
2012 { yyval.comp = make_operator ("()", 0); }
2013 break;
2015 case 48:
2016 #line 478 "cp-name-parser.y"
2017 { yyval.comp = make_operator ("[]", 2); }
2018 break;
2020 case 49:
2021 #line 486 "cp-name-parser.y"
2022 { yyval.comp = fill_comp (DEMANGLE_COMPONENT_CAST, yyvsp[0].comp, NULL); }
2023 break;
2025 case 50:
2026 #line 491 "cp-name-parser.y"
2027 { yyval.nested.comp = yyvsp[-1].nested1.comp;
2028 d_right (yyvsp[-1].nested1.last) = yyvsp[0].comp;
2029 yyval.nested.last = &d_left (yyvsp[0].comp);
2031 break;
2033 case 51:
2034 #line 496 "cp-name-parser.y"
2035 { yyval.nested.comp = yyvsp[0].comp;
2036 yyval.nested.last = &d_left (yyvsp[0].comp);
2038 break;
2040 case 52:
2041 #line 500 "cp-name-parser.y"
2042 { yyval.nested.comp = yyvsp[-1].nested1.comp;
2043 d_right (yyvsp[-1].nested1.last) = yyvsp[0].comp;
2044 yyval.nested.last = &d_left (yyvsp[0].comp);
2046 break;
2048 case 53:
2049 #line 505 "cp-name-parser.y"
2050 { yyval.nested.comp = yyvsp[0].comp;
2051 yyval.nested.last = &d_left (yyvsp[0].comp);
2053 break;
2055 case 55:
2056 #line 514 "cp-name-parser.y"
2057 { yyval.comp = fill_comp (DEMANGLE_COMPONENT_TEMPLATE, yyvsp[-3].comp, yyvsp[-1].nested.comp); }
2058 break;
2060 case 56:
2061 #line 516 "cp-name-parser.y"
2062 { yyval.comp = make_dtor (gnu_v3_complete_object_dtor, yyvsp[0].comp); }
2063 break;
2065 case 58:
2066 #line 529 "cp-name-parser.y"
2067 { yyval.comp = yyvsp[0].comp; }
2068 break;
2070 case 59:
2071 #line 535 "cp-name-parser.y"
2072 { yyval.comp = yyvsp[-1].nested1.comp; d_right (yyvsp[-1].nested1.last) = yyvsp[0].comp; }
2073 break;
2075 case 61:
2076 #line 538 "cp-name-parser.y"
2077 { yyval.comp = yyvsp[-1].nested1.comp; d_right (yyvsp[-1].nested1.last) = yyvsp[0].comp; }
2078 break;
2080 case 66:
2081 #line 548 "cp-name-parser.y"
2082 { yyval.comp = yyvsp[0].comp; }
2083 break;
2085 case 67:
2086 #line 552 "cp-name-parser.y"
2087 { yyval.comp = yyvsp[-1].nested1.comp; d_right (yyvsp[-1].nested1.last) = yyvsp[0].comp; }
2088 break;
2090 case 69:
2091 #line 557 "cp-name-parser.y"
2092 { yyval.nested1.comp = make_empty (DEMANGLE_COMPONENT_QUAL_NAME);
2093 d_left (yyval.nested1.comp) = yyvsp[-1].comp;
2094 d_right (yyval.nested1.comp) = NULL;
2095 yyval.nested1.last = yyval.nested1.comp;
2097 break;
2099 case 70:
2100 #line 563 "cp-name-parser.y"
2101 { yyval.nested1.comp = yyvsp[-2].nested1.comp;
2102 d_right (yyvsp[-2].nested1.last) = make_empty (DEMANGLE_COMPONENT_QUAL_NAME);
2103 yyval.nested1.last = d_right (yyvsp[-2].nested1.last);
2104 d_left (yyval.nested1.last) = yyvsp[-1].comp;
2105 d_right (yyval.nested1.last) = NULL;
2107 break;
2109 case 71:
2110 #line 570 "cp-name-parser.y"
2111 { yyval.nested1.comp = make_empty (DEMANGLE_COMPONENT_QUAL_NAME);
2112 d_left (yyval.nested1.comp) = yyvsp[-1].comp;
2113 d_right (yyval.nested1.comp) = NULL;
2114 yyval.nested1.last = yyval.nested1.comp;
2116 break;
2118 case 72:
2119 #line 576 "cp-name-parser.y"
2120 { yyval.nested1.comp = yyvsp[-2].nested1.comp;
2121 d_right (yyvsp[-2].nested1.last) = make_empty (DEMANGLE_COMPONENT_QUAL_NAME);
2122 yyval.nested1.last = d_right (yyvsp[-2].nested1.last);
2123 d_left (yyval.nested1.last) = yyvsp[-1].comp;
2124 d_right (yyval.nested1.last) = NULL;
2126 break;
2128 case 73:
2129 #line 587 "cp-name-parser.y"
2130 { yyval.comp = fill_comp (DEMANGLE_COMPONENT_TEMPLATE, yyvsp[-3].comp, yyvsp[-1].nested.comp); }
2131 break;
2133 case 74:
2134 #line 591 "cp-name-parser.y"
2135 { yyval.nested.comp = fill_comp (DEMANGLE_COMPONENT_TEMPLATE_ARGLIST, yyvsp[0].comp, NULL);
2136 yyval.nested.last = &d_right (yyval.nested.comp); }
2137 break;
2139 case 75:
2140 #line 594 "cp-name-parser.y"
2141 { yyval.nested.comp = yyvsp[-2].nested.comp;
2142 *yyvsp[-2].nested.last = fill_comp (DEMANGLE_COMPONENT_TEMPLATE_ARGLIST, yyvsp[0].comp, NULL);
2143 yyval.nested.last = &d_right (*yyvsp[-2].nested.last);
2145 break;
2147 case 77:
2148 #line 606 "cp-name-parser.y"
2149 { yyval.comp = yyvsp[0].abstract.comp;
2150 *yyvsp[0].abstract.last = yyvsp[-1].comp;
2152 break;
2154 case 78:
2155 #line 610 "cp-name-parser.y"
2156 { yyval.comp = fill_comp (DEMANGLE_COMPONENT_UNARY, make_operator ("&", 1), yyvsp[0].comp); }
2157 break;
2159 case 79:
2160 #line 612 "cp-name-parser.y"
2161 { yyval.comp = fill_comp (DEMANGLE_COMPONENT_UNARY, make_operator ("&", 1), yyvsp[-1].comp); }
2162 break;
2164 case 81:
2165 #line 617 "cp-name-parser.y"
2166 { yyval.nested.comp = fill_comp (DEMANGLE_COMPONENT_ARGLIST, yyvsp[0].comp, NULL);
2167 yyval.nested.last = &d_right (yyval.nested.comp);
2169 break;
2171 case 82:
2172 #line 621 "cp-name-parser.y"
2173 { *yyvsp[0].abstract.last = yyvsp[-1].comp;
2174 yyval.nested.comp = fill_comp (DEMANGLE_COMPONENT_ARGLIST, yyvsp[0].abstract.comp, NULL);
2175 yyval.nested.last = &d_right (yyval.nested.comp);
2177 break;
2179 case 83:
2180 #line 626 "cp-name-parser.y"
2181 { *yyvsp[-2].nested.last = fill_comp (DEMANGLE_COMPONENT_ARGLIST, yyvsp[0].comp, NULL);
2182 yyval.nested.comp = yyvsp[-2].nested.comp;
2183 yyval.nested.last = &d_right (*yyvsp[-2].nested.last);
2185 break;
2187 case 84:
2188 #line 631 "cp-name-parser.y"
2189 { *yyvsp[0].abstract.last = yyvsp[-1].comp;
2190 *yyvsp[-3].nested.last = fill_comp (DEMANGLE_COMPONENT_ARGLIST, yyvsp[0].abstract.comp, NULL);
2191 yyval.nested.comp = yyvsp[-3].nested.comp;
2192 yyval.nested.last = &d_right (*yyvsp[-3].nested.last);
2194 break;
2196 case 85:
2197 #line 637 "cp-name-parser.y"
2198 { *yyvsp[-2].nested.last
2199 = fill_comp (DEMANGLE_COMPONENT_ARGLIST,
2200 make_builtin_type ("..."),
2201 NULL);
2202 yyval.nested.comp = yyvsp[-2].nested.comp;
2203 yyval.nested.last = &d_right (*yyvsp[-2].nested.last);
2205 break;
2207 case 86:
2208 #line 647 "cp-name-parser.y"
2209 { yyval.nested.comp = fill_comp (DEMANGLE_COMPONENT_FUNCTION_TYPE, NULL, yyvsp[-2].nested.comp);
2210 yyval.nested.last = &d_left (yyval.nested.comp);
2211 yyval.nested.comp = d_qualify (yyval.nested.comp, yyvsp[0].lval, 1); }
2212 break;
2214 case 87:
2215 #line 651 "cp-name-parser.y"
2216 { yyval.nested.comp = fill_comp (DEMANGLE_COMPONENT_FUNCTION_TYPE, NULL, NULL);
2217 yyval.nested.last = &d_left (yyval.nested.comp);
2218 yyval.nested.comp = d_qualify (yyval.nested.comp, yyvsp[0].lval, 1); }
2219 break;
2221 case 88:
2222 #line 655 "cp-name-parser.y"
2223 { yyval.nested.comp = fill_comp (DEMANGLE_COMPONENT_FUNCTION_TYPE, NULL, NULL);
2224 yyval.nested.last = &d_left (yyval.nested.comp);
2225 yyval.nested.comp = d_qualify (yyval.nested.comp, yyvsp[0].lval, 1); }
2226 break;
2228 case 89:
2229 #line 662 "cp-name-parser.y"
2230 { yyval.lval = 0; }
2231 break;
2233 case 91:
2234 #line 667 "cp-name-parser.y"
2235 { yyval.lval = QUAL_RESTRICT; }
2236 break;
2238 case 92:
2239 #line 669 "cp-name-parser.y"
2240 { yyval.lval = QUAL_VOLATILE; }
2241 break;
2243 case 93:
2244 #line 671 "cp-name-parser.y"
2245 { yyval.lval = QUAL_CONST; }
2246 break;
2248 case 95:
2249 #line 676 "cp-name-parser.y"
2250 { yyval.lval = yyvsp[-1].lval | yyvsp[0].lval; }
2251 break;
2253 case 96:
2254 #line 683 "cp-name-parser.y"
2255 { yyval.lval = 0; }
2256 break;
2258 case 97:
2259 #line 685 "cp-name-parser.y"
2260 { yyval.lval = INT_SIGNED; }
2261 break;
2263 case 98:
2264 #line 687 "cp-name-parser.y"
2265 { yyval.lval = INT_UNSIGNED; }
2266 break;
2268 case 99:
2269 #line 689 "cp-name-parser.y"
2270 { yyval.lval = INT_CHAR; }
2271 break;
2273 case 100:
2274 #line 691 "cp-name-parser.y"
2275 { yyval.lval = INT_LONG; }
2276 break;
2278 case 101:
2279 #line 693 "cp-name-parser.y"
2280 { yyval.lval = INT_SHORT; }
2281 break;
2283 case 103:
2284 #line 698 "cp-name-parser.y"
2285 { yyval.lval = yyvsp[-1].lval | yyvsp[0].lval; if (yyvsp[-1].lval & yyvsp[0].lval & INT_LONG) yyval.lval = yyvsp[-1].lval | INT_LLONG; }
2286 break;
2288 case 104:
2289 #line 702 "cp-name-parser.y"
2290 { yyval.comp = d_int_type (yyvsp[0].lval); }
2291 break;
2293 case 105:
2294 #line 704 "cp-name-parser.y"
2295 { yyval.comp = make_builtin_type ("float"); }
2296 break;
2298 case 106:
2299 #line 706 "cp-name-parser.y"
2300 { yyval.comp = make_builtin_type ("double"); }
2301 break;
2303 case 107:
2304 #line 708 "cp-name-parser.y"
2305 { yyval.comp = make_builtin_type ("long double"); }
2306 break;
2308 case 108:
2309 #line 710 "cp-name-parser.y"
2310 { yyval.comp = make_builtin_type ("bool"); }
2311 break;
2313 case 109:
2314 #line 712 "cp-name-parser.y"
2315 { yyval.comp = make_builtin_type ("wchar_t"); }
2316 break;
2318 case 110:
2319 #line 714 "cp-name-parser.y"
2320 { yyval.comp = make_builtin_type ("void"); }
2321 break;
2323 case 111:
2324 #line 718 "cp-name-parser.y"
2325 { yyval.nested.comp = make_empty (DEMANGLE_COMPONENT_POINTER);
2326 yyval.nested.comp->u.s_binary.left = yyval.nested.comp->u.s_binary.right = NULL;
2327 yyval.nested.last = &d_left (yyval.nested.comp);
2328 yyval.nested.comp = d_qualify (yyval.nested.comp, yyvsp[0].lval, 0); }
2329 break;
2331 case 112:
2332 #line 724 "cp-name-parser.y"
2333 { yyval.nested.comp = make_empty (DEMANGLE_COMPONENT_REFERENCE);
2334 yyval.nested.comp->u.s_binary.left = yyval.nested.comp->u.s_binary.right = NULL;
2335 yyval.nested.last = &d_left (yyval.nested.comp); }
2336 break;
2338 case 113:
2339 #line 728 "cp-name-parser.y"
2340 { yyval.nested.comp = make_empty (DEMANGLE_COMPONENT_PTRMEM_TYPE);
2341 yyval.nested.comp->u.s_binary.left = yyvsp[-2].nested1.comp;
2342 /* Convert the innermost DEMANGLE_COMPONENT_QUAL_NAME to a DEMANGLE_COMPONENT_NAME. */
2343 *yyvsp[-2].nested1.last = *d_left (yyvsp[-2].nested1.last);
2344 yyval.nested.comp->u.s_binary.right = NULL;
2345 yyval.nested.last = &d_right (yyval.nested.comp);
2346 yyval.nested.comp = d_qualify (yyval.nested.comp, yyvsp[0].lval, 0); }
2347 break;
2349 case 114:
2350 #line 736 "cp-name-parser.y"
2351 { yyval.nested.comp = make_empty (DEMANGLE_COMPONENT_PTRMEM_TYPE);
2352 yyval.nested.comp->u.s_binary.left = yyvsp[-2].nested1.comp;
2353 /* Convert the innermost DEMANGLE_COMPONENT_QUAL_NAME to a DEMANGLE_COMPONENT_NAME. */
2354 *yyvsp[-2].nested1.last = *d_left (yyvsp[-2].nested1.last);
2355 yyval.nested.comp->u.s_binary.right = NULL;
2356 yyval.nested.last = &d_right (yyval.nested.comp);
2357 yyval.nested.comp = d_qualify (yyval.nested.comp, yyvsp[0].lval, 0); }
2358 break;
2360 case 115:
2361 #line 746 "cp-name-parser.y"
2362 { yyval.comp = make_empty (DEMANGLE_COMPONENT_ARRAY_TYPE);
2363 d_left (yyval.comp) = NULL;
2365 break;
2367 case 116:
2368 #line 750 "cp-name-parser.y"
2369 { yyval.comp = make_empty (DEMANGLE_COMPONENT_ARRAY_TYPE);
2370 d_left (yyval.comp) = yyvsp[-1].comp;
2372 break;
2374 case 117:
2375 #line 766 "cp-name-parser.y"
2376 { yyval.comp = d_qualify (yyvsp[-1].comp, yyvsp[0].lval, 0); }
2377 break;
2379 case 119:
2380 #line 769 "cp-name-parser.y"
2381 { yyval.comp = d_qualify (yyvsp[-1].comp, yyvsp[-2].lval | yyvsp[0].lval, 0); }
2382 break;
2384 case 120:
2385 #line 771 "cp-name-parser.y"
2386 { yyval.comp = d_qualify (yyvsp[0].comp, yyvsp[-1].lval, 0); }
2387 break;
2389 case 121:
2390 #line 774 "cp-name-parser.y"
2391 { yyval.comp = d_qualify (yyvsp[-1].comp, yyvsp[0].lval, 0); }
2392 break;
2394 case 123:
2395 #line 777 "cp-name-parser.y"
2396 { yyval.comp = d_qualify (yyvsp[-1].comp, yyvsp[-2].lval | yyvsp[0].lval, 0); }
2397 break;
2399 case 124:
2400 #line 779 "cp-name-parser.y"
2401 { yyval.comp = d_qualify (yyvsp[0].comp, yyvsp[-1].lval, 0); }
2402 break;
2404 case 125:
2405 #line 782 "cp-name-parser.y"
2406 { yyval.comp = d_qualify (yyvsp[-1].comp, yyvsp[0].lval, 0); }
2407 break;
2409 case 126:
2410 #line 784 "cp-name-parser.y"
2411 { yyval.comp = yyvsp[0].comp; }
2412 break;
2414 case 127:
2415 #line 786 "cp-name-parser.y"
2416 { yyval.comp = d_qualify (yyvsp[-1].comp, yyvsp[-3].lval | yyvsp[0].lval, 0); }
2417 break;
2419 case 128:
2420 #line 788 "cp-name-parser.y"
2421 { yyval.comp = d_qualify (yyvsp[0].comp, yyvsp[-2].lval, 0); }
2422 break;
2424 case 129:
2425 #line 793 "cp-name-parser.y"
2426 { yyval.abstract.comp = yyvsp[0].nested.comp; yyval.abstract.last = yyvsp[0].nested.last;
2427 yyval.abstract.fn.comp = NULL; yyval.abstract.fn.last = NULL; }
2428 break;
2430 case 130:
2431 #line 796 "cp-name-parser.y"
2432 { yyval.abstract = yyvsp[0].abstract; yyval.abstract.fn.comp = NULL; yyval.abstract.fn.last = NULL;
2433 if (yyvsp[0].abstract.fn.comp) { yyval.abstract.last = yyvsp[0].abstract.fn.last; *yyvsp[0].abstract.last = yyvsp[0].abstract.fn.comp; }
2434 *yyval.abstract.last = yyvsp[-1].nested.comp;
2435 yyval.abstract.last = yyvsp[-1].nested.last; }
2436 break;
2438 case 131:
2439 #line 801 "cp-name-parser.y"
2440 { yyval.abstract.fn.comp = NULL; yyval.abstract.fn.last = NULL;
2441 if (yyvsp[0].abstract.fn.comp) { yyval.abstract.last = yyvsp[0].abstract.fn.last; *yyvsp[0].abstract.last = yyvsp[0].abstract.fn.comp; }
2443 break;
2445 case 132:
2446 #line 808 "cp-name-parser.y"
2447 { yyval.abstract = yyvsp[-1].abstract; yyval.abstract.fn.comp = NULL; yyval.abstract.fn.last = NULL; yyval.abstract.fold_flag = 1;
2448 if (yyvsp[-1].abstract.fn.comp) { yyval.abstract.last = yyvsp[-1].abstract.fn.last; *yyvsp[-1].abstract.last = yyvsp[-1].abstract.fn.comp; }
2450 break;
2452 case 133:
2453 #line 812 "cp-name-parser.y"
2454 { yyval.abstract.fold_flag = 0;
2455 if (yyvsp[-1].abstract.fn.comp) { yyval.abstract.last = yyvsp[-1].abstract.fn.last; *yyvsp[-1].abstract.last = yyvsp[-1].abstract.fn.comp; }
2456 if (yyvsp[-1].abstract.fold_flag)
2458 *yyval.abstract.last = yyvsp[0].nested.comp;
2459 yyval.abstract.last = yyvsp[0].nested.last;
2461 else
2462 yyval.abstract.fn = yyvsp[0].nested;
2464 break;
2466 case 134:
2467 #line 823 "cp-name-parser.y"
2468 { yyval.abstract.fn.comp = NULL; yyval.abstract.fn.last = NULL; yyval.abstract.fold_flag = 0;
2469 if (yyvsp[-1].abstract.fn.comp) { yyval.abstract.last = yyvsp[-1].abstract.fn.last; *yyvsp[-1].abstract.last = yyvsp[-1].abstract.fn.comp; }
2470 *yyvsp[-1].abstract.last = yyvsp[0].comp;
2471 yyval.abstract.last = &d_right (yyvsp[0].comp);
2473 break;
2475 case 135:
2476 #line 829 "cp-name-parser.y"
2477 { yyval.abstract.fn.comp = NULL; yyval.abstract.fn.last = NULL; yyval.abstract.fold_flag = 0;
2478 yyval.abstract.comp = yyvsp[0].comp;
2479 yyval.abstract.last = &d_right (yyvsp[0].comp);
2481 break;
2483 case 136:
2484 #line 847 "cp-name-parser.y"
2485 { yyval.abstract.comp = yyvsp[0].nested.comp; yyval.abstract.last = yyvsp[0].nested.last;
2486 yyval.abstract.fn.comp = NULL; yyval.abstract.fn.last = NULL; yyval.abstract.start = NULL; }
2487 break;
2489 case 137:
2490 #line 850 "cp-name-parser.y"
2491 { yyval.abstract = yyvsp[0].abstract;
2492 if (yyvsp[0].abstract.last)
2493 *yyval.abstract.last = yyvsp[-1].nested.comp;
2494 else
2495 yyval.abstract.comp = yyvsp[-1].nested.comp;
2496 yyval.abstract.last = yyvsp[-1].nested.last;
2498 break;
2500 case 138:
2501 #line 858 "cp-name-parser.y"
2502 { yyval.abstract.comp = yyvsp[0].abstract.comp; yyval.abstract.last = yyvsp[0].abstract.last; yyval.abstract.fn = yyvsp[0].abstract.fn; yyval.abstract.start = NULL; }
2503 break;
2505 case 139:
2506 #line 860 "cp-name-parser.y"
2507 { yyval.abstract.start = yyvsp[0].comp;
2508 if (yyvsp[-3].abstract.fn.comp) { yyval.abstract.last = yyvsp[-3].abstract.fn.last; *yyvsp[-3].abstract.last = yyvsp[-3].abstract.fn.comp; }
2509 if (yyvsp[-3].abstract.fold_flag)
2511 *yyval.abstract.last = yyvsp[-2].nested.comp;
2512 yyval.abstract.last = yyvsp[-2].nested.last;
2514 else
2515 yyval.abstract.fn = yyvsp[-2].nested;
2517 break;
2519 case 140:
2520 #line 871 "cp-name-parser.y"
2521 { yyval.abstract.fn = yyvsp[-1].nested;
2522 yyval.abstract.start = yyvsp[0].comp;
2523 yyval.abstract.comp = NULL; yyval.abstract.last = NULL;
2525 break;
2527 case 142:
2528 #line 879 "cp-name-parser.y"
2529 { yyval.comp = yyvsp[0].abstract.comp;
2530 *yyvsp[0].abstract.last = yyvsp[-1].comp;
2532 break;
2534 case 143:
2535 #line 885 "cp-name-parser.y"
2536 { yyval.nested.comp = yyvsp[0].nested.comp;
2537 yyval.nested.last = yyvsp[-1].nested.last;
2538 *yyvsp[0].nested.last = yyvsp[-1].nested.comp; }
2539 break;
2541 case 145:
2542 #line 893 "cp-name-parser.y"
2543 { yyval.nested = yyvsp[-1].nested; }
2544 break;
2546 case 146:
2547 #line 895 "cp-name-parser.y"
2548 { yyval.nested.comp = yyvsp[-1].nested.comp;
2549 *yyvsp[-1].nested.last = yyvsp[0].nested.comp;
2550 yyval.nested.last = yyvsp[0].nested.last;
2552 break;
2554 case 147:
2555 #line 900 "cp-name-parser.y"
2556 { yyval.nested.comp = yyvsp[-1].nested.comp;
2557 *yyvsp[-1].nested.last = yyvsp[0].comp;
2558 yyval.nested.last = &d_right (yyvsp[0].comp);
2560 break;
2562 case 148:
2563 #line 905 "cp-name-parser.y"
2564 { yyval.nested.comp = make_empty (DEMANGLE_COMPONENT_TYPED_NAME);
2565 d_left (yyval.nested.comp) = yyvsp[0].comp;
2566 yyval.nested.last = &d_right (yyval.nested.comp);
2568 break;
2570 case 149:
2571 #line 918 "cp-name-parser.y"
2572 { yyval.nested.comp = yyvsp[0].nested.comp;
2573 yyval.nested.last = yyvsp[-1].nested.last;
2574 *yyvsp[0].nested.last = yyvsp[-1].nested.comp; }
2575 break;
2577 case 150:
2578 #line 922 "cp-name-parser.y"
2579 { yyval.nested.comp = make_empty (DEMANGLE_COMPONENT_TYPED_NAME);
2580 d_left (yyval.nested.comp) = yyvsp[0].comp;
2581 yyval.nested.last = &d_right (yyval.nested.comp);
2583 break;
2585 case 152:
2586 #line 935 "cp-name-parser.y"
2587 { yyval.nested.comp = fill_comp (DEMANGLE_COMPONENT_TYPED_NAME, yyvsp[-3].comp, yyvsp[-2].nested.comp);
2588 yyval.nested.last = yyvsp[-2].nested.last;
2589 yyval.nested.comp = fill_comp (DEMANGLE_COMPONENT_LOCAL_NAME, yyval.nested.comp, yyvsp[0].comp);
2591 break;
2593 case 153:
2594 #line 940 "cp-name-parser.y"
2595 { yyval.nested.comp = yyvsp[-3].nested.comp;
2596 *yyvsp[-3].nested.last = yyvsp[-2].nested.comp;
2597 yyval.nested.last = yyvsp[-2].nested.last;
2598 yyval.nested.comp = fill_comp (DEMANGLE_COMPONENT_LOCAL_NAME, yyval.nested.comp, yyvsp[0].comp);
2600 break;
2602 case 154:
2603 #line 949 "cp-name-parser.y"
2604 { yyval.nested.comp = yyvsp[-1].nested.comp;
2605 yyval.nested.last = yyvsp[-2].nested.last;
2606 *yyvsp[-1].nested.last = yyvsp[-2].nested.comp; }
2607 break;
2609 case 155:
2610 #line 953 "cp-name-parser.y"
2611 { yyval.nested.comp = yyvsp[-1].nested.comp;
2612 *yyvsp[-1].nested.last = yyvsp[0].nested.comp;
2613 yyval.nested.last = yyvsp[0].nested.last;
2615 break;
2617 case 156:
2618 #line 958 "cp-name-parser.y"
2619 { yyval.nested.comp = yyvsp[-1].nested.comp;
2620 *yyvsp[-1].nested.last = yyvsp[0].comp;
2621 yyval.nested.last = &d_right (yyvsp[0].comp);
2623 break;
2625 case 157:
2626 #line 963 "cp-name-parser.y"
2627 { yyval.nested.comp = fill_comp (DEMANGLE_COMPONENT_TYPED_NAME, yyvsp[-1].comp, yyvsp[0].nested.comp);
2628 yyval.nested.last = yyvsp[0].nested.last;
2630 break;
2632 case 158:
2633 #line 967 "cp-name-parser.y"
2634 { yyval.nested.comp = fill_comp (DEMANGLE_COMPONENT_TYPED_NAME, yyvsp[-1].comp, yyvsp[0].comp);
2635 yyval.nested.last = &d_right (yyvsp[0].comp);
2637 break;
2639 case 159:
2640 #line 973 "cp-name-parser.y"
2641 { yyval.comp = yyvsp[-1].comp; }
2642 break;
2644 case 161:
2645 #line 982 "cp-name-parser.y"
2646 { yyval.comp = d_binary (">", yyvsp[-2].comp, yyvsp[0].comp); }
2647 break;
2649 case 162:
2650 #line 989 "cp-name-parser.y"
2651 { yyval.comp = fill_comp (DEMANGLE_COMPONENT_UNARY, make_operator ("&", 1), yyvsp[0].comp); }
2652 break;
2654 case 163:
2655 #line 994 "cp-name-parser.y"
2656 { yyval.comp = d_unary ("-", yyvsp[0].comp); }
2657 break;
2659 case 164:
2660 #line 998 "cp-name-parser.y"
2661 { yyval.comp = d_unary ("!", yyvsp[0].comp); }
2662 break;
2664 case 165:
2665 #line 1002 "cp-name-parser.y"
2666 { yyval.comp = d_unary ("~", yyvsp[0].comp); }
2667 break;
2669 case 166:
2670 #line 1009 "cp-name-parser.y"
2671 { if (yyvsp[0].comp->type == DEMANGLE_COMPONENT_LITERAL
2672 || yyvsp[0].comp->type == DEMANGLE_COMPONENT_LITERAL_NEG)
2674 yyval.comp = yyvsp[0].comp;
2675 d_left (yyvsp[0].comp) = yyvsp[-2].comp;
2677 else
2678 yyval.comp = fill_comp (DEMANGLE_COMPONENT_UNARY,
2679 fill_comp (DEMANGLE_COMPONENT_CAST, yyvsp[-2].comp, NULL),
2680 yyvsp[0].comp);
2682 break;
2684 case 167:
2685 #line 1025 "cp-name-parser.y"
2686 { yyval.comp = fill_comp (DEMANGLE_COMPONENT_UNARY,
2687 fill_comp (DEMANGLE_COMPONENT_CAST, yyvsp[-4].comp, NULL),
2688 yyvsp[-1].comp);
2690 break;
2692 case 168:
2693 #line 1032 "cp-name-parser.y"
2694 { yyval.comp = fill_comp (DEMANGLE_COMPONENT_UNARY,
2695 fill_comp (DEMANGLE_COMPONENT_CAST, yyvsp[-4].comp, NULL),
2696 yyvsp[-1].comp);
2698 break;
2700 case 169:
2701 #line 1039 "cp-name-parser.y"
2702 { yyval.comp = fill_comp (DEMANGLE_COMPONENT_UNARY,
2703 fill_comp (DEMANGLE_COMPONENT_CAST, yyvsp[-4].comp, NULL),
2704 yyvsp[-1].comp);
2706 break;
2708 case 170:
2709 #line 1052 "cp-name-parser.y"
2710 { yyval.comp = fill_comp (DEMANGLE_COMPONENT_UNARY,
2711 fill_comp (DEMANGLE_COMPONENT_CAST, yyvsp[-3].comp, NULL),
2712 yyvsp[-1].comp);
2714 break;
2716 case 171:
2717 #line 1063 "cp-name-parser.y"
2718 { yyval.comp = d_binary ("*", yyvsp[-2].comp, yyvsp[0].comp); }
2719 break;
2721 case 172:
2722 #line 1067 "cp-name-parser.y"
2723 { yyval.comp = d_binary ("/", yyvsp[-2].comp, yyvsp[0].comp); }
2724 break;
2726 case 173:
2727 #line 1071 "cp-name-parser.y"
2728 { yyval.comp = d_binary ("%", yyvsp[-2].comp, yyvsp[0].comp); }
2729 break;
2731 case 174:
2732 #line 1075 "cp-name-parser.y"
2733 { yyval.comp = d_binary ("+", yyvsp[-2].comp, yyvsp[0].comp); }
2734 break;
2736 case 175:
2737 #line 1079 "cp-name-parser.y"
2738 { yyval.comp = d_binary ("-", yyvsp[-2].comp, yyvsp[0].comp); }
2739 break;
2741 case 176:
2742 #line 1083 "cp-name-parser.y"
2743 { yyval.comp = d_binary ("<<", yyvsp[-2].comp, yyvsp[0].comp); }
2744 break;
2746 case 177:
2747 #line 1087 "cp-name-parser.y"
2748 { yyval.comp = d_binary (">>", yyvsp[-2].comp, yyvsp[0].comp); }
2749 break;
2751 case 178:
2752 #line 1091 "cp-name-parser.y"
2753 { yyval.comp = d_binary ("==", yyvsp[-2].comp, yyvsp[0].comp); }
2754 break;
2756 case 179:
2757 #line 1095 "cp-name-parser.y"
2758 { yyval.comp = d_binary ("!=", yyvsp[-2].comp, yyvsp[0].comp); }
2759 break;
2761 case 180:
2762 #line 1099 "cp-name-parser.y"
2763 { yyval.comp = d_binary ("<=", yyvsp[-2].comp, yyvsp[0].comp); }
2764 break;
2766 case 181:
2767 #line 1103 "cp-name-parser.y"
2768 { yyval.comp = d_binary (">=", yyvsp[-2].comp, yyvsp[0].comp); }
2769 break;
2771 case 182:
2772 #line 1107 "cp-name-parser.y"
2773 { yyval.comp = d_binary ("<", yyvsp[-2].comp, yyvsp[0].comp); }
2774 break;
2776 case 183:
2777 #line 1111 "cp-name-parser.y"
2778 { yyval.comp = d_binary ("&", yyvsp[-2].comp, yyvsp[0].comp); }
2779 break;
2781 case 184:
2782 #line 1115 "cp-name-parser.y"
2783 { yyval.comp = d_binary ("^", yyvsp[-2].comp, yyvsp[0].comp); }
2784 break;
2786 case 185:
2787 #line 1119 "cp-name-parser.y"
2788 { yyval.comp = d_binary ("|", yyvsp[-2].comp, yyvsp[0].comp); }
2789 break;
2791 case 186:
2792 #line 1123 "cp-name-parser.y"
2793 { yyval.comp = d_binary ("&&", yyvsp[-2].comp, yyvsp[0].comp); }
2794 break;
2796 case 187:
2797 #line 1127 "cp-name-parser.y"
2798 { yyval.comp = d_binary ("||", yyvsp[-2].comp, yyvsp[0].comp); }
2799 break;
2801 case 188:
2802 #line 1132 "cp-name-parser.y"
2803 { yyval.comp = d_binary ("->", yyvsp[-2].comp, yyvsp[0].comp); }
2804 break;
2806 case 189:
2807 #line 1136 "cp-name-parser.y"
2808 { yyval.comp = d_binary (".", yyvsp[-2].comp, yyvsp[0].comp); }
2809 break;
2811 case 190:
2812 #line 1140 "cp-name-parser.y"
2813 { yyval.comp = fill_comp (DEMANGLE_COMPONENT_TRINARY, make_operator ("?", 3),
2814 fill_comp (DEMANGLE_COMPONENT_TRINARY_ARG1, yyvsp[-4].comp,
2815 fill_comp (DEMANGLE_COMPONENT_TRINARY_ARG2, yyvsp[-2].comp, yyvsp[0].comp)));
2817 break;
2819 case 193:
2820 #line 1154 "cp-name-parser.y"
2821 { yyval.comp = d_unary ("sizeof", yyvsp[-1].comp); }
2822 break;
2824 case 194:
2825 #line 1159 "cp-name-parser.y"
2826 { struct demangle_component *i;
2827 i = make_name ("1", 1);
2828 yyval.comp = fill_comp (DEMANGLE_COMPONENT_LITERAL,
2829 make_builtin_type ("bool"),
2832 break;
2834 case 195:
2835 #line 1168 "cp-name-parser.y"
2836 { struct demangle_component *i;
2837 i = make_name ("0", 1);
2838 yyval.comp = fill_comp (DEMANGLE_COMPONENT_LITERAL,
2839 make_builtin_type ("bool"),
2842 break;
2847 /* Line 1000 of yacc.c. */
2848 #line 2849 "cp-name-parser.c.tmp"
2850 yyvsp -= yylen;
2851 yyssp -= yylen;
2854 YY_STACK_PRINT (yyss, yyssp);
2856 *++yyvsp = yyval;
2859 /* Now `shift' the result of the reduction. Determine what state
2860 that goes to, based on the state we popped back to and the rule
2861 number reduced by. */
2863 yyn = yyr1[yyn];
2865 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
2866 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
2867 yystate = yytable[yystate];
2868 else
2869 yystate = yydefgoto[yyn - YYNTOKENS];
2871 goto yynewstate;
2874 /*------------------------------------.
2875 | yyerrlab -- here on detecting error |
2876 `------------------------------------*/
2877 yyerrlab:
2878 /* If not already recovering from an error, report this error. */
2879 if (!yyerrstatus)
2881 ++yynerrs;
2882 #if YYERROR_VERBOSE
2883 yyn = yypact[yystate];
2885 if (YYPACT_NINF < yyn && yyn < YYLAST)
2887 YYSIZE_T yysize = 0;
2888 int yytype = YYTRANSLATE (yychar);
2889 const char* yyprefix;
2890 char *yymsg;
2891 int yyx;
2893 /* Start YYX at -YYN if negative to avoid negative indexes in
2894 YYCHECK. */
2895 int yyxbegin = yyn < 0 ? -yyn : 0;
2897 /* Stay within bounds of both yycheck and yytname. */
2898 int yychecklim = YYLAST - yyn;
2899 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
2900 int yycount = 0;
2902 yyprefix = ", expecting ";
2903 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
2904 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
2906 yysize += yystrlen (yyprefix) + yystrlen (yytname [yyx]);
2907 yycount += 1;
2908 if (yycount == 5)
2910 yysize = 0;
2911 break;
2914 yysize += (sizeof ("syntax error, unexpected ")
2915 + yystrlen (yytname[yytype]));
2916 yymsg = (char *) YYSTACK_ALLOC (yysize);
2917 if (yymsg != 0)
2919 char *yyp = yystpcpy (yymsg, "syntax error, unexpected ");
2920 yyp = yystpcpy (yyp, yytname[yytype]);
2922 if (yycount < 5)
2924 yyprefix = ", expecting ";
2925 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
2926 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
2928 yyp = yystpcpy (yyp, yyprefix);
2929 yyp = yystpcpy (yyp, yytname[yyx]);
2930 yyprefix = " or ";
2933 yyerror (yymsg);
2934 YYSTACK_FREE (yymsg);
2936 else
2937 yyerror ("syntax error; also virtual memory exhausted");
2939 else
2940 #endif /* YYERROR_VERBOSE */
2941 yyerror ("syntax error");
2946 if (yyerrstatus == 3)
2948 /* If just tried and failed to reuse lookahead token after an
2949 error, discard it. */
2951 if (yychar <= YYEOF)
2953 /* If at end of input, pop the error token,
2954 then the rest of the stack, then return failure. */
2955 if (yychar == YYEOF)
2956 for (;;)
2958 YYPOPSTACK;
2959 if (yyssp == yyss)
2960 YYABORT;
2961 YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
2962 yydestruct (yystos[*yyssp], yyvsp);
2965 else
2967 YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc);
2968 yydestruct (yytoken, &yylval);
2969 yychar = YYEMPTY;
2974 /* Else will try to reuse lookahead token after shifting the error
2975 token. */
2976 goto yyerrlab1;
2979 /*---------------------------------------------------.
2980 | yyerrorlab -- error raised explicitly by YYERROR. |
2981 `---------------------------------------------------*/
2982 yyerrorlab:
2984 #ifdef __GNUC__
2985 /* Pacify GCC when the user code never invokes YYERROR and the label
2986 yyerrorlab therefore never appears in user code. */
2987 if (0)
2988 goto yyerrorlab;
2989 #endif
2991 yyvsp -= yylen;
2992 yyssp -= yylen;
2993 yystate = *yyssp;
2994 goto yyerrlab1;
2997 /*-------------------------------------------------------------.
2998 | yyerrlab1 -- common code for both syntax error and YYERROR. |
2999 `-------------------------------------------------------------*/
3000 yyerrlab1:
3001 yyerrstatus = 3; /* Each real token shifted decrements this. */
3003 for (;;)
3005 yyn = yypact[yystate];
3006 if (yyn != YYPACT_NINF)
3008 yyn += YYTERROR;
3009 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
3011 yyn = yytable[yyn];
3012 if (0 < yyn)
3013 break;
3017 /* Pop the current state because it cannot handle the error token. */
3018 if (yyssp == yyss)
3019 YYABORT;
3021 YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
3022 yydestruct (yystos[yystate], yyvsp);
3023 YYPOPSTACK;
3024 yystate = *yyssp;
3025 YY_STACK_PRINT (yyss, yyssp);
3028 if (yyn == YYFINAL)
3029 YYACCEPT;
3031 YYDPRINTF ((stderr, "Shifting error token, "));
3033 *++yyvsp = yylval;
3036 yystate = yyn;
3037 goto yynewstate;
3040 /*-------------------------------------.
3041 | yyacceptlab -- YYACCEPT comes here. |
3042 `-------------------------------------*/
3043 yyacceptlab:
3044 yyresult = 0;
3045 goto yyreturn;
3047 /*-----------------------------------.
3048 | yyabortlab -- YYABORT comes here. |
3049 `-----------------------------------*/
3050 yyabortlab:
3051 yyresult = 1;
3052 goto yyreturn;
3054 #ifndef yyoverflow
3055 /*----------------------------------------------.
3056 | yyoverflowlab -- parser overflow comes here. |
3057 `----------------------------------------------*/
3058 yyoverflowlab:
3059 yyerror ("parser stack overflow");
3060 yyresult = 2;
3061 /* Fall through. */
3062 #endif
3064 yyreturn:
3065 #ifndef yyoverflow
3066 if (yyss != yyssa)
3067 YYSTACK_FREE (yyss);
3068 #endif
3069 return yyresult;
3073 #line 1178 "cp-name-parser.y"
3076 /* Apply QUALIFIERS to LHS and return a qualified component. IS_METHOD
3077 is set if LHS is a method, in which case the qualifiers are logically
3078 applied to "this". We apply qualifiers in a consistent order; LHS
3079 may already be qualified; duplicate qualifiers are not created. */
3081 struct demangle_component *
3082 d_qualify (struct demangle_component *lhs, int qualifiers, int is_method)
3084 struct demangle_component **inner_p;
3085 enum demangle_component_type type;
3087 /* For now the order is CONST (innermost), VOLATILE, RESTRICT. */
3089 #define HANDLE_QUAL(TYPE, MTYPE, QUAL) \
3090 if ((qualifiers & QUAL) && (type != TYPE) && (type != MTYPE)) \
3092 *inner_p = fill_comp (is_method ? MTYPE : TYPE, \
3093 *inner_p, NULL); \
3094 inner_p = &d_left (*inner_p); \
3095 type = (*inner_p)->type; \
3097 else if (type == TYPE || type == MTYPE) \
3099 inner_p = &d_left (*inner_p); \
3100 type = (*inner_p)->type; \
3103 inner_p = &lhs;
3105 type = (*inner_p)->type;
3107 HANDLE_QUAL (DEMANGLE_COMPONENT_RESTRICT, DEMANGLE_COMPONENT_RESTRICT_THIS, QUAL_RESTRICT);
3108 HANDLE_QUAL (DEMANGLE_COMPONENT_VOLATILE, DEMANGLE_COMPONENT_VOLATILE_THIS, QUAL_VOLATILE);
3109 HANDLE_QUAL (DEMANGLE_COMPONENT_CONST, DEMANGLE_COMPONENT_CONST_THIS, QUAL_CONST);
3111 return lhs;
3114 /* Return a builtin type corresponding to FLAGS. */
3116 static struct demangle_component *
3117 d_int_type (int flags)
3119 const char *name;
3121 switch (flags)
3123 case INT_SIGNED | INT_CHAR:
3124 name = "signed char";
3125 break;
3126 case INT_CHAR:
3127 name = "char";
3128 break;
3129 case INT_UNSIGNED | INT_CHAR:
3130 name = "unsigned char";
3131 break;
3132 case 0:
3133 case INT_SIGNED:
3134 name = "int";
3135 break;
3136 case INT_UNSIGNED:
3137 name = "unsigned int";
3138 break;
3139 case INT_LONG:
3140 case INT_SIGNED | INT_LONG:
3141 name = "long";
3142 break;
3143 case INT_UNSIGNED | INT_LONG:
3144 name = "unsigned long";
3145 break;
3146 case INT_SHORT:
3147 case INT_SIGNED | INT_SHORT:
3148 name = "short";
3149 break;
3150 case INT_UNSIGNED | INT_SHORT:
3151 name = "unsigned short";
3152 break;
3153 case INT_LLONG | INT_LONG:
3154 case INT_SIGNED | INT_LLONG | INT_LONG:
3155 name = "long long";
3156 break;
3157 case INT_UNSIGNED | INT_LLONG | INT_LONG:
3158 name = "unsigned long long";
3159 break;
3160 default:
3161 return NULL;
3164 return make_builtin_type (name);
3167 /* Wrapper to create a unary operation. */
3169 static struct demangle_component *
3170 d_unary (const char *name, struct demangle_component *lhs)
3172 return fill_comp (DEMANGLE_COMPONENT_UNARY, make_operator (name, 1), lhs);
3175 /* Wrapper to create a binary operation. */
3177 static struct demangle_component *
3178 d_binary (const char *name, struct demangle_component *lhs, struct demangle_component *rhs)
3180 return fill_comp (DEMANGLE_COMPONENT_BINARY, make_operator (name, 2),
3181 fill_comp (DEMANGLE_COMPONENT_BINARY_ARGS, lhs, rhs));
3184 /* Find the end of a symbol name starting at LEXPTR. */
3186 static const char *
3187 symbol_end (const char *lexptr)
3189 const char *p = lexptr;
3191 while (*p && (ISALNUM (*p) || *p == '_' || *p == '$' || *p == '.'))
3192 p++;
3194 return p;
3197 /* Take care of parsing a number (anything that starts with a digit).
3198 The number starts at P and contains LEN characters. Store the result in
3199 YYLVAL. */
3201 static int
3202 parse_number (const char *p, int len, int parsed_float)
3204 int unsigned_p = 0;
3206 /* Number of "L" suffixes encountered. */
3207 int long_p = 0;
3209 struct demangle_component *signed_type;
3210 struct demangle_component *unsigned_type;
3211 struct demangle_component *type, *name;
3212 enum demangle_component_type literal_type;
3214 if (p[0] == '-')
3216 literal_type = DEMANGLE_COMPONENT_LITERAL_NEG;
3217 p++;
3218 len--;
3220 else
3221 literal_type = DEMANGLE_COMPONENT_LITERAL;
3223 if (parsed_float)
3225 /* It's a float since it contains a point or an exponent. */
3226 char c;
3228 /* The GDB lexer checks the result of scanf at this point. Not doing
3229 this leaves our error checking slightly weaker but only for invalid
3230 data. */
3232 /* See if it has `f' or `l' suffix (float or long double). */
3234 c = TOLOWER (p[len - 1]);
3236 if (c == 'f')
3238 len--;
3239 type = make_builtin_type ("float");
3241 else if (c == 'l')
3243 len--;
3244 type = make_builtin_type ("long double");
3246 else if (ISDIGIT (c) || c == '.')
3247 type = make_builtin_type ("double");
3248 else
3249 return ERROR;
3251 name = make_name (p, len);
3252 yylval.comp = fill_comp (literal_type, type, name);
3254 return FLOAT;
3257 /* This treats 0x1 and 1 as different literals. We also do not
3258 automatically generate unsigned types. */
3260 long_p = 0;
3261 unsigned_p = 0;
3262 while (len > 0)
3264 if (p[len - 1] == 'l' || p[len - 1] == 'L')
3266 len--;
3267 long_p++;
3268 continue;
3270 if (p[len - 1] == 'u' || p[len - 1] == 'U')
3272 len--;
3273 unsigned_p++;
3274 continue;
3276 break;
3279 if (long_p == 0)
3281 unsigned_type = make_builtin_type ("unsigned int");
3282 signed_type = make_builtin_type ("int");
3284 else if (long_p == 1)
3286 unsigned_type = make_builtin_type ("unsigned long");
3287 signed_type = make_builtin_type ("long");
3289 else
3291 unsigned_type = make_builtin_type ("unsigned long long");
3292 signed_type = make_builtin_type ("long long");
3295 if (unsigned_p)
3296 type = unsigned_type;
3297 else
3298 type = signed_type;
3300 name = make_name (p, len);
3301 yylval.comp = fill_comp (literal_type, type, name);
3303 return INT;
3306 static char backslashable[] = "abefnrtv";
3307 static char represented[] = "\a\b\e\f\n\r\t\v";
3309 /* Translate the backslash the way we would in the host character set. */
3310 static int
3311 c_parse_backslash (int host_char, int *target_char)
3313 const char *ix;
3314 ix = strchr (backslashable, host_char);
3315 if (! ix)
3316 return 0;
3317 else
3318 *target_char = represented[ix - backslashable];
3319 return 1;
3322 /* Parse a C escape sequence. STRING_PTR points to a variable
3323 containing a pointer to the string to parse. That pointer
3324 should point to the character after the \. That pointer
3325 is updated past the characters we use. The value of the
3326 escape sequence is returned.
3328 A negative value means the sequence \ newline was seen,
3329 which is supposed to be equivalent to nothing at all.
3331 If \ is followed by a null character, we return a negative
3332 value and leave the string pointer pointing at the null character.
3334 If \ is followed by 000, we return 0 and leave the string pointer
3335 after the zeros. A value of 0 does not mean end of string. */
3337 static int
3338 parse_escape (const char **string_ptr)
3340 int target_char;
3341 int c = *(*string_ptr)++;
3342 if (c_parse_backslash (c, &target_char))
3343 return target_char;
3344 else
3345 switch (c)
3347 case '\n':
3348 return -2;
3349 case 0:
3350 (*string_ptr)--;
3351 return 0;
3352 case '^':
3354 c = *(*string_ptr)++;
3356 if (c == '?')
3357 return 0177;
3358 else if (c == '\\')
3359 target_char = parse_escape (string_ptr);
3360 else
3361 target_char = c;
3363 /* Now target_char is something like `c', and we want to find
3364 its control-character equivalent. */
3365 target_char = target_char & 037;
3367 return target_char;
3370 case '0':
3371 case '1':
3372 case '2':
3373 case '3':
3374 case '4':
3375 case '5':
3376 case '6':
3377 case '7':
3379 int i = c - '0';
3380 int count = 0;
3381 while (++count < 3)
3383 c = (**string_ptr);
3384 if (c >= '0' && c <= '7')
3386 (*string_ptr)++;
3387 i *= 8;
3388 i += c - '0';
3390 else
3392 break;
3395 return i;
3397 default:
3398 return c;
3402 #define HANDLE_SPECIAL(string, comp) \
3403 if (strncmp (tokstart, string, sizeof (string) - 1) == 0) \
3405 lexptr = tokstart + sizeof (string) - 1; \
3406 yylval.lval = comp; \
3407 return DEMANGLER_SPECIAL; \
3410 #define HANDLE_TOKEN2(string, token) \
3411 if (lexptr[1] == string[1]) \
3413 lexptr += 2; \
3414 yylval.opname = string; \
3415 return token; \
3418 #define HANDLE_TOKEN3(string, token) \
3419 if (lexptr[1] == string[1] && lexptr[2] == string[2]) \
3421 lexptr += 3; \
3422 yylval.opname = string; \
3423 return token; \
3426 /* Read one token, getting characters through LEXPTR. */
3428 static int
3429 yylex (void)
3431 int c;
3432 int namelen;
3433 const char *tokstart, *tokptr;
3435 retry:
3436 prev_lexptr = lexptr;
3437 tokstart = lexptr;
3439 switch (c = *tokstart)
3441 case 0:
3442 return 0;
3444 case ' ':
3445 case '\t':
3446 case '\n':
3447 lexptr++;
3448 goto retry;
3450 case '\'':
3451 /* We either have a character constant ('0' or '\177' for example)
3452 or we have a quoted symbol reference ('foo(int,int)' in C++
3453 for example). */
3454 lexptr++;
3455 c = *lexptr++;
3456 if (c == '\\')
3457 c = parse_escape (&lexptr);
3458 else if (c == '\'')
3460 yyerror ("empty character constant");
3461 return ERROR;
3464 c = *lexptr++;
3465 if (c != '\'')
3467 yyerror ("invalid character constant");
3468 return ERROR;
3471 /* FIXME: We should refer to a canonical form of the character,
3472 presumably the same one that appears in manglings - the decimal
3473 representation. But if that isn't in our input then we have to
3474 allocate memory for it somewhere. */
3475 yylval.comp = fill_comp (DEMANGLE_COMPONENT_LITERAL,
3476 make_builtin_type ("char"),
3477 make_name (tokstart, lexptr - tokstart));
3479 return INT;
3481 case '(':
3482 if (strncmp (tokstart, "(anonymous namespace)", 21) == 0)
3484 lexptr += 21;
3485 yylval.comp = make_name ("(anonymous namespace)",
3486 sizeof "(anonymous namespace)" - 1);
3487 return NAME;
3489 /* FALL THROUGH */
3491 case ')':
3492 case ',':
3493 lexptr++;
3494 return c;
3496 case '.':
3497 if (lexptr[1] == '.' && lexptr[2] == '.')
3499 lexptr += 3;
3500 return ELLIPSIS;
3503 /* Might be a floating point number. */
3504 if (lexptr[1] < '0' || lexptr[1] > '9')
3505 goto symbol; /* Nope, must be a symbol. */
3507 goto try_number;
3509 case '-':
3510 HANDLE_TOKEN2 ("-=", ASSIGN_MODIFY);
3511 HANDLE_TOKEN2 ("--", DECREMENT);
3512 HANDLE_TOKEN2 ("->", ARROW);
3514 /* For construction vtables. This is kind of hokey. */
3515 if (strncmp (tokstart, "-in-", 4) == 0)
3517 lexptr += 4;
3518 return CONSTRUCTION_IN;
3521 if (lexptr[1] < '0' || lexptr[1] > '9')
3523 lexptr++;
3524 return '-';
3526 /* FALL THRU into number case. */
3528 try_number:
3529 case '0':
3530 case '1':
3531 case '2':
3532 case '3':
3533 case '4':
3534 case '5':
3535 case '6':
3536 case '7':
3537 case '8':
3538 case '9':
3540 /* It's a number. */
3541 int got_dot = 0, got_e = 0, toktype;
3542 const char *p = tokstart;
3543 int hex = 0;
3545 if (c == '-')
3546 p++;
3548 if (c == '0' && (p[1] == 'x' || p[1] == 'X'))
3550 p += 2;
3551 hex = 1;
3553 else if (c == '0' && (p[1]=='t' || p[1]=='T' || p[1]=='d' || p[1]=='D'))
3555 p += 2;
3556 hex = 0;
3559 for (;; ++p)
3561 /* This test includes !hex because 'e' is a valid hex digit
3562 and thus does not indicate a floating point number when
3563 the radix is hex. */
3564 if (!hex && !got_e && (*p == 'e' || *p == 'E'))
3565 got_dot = got_e = 1;
3566 /* This test does not include !hex, because a '.' always indicates
3567 a decimal floating point number regardless of the radix.
3569 NOTE drow/2005-03-09: This comment is not accurate in C99;
3570 however, it's not clear that all the floating point support
3571 in this file is doing any good here. */
3572 else if (!got_dot && *p == '.')
3573 got_dot = 1;
3574 else if (got_e && (p[-1] == 'e' || p[-1] == 'E')
3575 && (*p == '-' || *p == '+'))
3576 /* This is the sign of the exponent, not the end of the
3577 number. */
3578 continue;
3579 /* We will take any letters or digits. parse_number will
3580 complain if past the radix, or if L or U are not final. */
3581 else if (! ISALNUM (*p))
3582 break;
3584 toktype = parse_number (tokstart, p - tokstart, got_dot|got_e);
3585 if (toktype == ERROR)
3587 char *err_copy = (char *) alloca (p - tokstart + 1);
3589 memcpy (err_copy, tokstart, p - tokstart);
3590 err_copy[p - tokstart] = 0;
3591 yyerror ("invalid number");
3592 return ERROR;
3594 lexptr = p;
3595 return toktype;
3598 case '+':
3599 HANDLE_TOKEN2 ("+=", ASSIGN_MODIFY);
3600 HANDLE_TOKEN2 ("++", INCREMENT);
3601 lexptr++;
3602 return c;
3603 case '*':
3604 HANDLE_TOKEN2 ("*=", ASSIGN_MODIFY);
3605 lexptr++;
3606 return c;
3607 case '/':
3608 HANDLE_TOKEN2 ("/=", ASSIGN_MODIFY);
3609 lexptr++;
3610 return c;
3611 case '%':
3612 HANDLE_TOKEN2 ("%=", ASSIGN_MODIFY);
3613 lexptr++;
3614 return c;
3615 case '|':
3616 HANDLE_TOKEN2 ("|=", ASSIGN_MODIFY);
3617 HANDLE_TOKEN2 ("||", OROR);
3618 lexptr++;
3619 return c;
3620 case '&':
3621 HANDLE_TOKEN2 ("&=", ASSIGN_MODIFY);
3622 HANDLE_TOKEN2 ("&&", ANDAND);
3623 lexptr++;
3624 return c;
3625 case '^':
3626 HANDLE_TOKEN2 ("^=", ASSIGN_MODIFY);
3627 lexptr++;
3628 return c;
3629 case '!':
3630 HANDLE_TOKEN2 ("!=", NOTEQUAL);
3631 lexptr++;
3632 return c;
3633 case '<':
3634 HANDLE_TOKEN3 ("<<=", ASSIGN_MODIFY);
3635 HANDLE_TOKEN2 ("<=", LEQ);
3636 HANDLE_TOKEN2 ("<<", LSH);
3637 lexptr++;
3638 return c;
3639 case '>':
3640 HANDLE_TOKEN3 (">>=", ASSIGN_MODIFY);
3641 HANDLE_TOKEN2 (">=", GEQ);
3642 HANDLE_TOKEN2 (">>", RSH);
3643 lexptr++;
3644 return c;
3645 case '=':
3646 HANDLE_TOKEN2 ("==", EQUAL);
3647 lexptr++;
3648 return c;
3649 case ':':
3650 HANDLE_TOKEN2 ("::", COLONCOLON);
3651 lexptr++;
3652 return c;
3654 case '[':
3655 case ']':
3656 case '?':
3657 case '@':
3658 case '~':
3659 case '{':
3660 case '}':
3661 symbol:
3662 lexptr++;
3663 return c;
3665 case '"':
3666 /* These can't occur in C++ names. */
3667 yyerror ("unexpected string literal");
3668 return ERROR;
3671 if (!(c == '_' || c == '$' || ISALPHA (c)))
3673 /* We must have come across a bad character (e.g. ';'). */
3674 yyerror ("invalid character");
3675 return ERROR;
3678 /* It's a name. See how long it is. */
3679 namelen = 0;
3681 c = tokstart[++namelen];
3682 while (ISALNUM (c) || c == '_' || c == '$');
3684 lexptr += namelen;
3686 /* Catch specific keywords. Notice that some of the keywords contain
3687 spaces, and are sorted by the length of the first word. They must
3688 all include a trailing space in the string comparison. */
3689 switch (namelen)
3691 case 16:
3692 if (strncmp (tokstart, "reinterpret_cast", 16) == 0)
3693 return REINTERPRET_CAST;
3694 break;
3695 case 12:
3696 if (strncmp (tokstart, "construction vtable for ", 24) == 0)
3698 lexptr = tokstart + 24;
3699 return CONSTRUCTION_VTABLE;
3701 if (strncmp (tokstart, "dynamic_cast", 12) == 0)
3702 return DYNAMIC_CAST;
3703 break;
3704 case 11:
3705 if (strncmp (tokstart, "static_cast", 11) == 0)
3706 return STATIC_CAST;
3707 break;
3708 case 9:
3709 HANDLE_SPECIAL ("covariant return thunk to ", DEMANGLE_COMPONENT_COVARIANT_THUNK);
3710 HANDLE_SPECIAL ("reference temporary for ", DEMANGLE_COMPONENT_REFTEMP);
3711 break;
3712 case 8:
3713 HANDLE_SPECIAL ("typeinfo for ", DEMANGLE_COMPONENT_TYPEINFO);
3714 HANDLE_SPECIAL ("typeinfo fn for ", DEMANGLE_COMPONENT_TYPEINFO_FN);
3715 HANDLE_SPECIAL ("typeinfo name for ", DEMANGLE_COMPONENT_TYPEINFO_NAME);
3716 if (strncmp (tokstart, "operator", 8) == 0)
3717 return OPERATOR;
3718 if (strncmp (tokstart, "restrict", 8) == 0)
3719 return RESTRICT;
3720 if (strncmp (tokstart, "unsigned", 8) == 0)
3721 return UNSIGNED;
3722 if (strncmp (tokstart, "template", 8) == 0)
3723 return TEMPLATE;
3724 if (strncmp (tokstart, "volatile", 8) == 0)
3725 return VOLATILE_KEYWORD;
3726 break;
3727 case 7:
3728 HANDLE_SPECIAL ("virtual thunk to ", DEMANGLE_COMPONENT_VIRTUAL_THUNK);
3729 if (strncmp (tokstart, "wchar_t", 7) == 0)
3730 return WCHAR_T;
3731 break;
3732 case 6:
3733 if (strncmp (tokstart, "global constructors keyed to ", 29) == 0)
3735 const char *p;
3736 lexptr = tokstart + 29;
3737 yylval.typed_val_int.val = GLOBAL_CONSTRUCTORS;
3738 /* Find the end of the symbol. */
3739 p = symbol_end (lexptr);
3740 yylval.typed_val_int.type = make_name (lexptr, p - lexptr);
3741 lexptr = p;
3742 return GLOBAL;
3744 if (strncmp (tokstart, "global destructors keyed to ", 28) == 0)
3746 const char *p;
3747 lexptr = tokstart + 28;
3748 yylval.typed_val_int.val = GLOBAL_DESTRUCTORS;
3749 /* Find the end of the symbol. */
3750 p = symbol_end (lexptr);
3751 yylval.typed_val_int.type = make_name (lexptr, p - lexptr);
3752 lexptr = p;
3753 return GLOBAL;
3756 HANDLE_SPECIAL ("vtable for ", DEMANGLE_COMPONENT_VTABLE);
3757 if (strncmp (tokstart, "delete", 6) == 0)
3758 return DELETE;
3759 if (strncmp (tokstart, "struct", 6) == 0)
3760 return STRUCT;
3761 if (strncmp (tokstart, "signed", 6) == 0)
3762 return SIGNED_KEYWORD;
3763 if (strncmp (tokstart, "sizeof", 6) == 0)
3764 return SIZEOF;
3765 if (strncmp (tokstart, "double", 6) == 0)
3766 return DOUBLE_KEYWORD;
3767 break;
3768 case 5:
3769 HANDLE_SPECIAL ("guard variable for ", DEMANGLE_COMPONENT_GUARD);
3770 if (strncmp (tokstart, "false", 5) == 0)
3771 return FALSEKEYWORD;
3772 if (strncmp (tokstart, "class", 5) == 0)
3773 return CLASS;
3774 if (strncmp (tokstart, "union", 5) == 0)
3775 return UNION;
3776 if (strncmp (tokstart, "float", 5) == 0)
3777 return FLOAT_KEYWORD;
3778 if (strncmp (tokstart, "short", 5) == 0)
3779 return SHORT;
3780 if (strncmp (tokstart, "const", 5) == 0)
3781 return CONST_KEYWORD;
3782 break;
3783 case 4:
3784 if (strncmp (tokstart, "void", 4) == 0)
3785 return VOID;
3786 if (strncmp (tokstart, "bool", 4) == 0)
3787 return BOOL;
3788 if (strncmp (tokstart, "char", 4) == 0)
3789 return CHAR;
3790 if (strncmp (tokstart, "enum", 4) == 0)
3791 return ENUM;
3792 if (strncmp (tokstart, "long", 4) == 0)
3793 return LONG;
3794 if (strncmp (tokstart, "true", 4) == 0)
3795 return TRUEKEYWORD;
3796 break;
3797 case 3:
3798 HANDLE_SPECIAL ("VTT for ", DEMANGLE_COMPONENT_VTT);
3799 HANDLE_SPECIAL ("non-virtual thunk to ", DEMANGLE_COMPONENT_THUNK);
3800 if (strncmp (tokstart, "new", 3) == 0)
3801 return NEW;
3802 if (strncmp (tokstart, "int", 3) == 0)
3803 return INT_KEYWORD;
3804 break;
3805 default:
3806 break;
3809 yylval.comp = make_name (tokstart, namelen);
3810 return NAME;
3813 static void
3814 yyerror (char *msg)
3816 if (global_errmsg)
3817 return;
3819 error_lexptr = prev_lexptr;
3820 global_errmsg = msg ? msg : "parse error";
3823 /* Allocate all the components we'll need to build a tree. We generally
3824 allocate too many components, but the extra memory usage doesn't hurt
3825 because the trees are temporary. If we start keeping the trees for
3826 a longer lifetime we'll need to be cleverer. */
3827 static struct demangle_info *
3828 allocate_info (int comps)
3830 struct demangle_info *ret;
3832 ret = xmalloc (sizeof (struct demangle_info)
3833 + sizeof (struct demangle_component) * (comps - 1));
3834 ret->used = 0;
3835 return ret;
3838 /* Convert RESULT to a string. The return value is allocated
3839 using xmalloc. ESTIMATED_LEN is used only as a guide to the
3840 length of the result. This functions handles a few cases that
3841 cplus_demangle_print does not, specifically the global destructor
3842 and constructor labels. */
3844 char *
3845 cp_comp_to_string (struct demangle_component *result, int estimated_len)
3847 char *str, *prefix = NULL, *buf;
3848 size_t err = 0;
3850 if (result->type == GLOBAL_DESTRUCTORS)
3852 result = d_left (result);
3853 prefix = "global destructors keyed to ";
3855 else if (result->type == GLOBAL_CONSTRUCTORS)
3857 result = d_left (result);
3858 prefix = "global constructors keyed to ";
3861 str = cplus_demangle_print (DMGL_PARAMS | DMGL_ANSI, result, estimated_len, &err);
3862 if (str == NULL)
3863 return NULL;
3865 if (prefix == NULL)
3866 return str;
3868 buf = xmalloc (strlen (str) + strlen (prefix) + 1);
3869 strcpy (buf, prefix);
3870 strcat (buf, str);
3871 free (str);
3872 return (buf);
3875 /* Convert a demangled name to a demangle_component tree. *MEMORY is set to the
3876 block of used memory that should be freed when finished with the
3877 tree. On error, NULL is returned, and an error message will be
3878 set in *ERRMSG (which does not need to be freed). */
3880 struct demangle_component *
3881 cp_demangled_name_to_comp (const char *demangled_name, void **memory,
3882 const char **errmsg)
3884 static char errbuf[60];
3885 struct demangle_component *result;
3887 int len = strlen (demangled_name);
3889 len = len + len / 8;
3890 prev_lexptr = lexptr = demangled_name;
3891 error_lexptr = NULL;
3892 global_errmsg = NULL;
3894 demangle_info = allocate_info (len);
3896 if (yyparse ())
3898 if (global_errmsg && errmsg)
3900 snprintf (errbuf, sizeof (errbuf) - 2, "%s, near `%s",
3901 global_errmsg, error_lexptr);
3902 strcat (errbuf, "'");
3903 *errmsg = errbuf;
3905 free (demangle_info);
3906 return NULL;
3909 *memory = demangle_info;
3910 result = global_result;
3911 global_result = NULL;
3913 return result;
3916 #ifdef TEST_CPNAMES
3918 static void
3919 cp_print (struct demangle_component *result)
3921 char *str;
3922 size_t err = 0;
3924 if (result->type == GLOBAL_DESTRUCTORS)
3926 result = d_left (result);
3927 fputs ("global destructors keyed to ", stdout);
3929 else if (result->type == GLOBAL_CONSTRUCTORS)
3931 result = d_left (result);
3932 fputs ("global constructors keyed to ", stdout);
3935 str = cplus_demangle_print (DMGL_PARAMS | DMGL_ANSI, result, 64, &err);
3936 if (str == NULL)
3937 return;
3939 fputs (str, stdout);
3941 free (str);
3944 static char
3945 trim_chars (char *lexptr, char **extra_chars)
3947 char *p = (char *) symbol_end (lexptr);
3948 char c = 0;
3950 if (*p)
3952 c = *p;
3953 *p = 0;
3954 *extra_chars = p + 1;
3957 return c;
3961 main (int argc, char **argv)
3963 char *str2, *extra_chars, c;
3964 char buf[65536];
3965 int arg;
3966 const char *errmsg;
3967 void *memory;
3968 struct demangle_component *result;
3970 arg = 1;
3971 if (argv[arg] && strcmp (argv[arg], "--debug") == 0)
3973 yydebug = 1;
3974 arg++;
3977 if (argv[arg] == NULL)
3978 while (fgets (buf, 65536, stdin) != NULL)
3980 int len;
3981 buf[strlen (buf) - 1] = 0;
3982 /* Use DMGL_VERBOSE to get expanded standard substitutions. */
3983 c = trim_chars (buf, &extra_chars);
3984 str2 = cplus_demangle (buf, DMGL_PARAMS | DMGL_ANSI | DMGL_VERBOSE);
3985 if (str2 == NULL)
3987 /* printf ("Demangling error\n"); */
3988 if (c)
3989 printf ("%s%c%s\n", buf, c, extra_chars);
3990 else
3991 printf ("%s\n", buf);
3992 continue;
3994 result = cp_demangled_name_to_comp (str2, &memory, &errmsg);
3995 if (result == NULL)
3997 fputs (errmsg, stderr);
3998 fputc ('\n', stderr);
3999 continue;
4002 cp_print (result);
4003 free (memory);
4005 free (str2);
4006 if (c)
4008 putchar (c);
4009 fputs (extra_chars, stdout);
4011 putchar ('\n');
4013 else
4015 result = cp_demangled_name_to_comp (argv[arg], &memory, &errmsg);
4016 if (result == NULL)
4018 fputs (errmsg, stderr);
4019 fputc ('\n', stderr);
4020 return 0;
4022 cp_print (result);
4023 putchar ('\n');
4024 free (memory);
4026 return 0;
4029 #endif