OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gdb-7.1/] [gdb/] [cp-name-parser.c] - Blame information for rev 853

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.