packaging: Add python3-base dependency
[platform/upstream/gdb.git] / gdb / p-exp.c
1 /* A Bison parser, made by GNU Bison 3.8.2.  */
2
3 /* Bison implementation for Yacc-like parsers in C
4
5    Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2021 Free Software Foundation,
6    Inc.
7
8    This program is free software: you can redistribute it and/or modify
9    it under the terms of the GNU General Public License as published by
10    the Free Software Foundation, either version 3 of the License, or
11    (at your option) any later version.
12
13    This program is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16    GNU General Public License for more details.
17
18    You should have received a copy of the GNU General Public License
19    along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
20
21 /* As a special exception, you may create a larger work that contains
22    part or all of the Bison parser skeleton and distribute that work
23    under terms of your choice, so long as that work isn't itself a
24    parser generator using the skeleton or a modified version thereof
25    as a parser skeleton.  Alternatively, if you modify or redistribute
26    the parser skeleton itself, you may (at your option) remove this
27    special exception, which will cause the skeleton and the resulting
28    Bison output files to be licensed under the GNU General Public
29    License without this special exception.
30
31    This special exception was added by the Free Software Foundation in
32    version 2.2 of Bison.  */
33
34 /* C LALR(1) parser skeleton written by Richard Stallman, by
35    simplifying the original so-called "semantic" parser.  */
36
37 /* DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual,
38    especially those whose name start with YY_ or yy_.  They are
39    private implementation details that can be changed or removed.  */
40
41 /* All symbols defined below should begin with yy or YY, to avoid
42    infringing on user name space.  This should be done even for local
43    variables, as they might otherwise be expanded by user macros.
44    There are some unavoidable exceptions within include files to
45    define necessary library symbols; they are noted "INFRINGES ON
46    USER NAME SPACE" below.  */
47
48 /* Identify Bison output, and Bison version.  */
49 #define YYBISON 30802
50
51 /* Bison version string.  */
52 #define YYBISON_VERSION "3.8.2"
53
54 /* Skeleton name.  */
55 #define YYSKELETON_NAME "yacc.c"
56
57 /* Pure parsers.  */
58 #define YYPURE 0
59
60 /* Push parsers.  */
61 #define YYPUSH 0
62
63 /* Pull parsers.  */
64 #define YYPULL 1
65
66
67
68
69 /* First part of user prologue.  */
70 #line 44 "p-exp.y"
71
72
73 #include "defs.h"
74 #include <ctype.h>
75 #include "expression.h"
76 #include "value.h"
77 #include "parser-defs.h"
78 #include "language.h"
79 #include "p-lang.h"
80 #include "bfd.h" /* Required by objfiles.h.  */
81 #include "symfile.h" /* Required by objfiles.h.  */
82 #include "objfiles.h" /* For have_full_symbols and have_partial_symbols.  */
83 #include "block.h"
84 #include "completer.h"
85 #include "expop.h"
86
87 #define parse_type(ps) builtin_type (ps->gdbarch ())
88
89 /* Remap normal yacc parser interface names (yyparse, yylex, yyerror,
90    etc).  */
91 #define GDB_YY_REMAP_PREFIX pascal_
92 #include "yy-remap.h"
93
94 /* The state of the parser, used internally when we are parsing the
95    expression.  */
96
97 static struct parser_state *pstate = NULL;
98
99 /* Depth of parentheses.  */
100 static int paren_depth;
101
102 int yyparse (void);
103
104 static int yylex (void);
105
106 static void yyerror (const char *);
107
108 static char *uptok (const char *, int);
109
110 using namespace expr;
111
112 #line 113 "p-exp.c.tmp"
113
114 # ifndef YY_CAST
115 #  ifdef __cplusplus
116 #   define YY_CAST(Type, Val) static_cast<Type> (Val)
117 #   define YY_REINTERPRET_CAST(Type, Val) reinterpret_cast<Type> (Val)
118 #  else
119 #   define YY_CAST(Type, Val) ((Type) (Val))
120 #   define YY_REINTERPRET_CAST(Type, Val) ((Type) (Val))
121 #  endif
122 # endif
123 # ifndef YY_NULLPTRPTR
124 #  if defined __cplusplus
125 #   if 201103L <= __cplusplus
126 #    define YY_NULLPTRPTR nullptr
127 #   else
128 #    define YY_NULLPTRPTR 0
129 #   endif
130 #  else
131 #   define YY_NULLPTRPTR ((void*)0)
132 #  endif
133 # endif
134
135
136 /* Debug traces.  */
137 #ifndef YYDEBUG
138 # define YYDEBUG 0
139 #endif
140 #if YYDEBUG
141 extern int yydebug;
142 #endif
143
144 /* Token kinds.  */
145 #ifndef YYTOKENTYPE
146 # define YYTOKENTYPE
147   enum yytokentype
148   {
149     YYEMPTY = -2,
150     YYEOF = 0,                     /* "end of file"  */
151     YYerror = 256,                 /* error  */
152     YYUNDEF = 257,                 /* "invalid token"  */
153     INT = 258,                     /* INT  */
154     FLOAT = 259,                   /* FLOAT  */
155     STRING = 260,                  /* STRING  */
156     FIELDNAME = 261,               /* FIELDNAME  */
157     COMPLETE = 262,                /* COMPLETE  */
158     NAME = 263,                    /* NAME  */
159     TYPENAME = 264,                /* TYPENAME  */
160     NAME_OR_INT = 265,             /* NAME_OR_INT  */
161     STRUCT = 266,                  /* STRUCT  */
162     CLASS = 267,                   /* CLASS  */
163     SIZEOF = 268,                  /* SIZEOF  */
164     COLONCOLON = 269,              /* COLONCOLON  */
165     ERROR = 270,                   /* ERROR  */
166     DOLLAR_VARIABLE = 271,         /* DOLLAR_VARIABLE  */
167     THIS = 272,                    /* THIS  */
168     TRUEKEYWORD = 273,             /* TRUEKEYWORD  */
169     FALSEKEYWORD = 274,            /* FALSEKEYWORD  */
170     ABOVE_COMMA = 275,             /* ABOVE_COMMA  */
171     ASSIGN = 276,                  /* ASSIGN  */
172     NOT = 277,                     /* NOT  */
173     OR = 278,                      /* OR  */
174     XOR = 279,                     /* XOR  */
175     ANDAND = 280,                  /* ANDAND  */
176     NOTEQUAL = 281,                /* NOTEQUAL  */
177     LEQ = 282,                     /* LEQ  */
178     GEQ = 283,                     /* GEQ  */
179     LSH = 284,                     /* LSH  */
180     RSH = 285,                     /* RSH  */
181     DIV = 286,                     /* DIV  */
182     MOD = 287,                     /* MOD  */
183     UNARY = 288,                   /* UNARY  */
184     INCREMENT = 289,               /* INCREMENT  */
185     DECREMENT = 290,               /* DECREMENT  */
186     ARROW = 291,                   /* ARROW  */
187     BLOCKNAME = 292                /* BLOCKNAME  */
188   };
189   typedef enum yytokentype yytoken_kind_t;
190 #endif
191 /* Token kinds.  */
192 #define YYEMPTY -2
193 #define YYEOF 0
194 #define YYerror 256
195 #define YYUNDEF 257
196 #define INT 258
197 #define FLOAT 259
198 #define STRING 260
199 #define FIELDNAME 261
200 #define COMPLETE 262
201 #define NAME 263
202 #define TYPENAME 264
203 #define NAME_OR_INT 265
204 #define STRUCT 266
205 #define CLASS 267
206 #define SIZEOF 268
207 #define COLONCOLON 269
208 #define ERROR 270
209 #define DOLLAR_VARIABLE 271
210 #define THIS 272
211 #define TRUEKEYWORD 273
212 #define FALSEKEYWORD 274
213 #define ABOVE_COMMA 275
214 #define ASSIGN 276
215 #define NOT 277
216 #define OR 278
217 #define XOR 279
218 #define ANDAND 280
219 #define NOTEQUAL 281
220 #define LEQ 282
221 #define GEQ 283
222 #define LSH 284
223 #define RSH 285
224 #define DIV 286
225 #define MOD 287
226 #define UNARY 288
227 #define INCREMENT 289
228 #define DECREMENT 290
229 #define ARROW 291
230 #define BLOCKNAME 292
231
232 /* Value type.  */
233 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
234 union YYSTYPE
235 {
236 #line 91 "p-exp.y"
237
238     LONGEST lval;
239     struct {
240       LONGEST val;
241       struct type *type;
242     } typed_val_int;
243     struct {
244       gdb_byte val[16];
245       struct type *type;
246     } typed_val_float;
247     struct symbol *sym;
248     struct type *tval;
249     struct stoken sval;
250     struct ttype tsym;
251     struct symtoken ssym;
252     int voidval;
253     const struct block *bval;
254     enum exp_opcode opcode;
255     struct internalvar *ivar;
256
257     struct type **tvec;
258     int *ivec;
259   
260
261 #line 262 "p-exp.c.tmp"
262
263 };
264 typedef union YYSTYPE YYSTYPE;
265 # define YYSTYPE_IS_TRIVIAL 1
266 # define YYSTYPE_IS_DECLARED 1
267 #endif
268
269
270 extern YYSTYPE yylval;
271
272
273 int yyparse (void);
274
275
276
277 /* Symbol kind.  */
278 enum yysymbol_kind_t
279 {
280   YYSYMBOL_YYEMPTY = -2,
281   YYSYMBOL_YYEOF = 0,                      /* "end of file"  */
282   YYSYMBOL_YYerror = 1,                    /* error  */
283   YYSYMBOL_YYUNDEF = 2,                    /* "invalid token"  */
284   YYSYMBOL_INT = 3,                        /* INT  */
285   YYSYMBOL_FLOAT = 4,                      /* FLOAT  */
286   YYSYMBOL_STRING = 5,                     /* STRING  */
287   YYSYMBOL_FIELDNAME = 6,                  /* FIELDNAME  */
288   YYSYMBOL_COMPLETE = 7,                   /* COMPLETE  */
289   YYSYMBOL_NAME = 8,                       /* NAME  */
290   YYSYMBOL_TYPENAME = 9,                   /* TYPENAME  */
291   YYSYMBOL_NAME_OR_INT = 10,               /* NAME_OR_INT  */
292   YYSYMBOL_STRUCT = 11,                    /* STRUCT  */
293   YYSYMBOL_CLASS = 12,                     /* CLASS  */
294   YYSYMBOL_SIZEOF = 13,                    /* SIZEOF  */
295   YYSYMBOL_COLONCOLON = 14,                /* COLONCOLON  */
296   YYSYMBOL_ERROR = 15,                     /* ERROR  */
297   YYSYMBOL_DOLLAR_VARIABLE = 16,           /* DOLLAR_VARIABLE  */
298   YYSYMBOL_THIS = 17,                      /* THIS  */
299   YYSYMBOL_TRUEKEYWORD = 18,               /* TRUEKEYWORD  */
300   YYSYMBOL_FALSEKEYWORD = 19,              /* FALSEKEYWORD  */
301   YYSYMBOL_20_ = 20,                       /* ','  */
302   YYSYMBOL_ABOVE_COMMA = 21,               /* ABOVE_COMMA  */
303   YYSYMBOL_ASSIGN = 22,                    /* ASSIGN  */
304   YYSYMBOL_NOT = 23,                       /* NOT  */
305   YYSYMBOL_OR = 24,                        /* OR  */
306   YYSYMBOL_XOR = 25,                       /* XOR  */
307   YYSYMBOL_ANDAND = 26,                    /* ANDAND  */
308   YYSYMBOL_27_ = 27,                       /* '='  */
309   YYSYMBOL_NOTEQUAL = 28,                  /* NOTEQUAL  */
310   YYSYMBOL_29_ = 29,                       /* '<'  */
311   YYSYMBOL_30_ = 30,                       /* '>'  */
312   YYSYMBOL_LEQ = 31,                       /* LEQ  */
313   YYSYMBOL_GEQ = 32,                       /* GEQ  */
314   YYSYMBOL_LSH = 33,                       /* LSH  */
315   YYSYMBOL_RSH = 34,                       /* RSH  */
316   YYSYMBOL_DIV = 35,                       /* DIV  */
317   YYSYMBOL_MOD = 36,                       /* MOD  */
318   YYSYMBOL_37_ = 37,                       /* '@'  */
319   YYSYMBOL_38_ = 38,                       /* '+'  */
320   YYSYMBOL_39_ = 39,                       /* '-'  */
321   YYSYMBOL_40_ = 40,                       /* '*'  */
322   YYSYMBOL_41_ = 41,                       /* '/'  */
323   YYSYMBOL_UNARY = 42,                     /* UNARY  */
324   YYSYMBOL_INCREMENT = 43,                 /* INCREMENT  */
325   YYSYMBOL_DECREMENT = 44,                 /* DECREMENT  */
326   YYSYMBOL_ARROW = 45,                     /* ARROW  */
327   YYSYMBOL_46_ = 46,                       /* '.'  */
328   YYSYMBOL_47_ = 47,                       /* '['  */
329   YYSYMBOL_48_ = 48,                       /* '('  */
330   YYSYMBOL_49_ = 49,                       /* '^'  */
331   YYSYMBOL_BLOCKNAME = 50,                 /* BLOCKNAME  */
332   YYSYMBOL_51_ = 51,                       /* ')'  */
333   YYSYMBOL_52_ = 52,                       /* ']'  */
334   YYSYMBOL_YYACCEPT = 53,                  /* $accept  */
335   YYSYMBOL_start = 54,                     /* start  */
336   YYSYMBOL_55_1 = 55,                      /* $@1  */
337   YYSYMBOL_normal_start = 56,              /* normal_start  */
338   YYSYMBOL_type_exp = 57,                  /* type_exp  */
339   YYSYMBOL_exp1 = 58,                      /* exp1  */
340   YYSYMBOL_exp = 59,                       /* exp  */
341   YYSYMBOL_field_exp = 60,                 /* field_exp  */
342   YYSYMBOL_61_2 = 61,                      /* $@2  */
343   YYSYMBOL_62_3 = 62,                      /* $@3  */
344   YYSYMBOL_arglist = 63,                   /* arglist  */
345   YYSYMBOL_64_4 = 64,                      /* $@4  */
346   YYSYMBOL_block = 65,                     /* block  */
347   YYSYMBOL_variable = 66,                  /* variable  */
348   YYSYMBOL_qualified_name = 67,            /* qualified_name  */
349   YYSYMBOL_ptype = 68,                     /* ptype  */
350   YYSYMBOL_type = 69,                      /* type  */
351   YYSYMBOL_typebase = 70,                  /* typebase  */
352   YYSYMBOL_name = 71,                      /* name  */
353   YYSYMBOL_name_not_typename = 72          /* name_not_typename  */
354 };
355 typedef enum yysymbol_kind_t yysymbol_kind_t;
356
357
358 /* Second part of user prologue.  */
359 #line 115 "p-exp.y"
360
361 /* YYSTYPE gets defined by %union */
362 static int parse_number (struct parser_state *,
363                          const char *, int, int, YYSTYPE *);
364
365 static struct type *current_type;
366 static int leftdiv_is_integer;
367 static void push_current_type (void);
368 static void pop_current_type (void);
369 static int search_field;
370
371 #line 372 "p-exp.c.tmp"
372
373
374 #ifdef short
375 # undef short
376 #endif
377
378 /* On compilers that do not define __PTRDIFF_MAX__ etc., make sure
379    <limits.h> and (if available) <stdint.h> are included
380    so that the code can choose integer types of a good width.  */
381
382 #ifndef __PTRDIFF_MAX__
383 # include <limits.h> /* INFRINGES ON USER NAME SPACE */
384 # if defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
385 #  include <stdint.h> /* INFRINGES ON USER NAME SPACE */
386 #  define YY_STDINT_H
387 # endif
388 #endif
389
390 /* Narrow types that promote to a signed type and that can represent a
391    signed or unsigned integer of at least N bits.  In tables they can
392    save space and decrease cache pressure.  Promoting to a signed type
393    helps avoid bugs in integer arithmetic.  */
394
395 #ifdef __INT_LEAST8_MAX__
396 typedef __INT_LEAST8_TYPE__ yytype_int8;
397 #elif defined YY_STDINT_H
398 typedef int_least8_t yytype_int8;
399 #else
400 typedef signed char yytype_int8;
401 #endif
402
403 #ifdef __INT_LEAST16_MAX__
404 typedef __INT_LEAST16_TYPE__ yytype_int16;
405 #elif defined YY_STDINT_H
406 typedef int_least16_t yytype_int16;
407 #else
408 typedef short yytype_int16;
409 #endif
410
411 /* Work around bug in HP-UX 11.23, which defines these macros
412    incorrectly for preprocessor constants.  This workaround can likely
413    be removed in 2023, as HPE has promised support for HP-UX 11.23
414    (aka HP-UX 11i v2) only through the end of 2022; see Table 2 of
415    <https://h20195.www2.hpe.com/V2/getpdf.aspx/4AA4-7673ENW.pdf>.  */
416 #ifdef __hpux
417 # undef UINT_LEAST8_MAX
418 # undef UINT_LEAST16_MAX
419 # define UINT_LEAST8_MAX 255
420 # define UINT_LEAST16_MAX 65535
421 #endif
422
423 #if defined __UINT_LEAST8_MAX__ && __UINT_LEAST8_MAX__ <= __INT_MAX__
424 typedef __UINT_LEAST8_TYPE__ yytype_uint8;
425 #elif (!defined __UINT_LEAST8_MAX__ && defined YY_STDINT_H \
426        && UINT_LEAST8_MAX <= INT_MAX)
427 typedef uint_least8_t yytype_uint8;
428 #elif !defined __UINT_LEAST8_MAX__ && UCHAR_MAX <= INT_MAX
429 typedef unsigned char yytype_uint8;
430 #else
431 typedef short yytype_uint8;
432 #endif
433
434 #if defined __UINT_LEAST16_MAX__ && __UINT_LEAST16_MAX__ <= __INT_MAX__
435 typedef __UINT_LEAST16_TYPE__ yytype_uint16;
436 #elif (!defined __UINT_LEAST16_MAX__ && defined YY_STDINT_H \
437        && UINT_LEAST16_MAX <= INT_MAX)
438 typedef uint_least16_t yytype_uint16;
439 #elif !defined __UINT_LEAST16_MAX__ && USHRT_MAX <= INT_MAX
440 typedef unsigned short yytype_uint16;
441 #else
442 typedef int yytype_uint16;
443 #endif
444
445 #ifndef YYPTRDIFF_T
446 # if defined __PTRDIFF_TYPE__ && defined __PTRDIFF_MAX__
447 #  define YYPTRDIFF_T __PTRDIFF_TYPE__
448 #  define YYPTRDIFF_MAXIMUM __PTRDIFF_MAX__
449 # elif defined PTRDIFF_MAX
450 #  ifndef ptrdiff_t
451 #   include <stddef.h> /* INFRINGES ON USER NAME SPACE */
452 #  endif
453 #  define YYPTRDIFF_T ptrdiff_t
454 #  define YYPTRDIFF_MAXIMUM PTRDIFF_MAX
455 # else
456 #  define YYPTRDIFF_T long
457 #  define YYPTRDIFF_MAXIMUM LONG_MAX
458 # endif
459 #endif
460
461 #ifndef YYSIZE_T
462 # ifdef __SIZE_TYPE__
463 #  define YYSIZE_T __SIZE_TYPE__
464 # elif defined size_t
465 #  define YYSIZE_T size_t
466 # elif defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
467 #  include <stddef.h> /* INFRINGES ON USER NAME SPACE */
468 #  define YYSIZE_T size_t
469 # else
470 #  define YYSIZE_T unsigned
471 # endif
472 #endif
473
474 #define YYSIZE_MAXIMUM                                  \
475   YY_CAST (YYPTRDIFF_T,                                 \
476            (YYPTRDIFF_MAXIMUM < YY_CAST (YYSIZE_T, -1)  \
477             ? YYPTRDIFF_MAXIMUM                         \
478             : YY_CAST (YYSIZE_T, -1)))
479
480 #define YYSIZEOF(X) YY_CAST (YYPTRDIFF_T, sizeof (X))
481
482
483 /* Stored state numbers (used for stacks). */
484 typedef yytype_int8 yy_state_t;
485
486 /* State numbers in computations.  */
487 typedef int yy_state_fast_t;
488
489 #ifndef YY_
490 # if defined YYENABLE_NLS && YYENABLE_NLS
491 #  if ENABLE_NLS
492 #   include <libintl.h> /* INFRINGES ON USER NAME SPACE */
493 #   define YY_(Msgid) dgettext ("bison-runtime", Msgid)
494 #  endif
495 # endif
496 # ifndef YY_
497 #  define YY_(Msgid) Msgid
498 # endif
499 #endif
500
501
502 #ifndef YY_ATTRIBUTE_PURE
503 # if defined __GNUC__ && 2 < __GNUC__ + (96 <= __GNUC_MINOR__)
504 #  define YY_ATTRIBUTE_PURE __attribute__ ((__pure__))
505 # else
506 #  define YY_ATTRIBUTE_PURE
507 # endif
508 #endif
509
510 #ifndef YY_ATTRIBUTE_UNUSED
511 # if defined __GNUC__ && 2 < __GNUC__ + (7 <= __GNUC_MINOR__)
512 #  define YY_ATTRIBUTE_UNUSED __attribute__ ((__unused__))
513 # else
514 #  define YY_ATTRIBUTE_UNUSED
515 # endif
516 #endif
517
518 /* Suppress unused-variable warnings by "using" E.  */
519 #if ! defined lint || defined __GNUC__
520 # define YY_USE(E) ((void) (E))
521 #else
522 # define YY_USE(E) /* empty */
523 #endif
524
525 /* Suppress an incorrect diagnostic about yylval being uninitialized.  */
526 #if defined __GNUC__ && ! defined __ICC && 406 <= __GNUC__ * 100 + __GNUC_MINOR__
527 # if __GNUC__ * 100 + __GNUC_MINOR__ < 407
528 #  define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN                           \
529     _Pragma ("GCC diagnostic push")                                     \
530     _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")
531 # else
532 #  define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN                           \
533     _Pragma ("GCC diagnostic push")                                     \
534     _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")              \
535     _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
536 # endif
537 # define YY_IGNORE_MAYBE_UNINITIALIZED_END      \
538     _Pragma ("GCC diagnostic pop")
539 #else
540 # define YY_INITIAL_VALUE(Value) Value
541 #endif
542 #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
543 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
544 # define YY_IGNORE_MAYBE_UNINITIALIZED_END
545 #endif
546 #ifndef YY_INITIAL_VALUE
547 # define YY_INITIAL_VALUE(Value) /* Nothing. */
548 #endif
549
550 #if defined __cplusplus && defined __GNUC__ && ! defined __ICC && 6 <= __GNUC__
551 # define YY_IGNORE_USELESS_CAST_BEGIN                          \
552     _Pragma ("GCC diagnostic push")                            \
553     _Pragma ("GCC diagnostic ignored \"-Wuseless-cast\"")
554 # define YY_IGNORE_USELESS_CAST_END            \
555     _Pragma ("GCC diagnostic pop")
556 #endif
557 #ifndef YY_IGNORE_USELESS_CAST_BEGIN
558 # define YY_IGNORE_USELESS_CAST_BEGIN
559 # define YY_IGNORE_USELESS_CAST_END
560 #endif
561
562
563 #define YY_ASSERT(E) ((void) (0 && (E)))
564
565 #if !defined yyoverflow
566
567 /* The parser invokes alloca or xmalloc; define the necessary symbols.  */
568
569 # ifdef YYSTACK_USE_ALLOCA
570 #  if YYSTACK_USE_ALLOCA
571 #   ifdef __GNUC__
572 #    define YYSTACK_ALLOC __builtin_alloca
573 #   elif defined __BUILTIN_VA_ARG_INCR
574 #    include <alloca.h> /* INFRINGES ON USER NAME SPACE */
575 #   elif defined _AIX
576 #    define YYSTACK_ALLOC __alloca
577 #   elif defined _MSC_VER
578 #    define alloca _alloca
579 #   else
580 #    define YYSTACK_ALLOC alloca
581 #    if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
582 #     include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
583       /* Use EXIT_SUCCESS as a witness for stdlib.h.  */
584 #     ifndef EXIT_SUCCESS
585 #      define EXIT_SUCCESS 0
586 #     endif
587 #    endif
588 #   endif
589 #  endif
590 # endif
591
592 # ifdef YYSTACK_ALLOC
593    /* Pacify GCC's 'empty if-body' warning.  */
594 #  define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
595 #  ifndef YYSTACK_ALLOC_MAXIMUM
596     /* The OS might guarantee only one guard page at the bottom of the stack,
597        and a page size can be as small as 4096 bytes.  So we cannot safely
598        invoke alloca (N) if N exceeds 4096.  Use a slightly smaller number
599        to allow for a few compiler-allocated temporary stack slots.  */
600 #   define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
601 #  endif
602 # else
603 #  define YYSTACK_ALLOC YYMALLOC
604 #  define YYSTACK_FREE YYFREE
605 #  ifndef YYSTACK_ALLOC_MAXIMUM
606 #   define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
607 #  endif
608 #  if (defined __cplusplus && ! defined EXIT_SUCCESS \
609        && ! ((defined YYMALLOC || defined xmalloc) \
610              && (defined YYFREE || defined xfree)))
611 #   include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
612 #   ifndef EXIT_SUCCESS
613 #    define EXIT_SUCCESS 0
614 #   endif
615 #  endif
616 #  ifndef YYMALLOC
617 #   define YYMALLOC xmalloc
618 #   if ! defined xmalloc && ! defined EXIT_SUCCESS
619 void *xmalloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
620 #   endif
621 #  endif
622 #  ifndef YYFREE
623 #   define YYFREE xfree
624 #   if ! defined xfree && ! defined EXIT_SUCCESS
625 void xfree (void *); /* INFRINGES ON USER NAME SPACE */
626 #   endif
627 #  endif
628 # endif
629 #endif /* !defined yyoverflow */
630
631 #if (! defined yyoverflow \
632      && (! defined __cplusplus \
633          || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
634
635 /* A type that is properly aligned for any stack member.  */
636 union yyalloc
637 {
638   yy_state_t yyss_alloc;
639   YYSTYPE yyvs_alloc;
640 };
641
642 /* The size of the maximum gap between one aligned stack and the next.  */
643 # define YYSTACK_GAP_MAXIMUM (YYSIZEOF (union yyalloc) - 1)
644
645 /* The size of an array large to enough to hold all stacks, each with
646    N elements.  */
647 # define YYSTACK_BYTES(N) \
648      ((N) * (YYSIZEOF (yy_state_t) + YYSIZEOF (YYSTYPE)) \
649       + YYSTACK_GAP_MAXIMUM)
650
651 # define YYCOPY_NEEDED 1
652
653 /* Relocate STACK from its old location to the new one.  The
654    local variables YYSIZE and YYSTACKSIZE give the old and new number of
655    elements in the stack, and YYPTR gives the new location of the
656    stack.  Advance YYPTR to a properly aligned location for the next
657    stack.  */
658 # define YYSTACK_RELOCATE(Stack_alloc, Stack)                           \
659     do                                                                  \
660       {                                                                 \
661         YYPTRDIFF_T yynewbytes;                                         \
662         YYCOPY (&yyptr->Stack_alloc, Stack, yysize);                    \
663         Stack = &yyptr->Stack_alloc;                                    \
664         yynewbytes = yystacksize * YYSIZEOF (*Stack) + YYSTACK_GAP_MAXIMUM; \
665         yyptr += yynewbytes / YYSIZEOF (*yyptr);                        \
666       }                                                                 \
667     while (0)
668
669 #endif
670
671 #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
672 /* Copy COUNT objects from SRC to DST.  The source and destination do
673    not overlap.  */
674 # ifndef YYCOPY
675 #  if defined __GNUC__ && 1 < __GNUC__
676 #   define YYCOPY(Dst, Src, Count) \
677       __builtin_memcpy (Dst, Src, YY_CAST (YYSIZE_T, (Count)) * sizeof (*(Src)))
678 #  else
679 #   define YYCOPY(Dst, Src, Count)              \
680       do                                        \
681         {                                       \
682           YYPTRDIFF_T yyi;                      \
683           for (yyi = 0; yyi < (Count); yyi++)   \
684             (Dst)[yyi] = (Src)[yyi];            \
685         }                                       \
686       while (0)
687 #  endif
688 # endif
689 #endif /* !YYCOPY_NEEDED */
690
691 /* YYFINAL -- State number of the termination state.  */
692 #define YYFINAL  3
693 /* YYLAST -- Last index in YYTABLE.  */
694 #define YYLAST   377
695
696 /* YYNTOKENS -- Number of terminals.  */
697 #define YYNTOKENS  53
698 /* YYNNTS -- Number of nonterminals.  */
699 #define YYNNTS  20
700 /* YYNRULES -- Number of rules.  */
701 #define YYNRULES  77
702 /* YYNSTATES -- Number of states.  */
703 #define YYNSTATES  126
704
705 /* YYMAXUTOK -- Last valid token kind.  */
706 #define YYMAXUTOK   292
707
708
709 /* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM
710    as returned by yylex, with out-of-bounds checking.  */
711 #define YYTRANSLATE(YYX)                                \
712   (0 <= (YYX) && (YYX) <= YYMAXUTOK                     \
713    ? YY_CAST (yysymbol_kind_t, yytranslate[YYX])        \
714    : YYSYMBOL_YYUNDEF)
715
716 /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
717    as returned by yylex.  */
718 static const yytype_int8 yytranslate[] =
719 {
720        0,     2,     2,     2,     2,     2,     2,     2,     2,     2,
721        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
722        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
723        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
724       48,    51,    40,    38,    20,    39,    46,    41,     2,     2,
725        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
726       29,    27,    30,     2,    37,     2,     2,     2,     2,     2,
727        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
728        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
729        2,    47,     2,    52,    49,     2,     2,     2,     2,     2,
730        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
731        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
732        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
733        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
734        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
735        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
736        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
737        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
738        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
739        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
740        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
741        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
742        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
743        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
744        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
745        2,     2,     2,     2,     2,     2,     1,     2,     3,     4,
746        5,     6,     7,     8,     9,    10,    11,    12,    13,    14,
747       15,    16,    17,    18,    19,    21,    22,    23,    24,    25,
748       26,    28,    31,    32,    33,    34,    35,    36,    42,    43,
749       44,    45,    50
750 };
751
752 #if YYDEBUG
753 /* YYRLINE[YYN] -- Source line where rule number YYN was defined.  */
754 static const yytype_int16 yyrline[] =
755 {
756        0,   196,   196,   196,   204,   205,   208,   214,   215,   220,
757      226,   232,   236,   240,   244,   249,   253,   271,   287,   296,
758      307,   305,   330,   327,   344,   345,   347,   351,   365,   371,
759      375,   375,   396,   400,   404,   408,   412,   416,   420,   427,
760      434,   441,   448,   455,   462,   466,   470,   474,   478,   485,
761      492,   500,   512,   521,   524,   550,   559,   563,   585,   612,
762      631,   644,   658,   672,   673,   684,   742,   753,   757,   759,
763      761,   766,   776,   777,   778,   779,   782,   783
764 };
765 #endif
766
767 /** Accessing symbol of state STATE.  */
768 #define YY_ACCESSING_SYMBOL(State) YY_CAST (yysymbol_kind_t, yystos[State])
769
770 #if YYDEBUG || 0
771 /* The user-facing name of the symbol whose (internal) number is
772    YYSYMBOL.  No bounds checking.  */
773 static const char *yysymbol_name (yysymbol_kind_t yysymbol) YY_ATTRIBUTE_UNUSED;
774
775 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
776    First, the terminals, then, starting at YYNTOKENS, nonterminals.  */
777 static const char *const yytname[] =
778 {
779   "\"end of file\"", "error", "\"invalid token\"", "INT", "FLOAT",
780   "STRING", "FIELDNAME", "COMPLETE", "NAME", "TYPENAME", "NAME_OR_INT",
781   "STRUCT", "CLASS", "SIZEOF", "COLONCOLON", "ERROR", "DOLLAR_VARIABLE",
782   "THIS", "TRUEKEYWORD", "FALSEKEYWORD", "','", "ABOVE_COMMA", "ASSIGN",
783   "NOT", "OR", "XOR", "ANDAND", "'='", "NOTEQUAL", "'<'", "'>'", "LEQ",
784   "GEQ", "LSH", "RSH", "DIV", "MOD", "'@'", "'+'", "'-'", "'*'", "'/'",
785   "UNARY", "INCREMENT", "DECREMENT", "ARROW", "'.'", "'['", "'('", "'^'",
786   "BLOCKNAME", "')'", "']'", "$accept", "start", "$@1", "normal_start",
787   "type_exp", "exp1", "exp", "field_exp", "$@2", "$@3", "arglist", "$@4",
788   "block", "variable", "qualified_name", "ptype", "type", "typebase",
789   "name", "name_not_typename", YY_NULLPTRPTR
790 };
791
792 static const char *
793 yysymbol_name (yysymbol_kind_t yysymbol)
794 {
795   return yytname[yysymbol];
796 }
797 #endif
798
799 #define YYPACT_NINF (-44)
800
801 #define yypact_value_is_default(Yyn) \
802   ((Yyn) == YYPACT_NINF)
803
804 #define YYTABLE_NINF (-61)
805
806 #define yytable_value_is_error(Yyn) \
807   0
808
809 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
810    STATE-NUM.  */
811 static const yytype_int16 yypact[] =
812 {
813      -44,    20,    90,   -44,   -44,   -44,   -44,   -44,   -44,   -44,
814        7,     7,   -41,     7,   -44,   -44,   -44,   -44,    90,    90,
815       90,   -39,   -24,    90,    10,    13,   -44,   -44,     8,   231,
816        4,    21,   -44,   -44,   -44,   -14,    41,   -44,   -44,   -44,
817      -44,   -44,   -44,   -44,    90,   -44,    35,   -14,    35,    35,
818       90,    90,     5,   -44,    90,    90,    90,    90,    90,    90,
819       90,    90,    90,    90,    90,    90,    90,    90,    90,    90,
820       90,    90,   -44,   -44,   -44,   -44,   -44,   -44,   -44,    23,
821        7,    90,     7,   119,   -43,   147,   175,   -44,   231,   231,
822      256,   280,   303,   324,   324,    31,    31,    31,    31,    76,
823       76,    76,    76,   328,   328,    35,    90,    90,    90,   -44,
824       44,   203,   -44,   -44,   -44,   -44,   -44,    35,     9,   231,
825       11,   -44,   -44,    90,   -44,   231
826 };
827
828 /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
829    Performed when YYTABLE does not specify something else to do.  Zero
830    means the default is an error.  */
831 static const yytype_int8 yydefact[] =
832 {
833        2,     0,     0,     1,    50,    52,    57,    76,    69,    51,
834        0,     0,     0,     0,    54,    58,    48,    49,     0,     0,
835        0,     0,     0,     0,     0,    77,     3,     5,     4,     7,
836        0,     0,    53,    63,    67,     6,    66,    65,    72,    74,
837       75,    73,    70,    71,     0,    64,    12,     0,    10,    11,
838        0,     0,     0,    68,     0,     0,     0,     0,     0,     0,
839        0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
840        0,     0,    30,    15,    20,    22,     9,    16,    19,    17,
841        0,     0,     0,     0,     0,     0,     0,    28,     8,    47,
842       46,    45,    44,    38,    39,    42,    43,    40,    41,    36,
843       37,    32,    33,    34,    35,    29,     0,     0,    24,    18,
844       61,     0,    62,    56,    55,    13,    14,    31,     0,    25,
845        0,    27,    21,     0,    23,    26
846 };
847
848 /* YYPGOTO[NTERM-NUM].  */
849 static const yytype_int8 yypgoto[] =
850 {
851      -44,   -44,   -44,   -44,   -44,   -20,   -18,   -44,   -44,   -44,
852      -44,   -44,   -44,   -44,   -44,   -44,    16,    50,    -7,   -44
853 };
854
855 /* YYDEFGOTO[NTERM-NUM].  */
856 static const yytype_int8 yydefgoto[] =
857 {
858        0,     1,     2,    26,    27,    28,    29,    30,   107,   108,
859      120,   106,    31,    32,    33,    34,    47,    36,    42,    37
860 };
861
862 /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM.  If
863    positive, shift that token.  If negative, reduce the rule whose
864    number is the opposite.  If YYTABLE_NINF, syntax error.  */
865 static const yytype_int8 yytable[] =
866 {
867       46,    48,    49,    52,    43,    81,    45,    44,   114,    50,
868       77,    78,    38,    39,    40,    38,    39,    40,    35,     8,
869        3,    10,    11,    79,    51,    54,    83,   -59,    54,    54,
870      109,   123,    85,    86,    81,    80,    88,    89,    90,    91,
871       92,    93,    94,    95,    96,    97,    98,    99,   100,   101,
872      102,   103,   104,   105,    41,    82,    87,    41,   -60,    24,
873       84,   122,   124,   111,    65,    66,    67,    68,     0,    69,
874       70,    71,    72,   110,    53,   112,     0,    73,    74,    75,
875       76,    73,    74,    75,    76,     0,     0,   118,   117,     0,
876      119,     0,     0,     4,     5,     6,     0,     0,     7,     8,
877        9,    10,    11,    12,    13,   125,    14,    15,    16,    17,
878        0,     0,     0,    18,    69,    70,    71,    72,     0,     0,
879        0,     0,    73,    74,    75,    76,     0,    19,     0,    20,
880        0,     0,     0,    21,    22,     0,     0,     0,    23,    24,
881       25,    55,     0,    56,    57,    58,    59,    60,    61,    62,
882       63,    64,    65,    66,    67,    68,     0,    69,    70,    71,
883       72,     0,     0,     0,     0,    73,    74,    75,    76,    55,
884      113,    56,    57,    58,    59,    60,    61,    62,    63,    64,
885       65,    66,    67,    68,     0,    69,    70,    71,    72,     0,
886        0,     0,     0,    73,    74,    75,    76,    55,   115,    56,
887       57,    58,    59,    60,    61,    62,    63,    64,    65,    66,
888       67,    68,     0,    69,    70,    71,    72,     0,     0,     0,
889        0,    73,    74,    75,    76,    55,   116,    56,    57,    58,
890       59,    60,    61,    62,    63,    64,    65,    66,    67,    68,
891        0,    69,    70,    71,    72,     0,     0,     0,     0,    73,
892       74,    75,    76,    55,   121,    56,    57,    58,    59,    60,
893       61,    62,    63,    64,    65,    66,    67,    68,     0,    69,
894       70,    71,    72,     0,     0,     0,     0,    73,    74,    75,
895       76,    57,    58,    59,    60,    61,    62,    63,    64,    65,
896       66,    67,    68,     0,    69,    70,    71,    72,     0,     0,
897        0,     0,    73,    74,    75,    76,    58,    59,    60,    61,
898       62,    63,    64,    65,    66,    67,    68,     0,    69,    70,
899       71,    72,     0,     0,     0,     0,    73,    74,    75,    76,
900       59,    60,    61,    62,    63,    64,    65,    66,    67,    68,
901        0,    69,    70,    71,    72,     0,     0,     0,     0,    73,
902       74,    75,    76,    61,    62,    63,    64,    65,    66,    67,
903       68,     0,    69,    70,    71,    72,     0,     0,    71,    72,
904       73,    74,    75,    76,    73,    74,    75,    76
905 };
906
907 static const yytype_int8 yycheck[] =
908 {
909       18,    19,    20,    23,    11,    48,    13,    48,    51,    48,
910        6,     7,     8,     9,    10,     8,     9,    10,     2,     9,
911        0,    11,    12,    30,    48,    20,    44,    14,    20,    20,
912        7,    20,    50,    51,    48,    14,    54,    55,    56,    57,
913       58,    59,    60,    61,    62,    63,    64,    65,    66,    67,
914       68,    69,    70,    71,    50,    14,    51,    50,    14,    49,
915       44,    52,    51,    81,    33,    34,    35,    36,    -1,    38,
916       39,    40,    41,    80,    24,    82,    -1,    46,    47,    48,
917       49,    46,    47,    48,    49,    -1,    -1,   107,   106,    -1,
918      108,    -1,    -1,     3,     4,     5,    -1,    -1,     8,     9,
919       10,    11,    12,    13,    14,   123,    16,    17,    18,    19,
920       -1,    -1,    -1,    23,    38,    39,    40,    41,    -1,    -1,
921       -1,    -1,    46,    47,    48,    49,    -1,    37,    -1,    39,
922       -1,    -1,    -1,    43,    44,    -1,    -1,    -1,    48,    49,
923       50,    22,    -1,    24,    25,    26,    27,    28,    29,    30,
924       31,    32,    33,    34,    35,    36,    -1,    38,    39,    40,
925       41,    -1,    -1,    -1,    -1,    46,    47,    48,    49,    22,
926       51,    24,    25,    26,    27,    28,    29,    30,    31,    32,
927       33,    34,    35,    36,    -1,    38,    39,    40,    41,    -1,
928       -1,    -1,    -1,    46,    47,    48,    49,    22,    51,    24,
929       25,    26,    27,    28,    29,    30,    31,    32,    33,    34,
930       35,    36,    -1,    38,    39,    40,    41,    -1,    -1,    -1,
931       -1,    46,    47,    48,    49,    22,    51,    24,    25,    26,
932       27,    28,    29,    30,    31,    32,    33,    34,    35,    36,
933       -1,    38,    39,    40,    41,    -1,    -1,    -1,    -1,    46,
934       47,    48,    49,    22,    51,    24,    25,    26,    27,    28,
935       29,    30,    31,    32,    33,    34,    35,    36,    -1,    38,
936       39,    40,    41,    -1,    -1,    -1,    -1,    46,    47,    48,
937       49,    25,    26,    27,    28,    29,    30,    31,    32,    33,
938       34,    35,    36,    -1,    38,    39,    40,    41,    -1,    -1,
939       -1,    -1,    46,    47,    48,    49,    26,    27,    28,    29,
940       30,    31,    32,    33,    34,    35,    36,    -1,    38,    39,
941       40,    41,    -1,    -1,    -1,    -1,    46,    47,    48,    49,
942       27,    28,    29,    30,    31,    32,    33,    34,    35,    36,
943       -1,    38,    39,    40,    41,    -1,    -1,    -1,    -1,    46,
944       47,    48,    49,    29,    30,    31,    32,    33,    34,    35,
945       36,    -1,    38,    39,    40,    41,    -1,    -1,    40,    41,
946       46,    47,    48,    49,    46,    47,    48,    49
947 };
948
949 /* YYSTOS[STATE-NUM] -- The symbol kind of the accessing symbol of
950    state STATE-NUM.  */
951 static const yytype_int8 yystos[] =
952 {
953        0,    54,    55,     0,     3,     4,     5,     8,     9,    10,
954       11,    12,    13,    14,    16,    17,    18,    19,    23,    37,
955       39,    43,    44,    48,    49,    50,    56,    57,    58,    59,
956       60,    65,    66,    67,    68,    69,    70,    72,     8,     9,
957       10,    50,    71,    71,    48,    71,    59,    69,    59,    59,
958       48,    48,    58,    70,    20,    22,    24,    25,    26,    27,
959       28,    29,    30,    31,    32,    33,    34,    35,    36,    38,
960       39,    40,    41,    46,    47,    48,    49,     6,     7,    71,
961       14,    48,    14,    59,    69,    59,    59,    51,    59,    59,
962       59,    59,    59,    59,    59,    59,    59,    59,    59,    59,
963       59,    59,    59,    59,    59,    59,    64,    61,    62,     7,
964       71,    59,    71,    51,    51,    51,    51,    59,    58,    59,
965       63,    51,    52,    20,    51,    59
966 };
967
968 /* YYR1[RULE-NUM] -- Symbol kind of the left-hand side of rule RULE-NUM.  */
969 static const yytype_int8 yyr1[] =
970 {
971        0,    53,    55,    54,    56,    56,    57,    58,    58,    59,
972       59,    59,    59,    59,    59,    60,    59,    59,    59,    59,
973       61,    59,    62,    59,    63,    63,    63,    59,    59,    59,
974       64,    59,    59,    59,    59,    59,    59,    59,    59,    59,
975       59,    59,    59,    59,    59,    59,    59,    59,    59,    59,
976       59,    59,    59,    59,    59,    59,    59,    59,    59,    65,
977       65,    66,    67,    66,    66,    66,    68,    69,    70,    70,
978       70,    70,    71,    71,    71,    71,    72,    72
979 };
980
981 /* YYR2[RULE-NUM] -- Number of symbols on the right-hand side of rule RULE-NUM.  */
982 static const yytype_int8 yyr2[] =
983 {
984        0,     2,     0,     2,     1,     1,     1,     1,     3,     2,
985        2,     2,     2,     4,     4,     2,     2,     2,     3,     2,
986        0,     5,     0,     5,     0,     1,     3,     4,     3,     3,
987        0,     4,     3,     3,     3,     3,     3,     3,     3,     3,
988        3,     3,     3,     3,     3,     3,     3,     3,     1,     1,
989        1,     1,     1,     1,     1,     4,     4,     1,     1,     1,
990        3,     3,     3,     1,     2,     1,     1,     1,     2,     1,
991        2,     2,     1,     1,     1,     1,     1,     1
992 };
993
994
995 enum { YYENOMEM = -2 };
996
997 #define yyerrok         (yyerrstatus = 0)
998 #define yyclearin       (yychar = YYEMPTY)
999
1000 #define YYACCEPT        goto yyacceptlab
1001 #define YYABORT         goto yyabortlab
1002 #define YYERROR         goto yyerrorlab
1003 #define YYNOMEM         goto yyexhaustedlab
1004
1005
1006 #define YYRECOVERING()  (!!yyerrstatus)
1007
1008 #define YYBACKUP(Token, Value)                                    \
1009   do                                                              \
1010     if (yychar == YYEMPTY)                                        \
1011       {                                                           \
1012         yychar = (Token);                                         \
1013         yylval = (Value);                                         \
1014         YYPOPSTACK (yylen);                                       \
1015         yystate = *yyssp;                                         \
1016         goto yybackup;                                            \
1017       }                                                           \
1018     else                                                          \
1019       {                                                           \
1020         yyerror (YY_("syntax error: cannot back up")); \
1021         YYERROR;                                                  \
1022       }                                                           \
1023   while (0)
1024
1025 /* Backward compatibility with an undocumented macro.
1026    Use YYerror or YYUNDEF. */
1027 #define YYERRCODE YYUNDEF
1028
1029
1030 /* Enable debugging if requested.  */
1031 #if YYDEBUG
1032
1033 # ifndef YYFPRINTF
1034 #  include <stdio.h> /* INFRINGES ON USER NAME SPACE */
1035 #  define YYFPRINTF fprintf
1036 # endif
1037
1038 # define YYDPRINTF(Args)                        \
1039 do {                                            \
1040   if (yydebug)                                  \
1041     YYFPRINTF Args;                             \
1042 } while (0)
1043
1044
1045
1046
1047 # define YY_SYMBOL_PRINT(Title, Kind, Value, Location)                    \
1048 do {                                                                      \
1049   if (yydebug)                                                            \
1050     {                                                                     \
1051       YYFPRINTF (stderr, "%s ", Title);                                   \
1052       yy_symbol_print (stderr,                                            \
1053                   Kind, Value); \
1054       YYFPRINTF (stderr, "\n");                                           \
1055     }                                                                     \
1056 } while (0)
1057
1058
1059 /*-----------------------------------.
1060 | Print this symbol's value on YYO.  |
1061 `-----------------------------------*/
1062
1063 static void
1064 yy_symbol_value_print (FILE *yyo,
1065                        yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep)
1066 {
1067   FILE *yyoutput = yyo;
1068   YY_USE (yyoutput);
1069   if (!yyvaluep)
1070     return;
1071   YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1072   YY_USE (yykind);
1073   YY_IGNORE_MAYBE_UNINITIALIZED_END
1074 }
1075
1076
1077 /*---------------------------.
1078 | Print this symbol on YYO.  |
1079 `---------------------------*/
1080
1081 static void
1082 yy_symbol_print (FILE *yyo,
1083                  yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep)
1084 {
1085   YYFPRINTF (yyo, "%s %s (",
1086              yykind < YYNTOKENS ? "token" : "nterm", yysymbol_name (yykind));
1087
1088   yy_symbol_value_print (yyo, yykind, yyvaluep);
1089   YYFPRINTF (yyo, ")");
1090 }
1091
1092 /*------------------------------------------------------------------.
1093 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
1094 | TOP (included).                                                   |
1095 `------------------------------------------------------------------*/
1096
1097 static void
1098 yy_stack_print (yy_state_t *yybottom, yy_state_t *yytop)
1099 {
1100   YYFPRINTF (stderr, "Stack now");
1101   for (; yybottom <= yytop; yybottom++)
1102     {
1103       int yybot = *yybottom;
1104       YYFPRINTF (stderr, " %d", yybot);
1105     }
1106   YYFPRINTF (stderr, "\n");
1107 }
1108
1109 # define YY_STACK_PRINT(Bottom, Top)                            \
1110 do {                                                            \
1111   if (yydebug)                                                  \
1112     yy_stack_print ((Bottom), (Top));                           \
1113 } while (0)
1114
1115
1116 /*------------------------------------------------.
1117 | Report that the YYRULE is going to be reduced.  |
1118 `------------------------------------------------*/
1119
1120 static void
1121 yy_reduce_print (yy_state_t *yyssp, YYSTYPE *yyvsp,
1122                  int yyrule)
1123 {
1124   int yylno = yyrline[yyrule];
1125   int yynrhs = yyr2[yyrule];
1126   int yyi;
1127   YYFPRINTF (stderr, "Reducing stack by rule %d (line %d):\n",
1128              yyrule - 1, yylno);
1129   /* The symbols being reduced.  */
1130   for (yyi = 0; yyi < yynrhs; yyi++)
1131     {
1132       YYFPRINTF (stderr, "   $%d = ", yyi + 1);
1133       yy_symbol_print (stderr,
1134                        YY_ACCESSING_SYMBOL (+yyssp[yyi + 1 - yynrhs]),
1135                        &yyvsp[(yyi + 1) - (yynrhs)]);
1136       YYFPRINTF (stderr, "\n");
1137     }
1138 }
1139
1140 # define YY_REDUCE_PRINT(Rule)          \
1141 do {                                    \
1142   if (yydebug)                          \
1143     yy_reduce_print (yyssp, yyvsp, Rule); \
1144 } while (0)
1145
1146 /* Nonzero means print parse trace.  It is left uninitialized so that
1147    multiple parsers can coexist.  */
1148 int yydebug;
1149 #else /* !YYDEBUG */
1150 # define YYDPRINTF(Args) ((void) 0)
1151 # define YY_SYMBOL_PRINT(Title, Kind, Value, Location)
1152 # define YY_STACK_PRINT(Bottom, Top)
1153 # define YY_REDUCE_PRINT(Rule)
1154 #endif /* !YYDEBUG */
1155
1156
1157 /* YYINITDEPTH -- initial size of the parser's stacks.  */
1158 #ifndef YYINITDEPTH
1159 # define YYINITDEPTH 200
1160 #endif
1161
1162 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
1163    if the built-in stack extension method is used).
1164
1165    Do not make this value too large; the results are undefined if
1166    YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
1167    evaluated with infinite-precision integer arithmetic.  */
1168
1169 #ifndef YYMAXDEPTH
1170 # define YYMAXDEPTH 10000
1171 #endif
1172
1173
1174
1175
1176
1177
1178 /*-----------------------------------------------.
1179 | Release the memory associated to this symbol.  |
1180 `-----------------------------------------------*/
1181
1182 static void
1183 yydestruct (const char *yymsg,
1184             yysymbol_kind_t yykind, YYSTYPE *yyvaluep)
1185 {
1186   YY_USE (yyvaluep);
1187   if (!yymsg)
1188     yymsg = "Deleting";
1189   YY_SYMBOL_PRINT (yymsg, yykind, yyvaluep, yylocationp);
1190
1191   YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1192   YY_USE (yykind);
1193   YY_IGNORE_MAYBE_UNINITIALIZED_END
1194 }
1195
1196
1197 /* Lookahead token kind.  */
1198 int yychar;
1199
1200 /* The semantic value of the lookahead symbol.  */
1201 YYSTYPE yylval;
1202 /* Number of syntax errors so far.  */
1203 int yynerrs;
1204
1205
1206
1207
1208 /*----------.
1209 | yyparse.  |
1210 `----------*/
1211
1212 int
1213 yyparse (void)
1214 {
1215     yy_state_fast_t yystate = 0;
1216     /* Number of tokens to shift before error messages enabled.  */
1217     int yyerrstatus = 0;
1218
1219     /* Refer to the stacks through separate pointers, to allow yyoverflow
1220        to xreallocate them elsewhere.  */
1221
1222     /* Their size.  */
1223     YYPTRDIFF_T yystacksize = YYINITDEPTH;
1224
1225     /* The state stack: array, bottom, top.  */
1226     yy_state_t yyssa[YYINITDEPTH];
1227     yy_state_t *yyss = yyssa;
1228     yy_state_t *yyssp = yyss;
1229
1230     /* The semantic value stack: array, bottom, top.  */
1231     YYSTYPE yyvsa[YYINITDEPTH];
1232     YYSTYPE *yyvs = yyvsa;
1233     YYSTYPE *yyvsp = yyvs;
1234
1235   int yyn;
1236   /* The return value of yyparse.  */
1237   int yyresult;
1238   /* Lookahead symbol kind.  */
1239   yysymbol_kind_t yytoken = YYSYMBOL_YYEMPTY;
1240   /* The variables used to return semantic value and location from the
1241      action routines.  */
1242   YYSTYPE yyval;
1243
1244
1245
1246 #define YYPOPSTACK(N)   (yyvsp -= (N), yyssp -= (N))
1247
1248   /* The number of symbols on the RHS of the reduced rule.
1249      Keep to zero when no symbol should be popped.  */
1250   int yylen = 0;
1251
1252   YYDPRINTF ((stderr, "Starting parse\n"));
1253
1254   yychar = YYEMPTY; /* Cause a token to be read.  */
1255
1256   goto yysetstate;
1257
1258
1259 /*------------------------------------------------------------.
1260 | yynewstate -- push a new state, which is found in yystate.  |
1261 `------------------------------------------------------------*/
1262 yynewstate:
1263   /* In all cases, when you get here, the value and location stacks
1264      have just been pushed.  So pushing a state here evens the stacks.  */
1265   yyssp++;
1266
1267
1268 /*--------------------------------------------------------------------.
1269 | yysetstate -- set current state (the top of the stack) to yystate.  |
1270 `--------------------------------------------------------------------*/
1271 yysetstate:
1272   YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1273   YY_ASSERT (0 <= yystate && yystate < YYNSTATES);
1274   YY_IGNORE_USELESS_CAST_BEGIN
1275   *yyssp = YY_CAST (yy_state_t, yystate);
1276   YY_IGNORE_USELESS_CAST_END
1277   YY_STACK_PRINT (yyss, yyssp);
1278
1279   if (yyss + yystacksize - 1 <= yyssp)
1280 #if !defined yyoverflow && !defined YYSTACK_RELOCATE
1281     YYNOMEM;
1282 #else
1283     {
1284       /* Get the current used size of the three stacks, in elements.  */
1285       YYPTRDIFF_T yysize = yyssp - yyss + 1;
1286
1287 # if defined yyoverflow
1288       {
1289         /* Give user a chance to xreallocate the stack.  Use copies of
1290            these so that the &'s don't force the real ones into
1291            memory.  */
1292         yy_state_t *yyss1 = yyss;
1293         YYSTYPE *yyvs1 = yyvs;
1294
1295         /* Each stack pointer address is followed by the size of the
1296            data in use in that stack, in bytes.  This used to be a
1297            conditional around just the two extra args, but that might
1298            be undefined if yyoverflow is a macro.  */
1299         yyoverflow (YY_("memory exhausted"),
1300                     &yyss1, yysize * YYSIZEOF (*yyssp),
1301                     &yyvs1, yysize * YYSIZEOF (*yyvsp),
1302                     &yystacksize);
1303         yyss = yyss1;
1304         yyvs = yyvs1;
1305       }
1306 # else /* defined YYSTACK_RELOCATE */
1307       /* Extend the stack our own way.  */
1308       if (YYMAXDEPTH <= yystacksize)
1309         YYNOMEM;
1310       yystacksize *= 2;
1311       if (YYMAXDEPTH < yystacksize)
1312         yystacksize = YYMAXDEPTH;
1313
1314       {
1315         yy_state_t *yyss1 = yyss;
1316         union yyalloc *yyptr =
1317           YY_CAST (union yyalloc *,
1318                    YYSTACK_ALLOC (YY_CAST (YYSIZE_T, YYSTACK_BYTES (yystacksize))));
1319         if (! yyptr)
1320           YYNOMEM;
1321         YYSTACK_RELOCATE (yyss_alloc, yyss);
1322         YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1323 #  undef YYSTACK_RELOCATE
1324         if (yyss1 != yyssa)
1325           YYSTACK_FREE (yyss1);
1326       }
1327 # endif
1328
1329       yyssp = yyss + yysize - 1;
1330       yyvsp = yyvs + yysize - 1;
1331
1332       YY_IGNORE_USELESS_CAST_BEGIN
1333       YYDPRINTF ((stderr, "Stack size increased to %ld\n",
1334                   YY_CAST (long, yystacksize)));
1335       YY_IGNORE_USELESS_CAST_END
1336
1337       if (yyss + yystacksize - 1 <= yyssp)
1338         YYABORT;
1339     }
1340 #endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */
1341
1342
1343   if (yystate == YYFINAL)
1344     YYACCEPT;
1345
1346   goto yybackup;
1347
1348
1349 /*-----------.
1350 | yybackup.  |
1351 `-----------*/
1352 yybackup:
1353   /* Do appropriate processing given the current state.  Read a
1354      lookahead token if we need one and don't already have one.  */
1355
1356   /* First try to decide what to do without reference to lookahead token.  */
1357   yyn = yypact[yystate];
1358   if (yypact_value_is_default (yyn))
1359     goto yydefault;
1360
1361   /* Not known => get a lookahead token if don't already have one.  */
1362
1363   /* YYCHAR is either empty, or end-of-input, or a valid lookahead.  */
1364   if (yychar == YYEMPTY)
1365     {
1366       YYDPRINTF ((stderr, "Reading a token\n"));
1367       yychar = yylex ();
1368     }
1369
1370   if (yychar <= YYEOF)
1371     {
1372       yychar = YYEOF;
1373       yytoken = YYSYMBOL_YYEOF;
1374       YYDPRINTF ((stderr, "Now at end of input.\n"));
1375     }
1376   else if (yychar == YYerror)
1377     {
1378       /* The scanner already issued an error message, process directly
1379          to error recovery.  But do not keep the error token as
1380          lookahead, it is too special and may lead us to an endless
1381          loop in error recovery. */
1382       yychar = YYUNDEF;
1383       yytoken = YYSYMBOL_YYerror;
1384       goto yyerrlab1;
1385     }
1386   else
1387     {
1388       yytoken = YYTRANSLATE (yychar);
1389       YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1390     }
1391
1392   /* If the proper action on seeing token YYTOKEN is to reduce or to
1393      detect an error, take that action.  */
1394   yyn += yytoken;
1395   if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1396     goto yydefault;
1397   yyn = yytable[yyn];
1398   if (yyn <= 0)
1399     {
1400       if (yytable_value_is_error (yyn))
1401         goto yyerrlab;
1402       yyn = -yyn;
1403       goto yyreduce;
1404     }
1405
1406   /* Count tokens shifted since error; after three, turn off error
1407      status.  */
1408   if (yyerrstatus)
1409     yyerrstatus--;
1410
1411   /* Shift the lookahead token.  */
1412   YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1413   yystate = yyn;
1414   YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1415   *++yyvsp = yylval;
1416   YY_IGNORE_MAYBE_UNINITIALIZED_END
1417
1418   /* Discard the shifted token.  */
1419   yychar = YYEMPTY;
1420   goto yynewstate;
1421
1422
1423 /*-----------------------------------------------------------.
1424 | yydefault -- do the default action for the current state.  |
1425 `-----------------------------------------------------------*/
1426 yydefault:
1427   yyn = yydefact[yystate];
1428   if (yyn == 0)
1429     goto yyerrlab;
1430   goto yyreduce;
1431
1432
1433 /*-----------------------------.
1434 | yyreduce -- do a reduction.  |
1435 `-----------------------------*/
1436 yyreduce:
1437   /* yyn is the number of a rule to reduce with.  */
1438   yylen = yyr2[yyn];
1439
1440   /* If YYLEN is nonzero, implement the default value of the action:
1441      '$$ = $1'.
1442
1443      Otherwise, the following line sets YYVAL to garbage.
1444      This behavior is undocumented and Bison
1445      users should not rely upon it.  Assigning to YYVAL
1446      unconditionally makes the parser a bit smaller, and it avoids a
1447      GCC warning that YYVAL may be used uninitialized.  */
1448   yyval = yyvsp[1-yylen];
1449
1450
1451   YY_REDUCE_PRINT (yyn);
1452   switch (yyn)
1453     {
1454   case 2: /* $@1: %empty  */
1455 #line 196 "p-exp.y"
1456                 { current_type = NULL;
1457                   search_field = 0;
1458                   leftdiv_is_integer = 0;
1459                 }
1460 #line 1462 "p-exp.c.tmp"
1461     break;
1462
1463   case 3: /* start: $@1 normal_start  */
1464 #line 200 "p-exp.y"
1465                              {}
1466 #line 1468 "p-exp.c.tmp"
1467     break;
1468
1469   case 6: /* type_exp: type  */
1470 #line 209 "p-exp.y"
1471                         {
1472                           pstate->push_new<type_operation> ((yyvsp[0].tval));
1473                           current_type = (yyvsp[0].tval); }
1474 #line 1476 "p-exp.c.tmp"
1475     break;
1476
1477   case 8: /* exp1: exp1 ',' exp  */
1478 #line 216 "p-exp.y"
1479                         { pstate->wrap2<comma_operation> (); }
1480 #line 1482 "p-exp.c.tmp"
1481     break;
1482
1483   case 9: /* exp: exp '^'  */
1484 #line 221 "p-exp.y"
1485                         { pstate->wrap<unop_ind_operation> ();
1486                           if (current_type)
1487                             current_type = current_type->target_type (); }
1488 #line 1490 "p-exp.c.tmp"
1489     break;
1490
1491   case 10: /* exp: '@' exp  */
1492 #line 227 "p-exp.y"
1493                         { pstate->wrap<unop_addr_operation> ();
1494                           if (current_type)
1495                             current_type = TYPE_POINTER_TYPE (current_type); }
1496 #line 1498 "p-exp.c.tmp"
1497     break;
1498
1499   case 11: /* exp: '-' exp  */
1500 #line 233 "p-exp.y"
1501                         { pstate->wrap<unary_neg_operation> (); }
1502 #line 1504 "p-exp.c.tmp"
1503     break;
1504
1505   case 12: /* exp: NOT exp  */
1506 #line 237 "p-exp.y"
1507                         { pstate->wrap<unary_logical_not_operation> (); }
1508 #line 1510 "p-exp.c.tmp"
1509     break;
1510
1511   case 13: /* exp: INCREMENT '(' exp ')'  */
1512 #line 241 "p-exp.y"
1513                         { pstate->wrap<preinc_operation> (); }
1514 #line 1516 "p-exp.c.tmp"
1515     break;
1516
1517   case 14: /* exp: DECREMENT '(' exp ')'  */
1518 #line 245 "p-exp.y"
1519                         { pstate->wrap<predec_operation> (); }
1520 #line 1522 "p-exp.c.tmp"
1521     break;
1522
1523   case 15: /* field_exp: exp '.'  */
1524 #line 250 "p-exp.y"
1525                         { search_field = 1; }
1526 #line 1528 "p-exp.c.tmp"
1527     break;
1528
1529   case 16: /* exp: field_exp FIELDNAME  */
1530 #line 254 "p-exp.y"
1531                         {
1532                           pstate->push_new<structop_operation>
1533                             (pstate->pop (), copy_name ((yyvsp[0].sval)));
1534                           search_field = 0;
1535                           if (current_type)
1536                             {
1537                               while (current_type->code ()
1538                                      == TYPE_CODE_PTR)
1539                                 current_type =
1540                                   current_type->target_type ();
1541                               current_type = lookup_struct_elt_type (
1542                                 current_type, (yyvsp[0].sval).ptr, 0);
1543                             }
1544                          }
1545 #line 1547 "p-exp.c.tmp"
1546     break;
1547
1548   case 17: /* exp: field_exp name  */
1549 #line 272 "p-exp.y"
1550                         {
1551                           pstate->push_new<structop_operation>
1552                             (pstate->pop (), copy_name ((yyvsp[0].sval)));
1553                           search_field = 0;
1554                           if (current_type)
1555                             {
1556                               while (current_type->code ()
1557                                      == TYPE_CODE_PTR)
1558                                 current_type =
1559                                   current_type->target_type ();
1560                               current_type = lookup_struct_elt_type (
1561                                 current_type, (yyvsp[0].sval).ptr, 0);
1562                             }
1563                         }
1564 #line 1566 "p-exp.c.tmp"
1565     break;
1566
1567   case 18: /* exp: field_exp name COMPLETE  */
1568 #line 288 "p-exp.y"
1569                         {
1570                           structop_base_operation *op
1571                             = new structop_ptr_operation (pstate->pop (),
1572                                                           copy_name ((yyvsp[-1].sval)));
1573                           pstate->mark_struct_expression (op);
1574                           pstate->push (operation_up (op));
1575                         }
1576 #line 1578 "p-exp.c.tmp"
1577     break;
1578
1579   case 19: /* exp: field_exp COMPLETE  */
1580 #line 297 "p-exp.y"
1581                         {
1582                           structop_base_operation *op
1583                             = new structop_ptr_operation (pstate->pop (), "");
1584                           pstate->mark_struct_expression (op);
1585                           pstate->push (operation_up (op));
1586                         }
1587 #line 1589 "p-exp.c.tmp"
1588     break;
1589
1590   case 20: /* $@2: %empty  */
1591 #line 307 "p-exp.y"
1592                         { const char *arrayname;
1593                           int arrayfieldindex
1594                             = pascal_is_string_type (current_type, NULL, NULL,
1595                                                      NULL, NULL, &arrayname);
1596                           if (arrayfieldindex)
1597                             {
1598                               current_type
1599                                 = (current_type
1600                                    ->field (arrayfieldindex - 1).type ());
1601                               pstate->push_new<structop_operation>
1602                                 (pstate->pop (), arrayname);
1603                             }
1604                           push_current_type ();  }
1605 #line 1607 "p-exp.c.tmp"
1606     break;
1607
1608   case 21: /* exp: exp '[' $@2 exp1 ']'  */
1609 #line 321 "p-exp.y"
1610                         { pop_current_type ();
1611                           pstate->wrap2<subscript_operation> ();
1612                           if (current_type)
1613                             current_type = current_type->target_type (); }
1614 #line 1616 "p-exp.c.tmp"
1615     break;
1616
1617   case 22: /* $@3: %empty  */
1618 #line 330 "p-exp.y"
1619                         { push_current_type ();
1620                           pstate->start_arglist (); }
1621 #line 1623 "p-exp.c.tmp"
1622     break;
1623
1624   case 23: /* exp: exp '(' $@3 arglist ')'  */
1625 #line 333 "p-exp.y"
1626                         {
1627                           std::vector<operation_up> args
1628                             = pstate->pop_vector (pstate->end_arglist ());
1629                           pstate->push_new<funcall_operation>
1630                             (pstate->pop (), std::move (args));
1631                           pop_current_type ();
1632                           if (current_type)
1633                             current_type = current_type->target_type ();
1634                         }
1635 #line 1637 "p-exp.c.tmp"
1636     break;
1637
1638   case 25: /* arglist: exp  */
1639 #line 346 "p-exp.y"
1640                         { pstate->arglist_len = 1; }
1641 #line 1643 "p-exp.c.tmp"
1642     break;
1643
1644   case 26: /* arglist: arglist ',' exp  */
1645 #line 348 "p-exp.y"
1646                         { pstate->arglist_len++; }
1647 #line 1649 "p-exp.c.tmp"
1648     break;
1649
1650   case 27: /* exp: type '(' exp ')'  */
1651 #line 352 "p-exp.y"
1652                         { if (current_type)
1653                             {
1654                               /* Allow automatic dereference of classes.  */
1655                               if ((current_type->code () == TYPE_CODE_PTR)
1656                                   && (current_type->target_type ()->code () == TYPE_CODE_STRUCT)
1657                                   && (((yyvsp[-3].tval))->code () == TYPE_CODE_STRUCT))
1658                                 pstate->wrap<unop_ind_operation> ();
1659                             }
1660                           pstate->push_new<unop_cast_operation>
1661                             (pstate->pop (), (yyvsp[-3].tval));
1662                           current_type = (yyvsp[-3].tval); }
1663 #line 1665 "p-exp.c.tmp"
1664     break;
1665
1666   case 28: /* exp: '(' exp1 ')'  */
1667 #line 366 "p-exp.y"
1668                         { }
1669 #line 1671 "p-exp.c.tmp"
1670     break;
1671
1672   case 29: /* exp: exp '*' exp  */
1673 #line 372 "p-exp.y"
1674                         { pstate->wrap2<mul_operation> (); }
1675 #line 1677 "p-exp.c.tmp"
1676     break;
1677
1678   case 30: /* $@4: %empty  */
1679 #line 375 "p-exp.y"
1680                         {
1681                           if (current_type && is_integral_type (current_type))
1682                             leftdiv_is_integer = 1;
1683                         }
1684 #line 1686 "p-exp.c.tmp"
1685     break;
1686
1687   case 31: /* exp: exp '/' $@4 exp  */
1688 #line 380 "p-exp.y"
1689                         {
1690                           if (leftdiv_is_integer && current_type
1691                               && is_integral_type (current_type))
1692                             {
1693                               pstate->push_new<unop_cast_operation>
1694                                 (pstate->pop (),
1695                                  parse_type (pstate)->builtin_long_double);
1696                               current_type
1697                                 = parse_type (pstate)->builtin_long_double;
1698                               leftdiv_is_integer = 0;
1699                             }
1700
1701                           pstate->wrap2<div_operation> ();
1702                         }
1703 #line 1705 "p-exp.c.tmp"
1704     break;
1705
1706   case 32: /* exp: exp DIV exp  */
1707 #line 397 "p-exp.y"
1708                         { pstate->wrap2<intdiv_operation> (); }
1709 #line 1711 "p-exp.c.tmp"
1710     break;
1711
1712   case 33: /* exp: exp MOD exp  */
1713 #line 401 "p-exp.y"
1714                         { pstate->wrap2<rem_operation> (); }
1715 #line 1717 "p-exp.c.tmp"
1716     break;
1717
1718   case 34: /* exp: exp '+' exp  */
1719 #line 405 "p-exp.y"
1720                         { pstate->wrap2<add_operation> (); }
1721 #line 1723 "p-exp.c.tmp"
1722     break;
1723
1724   case 35: /* exp: exp '-' exp  */
1725 #line 409 "p-exp.y"
1726                         { pstate->wrap2<sub_operation> (); }
1727 #line 1729 "p-exp.c.tmp"
1728     break;
1729
1730   case 36: /* exp: exp LSH exp  */
1731 #line 413 "p-exp.y"
1732                         { pstate->wrap2<lsh_operation> (); }
1733 #line 1735 "p-exp.c.tmp"
1734     break;
1735
1736   case 37: /* exp: exp RSH exp  */
1737 #line 417 "p-exp.y"
1738                         { pstate->wrap2<rsh_operation> (); }
1739 #line 1741 "p-exp.c.tmp"
1740     break;
1741
1742   case 38: /* exp: exp '=' exp  */
1743 #line 421 "p-exp.y"
1744                         {
1745                           pstate->wrap2<equal_operation> ();
1746                           current_type = parse_type (pstate)->builtin_bool;
1747                         }
1748 #line 1750 "p-exp.c.tmp"
1749     break;
1750
1751   case 39: /* exp: exp NOTEQUAL exp  */
1752 #line 428 "p-exp.y"
1753                         {
1754                           pstate->wrap2<notequal_operation> ();
1755                           current_type = parse_type (pstate)->builtin_bool;
1756                         }
1757 #line 1759 "p-exp.c.tmp"
1758     break;
1759
1760   case 40: /* exp: exp LEQ exp  */
1761 #line 435 "p-exp.y"
1762                         {
1763                           pstate->wrap2<leq_operation> ();
1764                           current_type = parse_type (pstate)->builtin_bool;
1765                         }
1766 #line 1768 "p-exp.c.tmp"
1767     break;
1768
1769   case 41: /* exp: exp GEQ exp  */
1770 #line 442 "p-exp.y"
1771                         {
1772                           pstate->wrap2<geq_operation> ();
1773                           current_type = parse_type (pstate)->builtin_bool;
1774                         }
1775 #line 1777 "p-exp.c.tmp"
1776     break;
1777
1778   case 42: /* exp: exp '<' exp  */
1779 #line 449 "p-exp.y"
1780                         {
1781                           pstate->wrap2<less_operation> ();
1782                           current_type = parse_type (pstate)->builtin_bool;
1783                         }
1784 #line 1786 "p-exp.c.tmp"
1785     break;
1786
1787   case 43: /* exp: exp '>' exp  */
1788 #line 456 "p-exp.y"
1789                         {
1790                           pstate->wrap2<gtr_operation> ();
1791                           current_type = parse_type (pstate)->builtin_bool;
1792                         }
1793 #line 1795 "p-exp.c.tmp"
1794     break;
1795
1796   case 44: /* exp: exp ANDAND exp  */
1797 #line 463 "p-exp.y"
1798                         { pstate->wrap2<bitwise_and_operation> (); }
1799 #line 1801 "p-exp.c.tmp"
1800     break;
1801
1802   case 45: /* exp: exp XOR exp  */
1803 #line 467 "p-exp.y"
1804                         { pstate->wrap2<bitwise_xor_operation> (); }
1805 #line 1807 "p-exp.c.tmp"
1806     break;
1807
1808   case 46: /* exp: exp OR exp  */
1809 #line 471 "p-exp.y"
1810                         { pstate->wrap2<bitwise_ior_operation> (); }
1811 #line 1813 "p-exp.c.tmp"
1812     break;
1813
1814   case 47: /* exp: exp ASSIGN exp  */
1815 #line 475 "p-exp.y"
1816                         { pstate->wrap2<assign_operation> (); }
1817 #line 1819 "p-exp.c.tmp"
1818     break;
1819
1820   case 48: /* exp: TRUEKEYWORD  */
1821 #line 479 "p-exp.y"
1822                         {
1823                           pstate->push_new<bool_operation> ((yyvsp[0].lval));
1824                           current_type = parse_type (pstate)->builtin_bool;
1825                         }
1826 #line 1828 "p-exp.c.tmp"
1827     break;
1828
1829   case 49: /* exp: FALSEKEYWORD  */
1830 #line 486 "p-exp.y"
1831                         {
1832                           pstate->push_new<bool_operation> ((yyvsp[0].lval));
1833                           current_type = parse_type (pstate)->builtin_bool;
1834                         }
1835 #line 1837 "p-exp.c.tmp"
1836     break;
1837
1838   case 50: /* exp: INT  */
1839 #line 493 "p-exp.y"
1840                         {
1841                           pstate->push_new<long_const_operation>
1842                             ((yyvsp[0].typed_val_int).type, (yyvsp[0].typed_val_int).val);
1843                           current_type = (yyvsp[0].typed_val_int).type;
1844                         }
1845 #line 1847 "p-exp.c.tmp"
1846     break;
1847
1848   case 51: /* exp: NAME_OR_INT  */
1849 #line 501 "p-exp.y"
1850                         { YYSTYPE val;
1851                           parse_number (pstate, (yyvsp[0].ssym).stoken.ptr,
1852                                         (yyvsp[0].ssym).stoken.length, 0, &val);
1853                           pstate->push_new<long_const_operation>
1854                             (val.typed_val_int.type,
1855                              val.typed_val_int.val);
1856                           current_type = val.typed_val_int.type;
1857                         }
1858 #line 1860 "p-exp.c.tmp"
1859     break;
1860
1861   case 52: /* exp: FLOAT  */
1862 #line 513 "p-exp.y"
1863                         {
1864                           float_data data;
1865                           std::copy (std::begin ((yyvsp[0].typed_val_float).val), std::end ((yyvsp[0].typed_val_float).val),
1866                                      std::begin (data));
1867                           pstate->push_new<float_const_operation> ((yyvsp[0].typed_val_float).type, data);
1868                         }
1869 #line 1871 "p-exp.c.tmp"
1870     break;
1871
1872   case 54: /* exp: DOLLAR_VARIABLE  */
1873 #line 525 "p-exp.y"
1874                         {
1875                           pstate->push_dollar ((yyvsp[0].sval));
1876
1877                           /* $ is the normal prefix for pascal
1878                              hexadecimal values but this conflicts
1879                              with the GDB use for debugger variables
1880                              so in expression to enter hexadecimal
1881                              values we still need to use C syntax with
1882                              0xff */
1883                           std::string tmp ((yyvsp[0].sval).ptr, (yyvsp[0].sval).length);
1884                           /* Handle current_type.  */
1885                           struct internalvar *intvar
1886                             = lookup_only_internalvar (tmp.c_str () + 1);
1887                           if (intvar != nullptr)
1888                             {
1889                               scoped_value_mark mark;
1890
1891                               value *val
1892                                 = value_of_internalvar (pstate->gdbarch (),
1893                                                         intvar);
1894                               current_type = value_type (val);
1895                             }
1896                         }
1897 #line 1899 "p-exp.c.tmp"
1898     break;
1899
1900   case 55: /* exp: SIZEOF '(' type ')'  */
1901 #line 551 "p-exp.y"
1902                         {
1903                           current_type = parse_type (pstate)->builtin_int;
1904                           (yyvsp[-1].tval) = check_typedef ((yyvsp[-1].tval));
1905                           pstate->push_new<long_const_operation>
1906                             (parse_type (pstate)->builtin_int,
1907                              (yyvsp[-1].tval)->length ()); }
1908 #line 1910 "p-exp.c.tmp"
1909     break;
1910
1911   case 56: /* exp: SIZEOF '(' exp ')'  */
1912 #line 560 "p-exp.y"
1913                         { pstate->wrap<unop_sizeof_operation> ();
1914                           current_type = parse_type (pstate)->builtin_int; }
1915 #line 1917 "p-exp.c.tmp"
1916     break;
1917
1918   case 57: /* exp: STRING  */
1919 #line 564 "p-exp.y"
1920                         { /* C strings are converted into array constants with
1921                              an explicit null byte added at the end.  Thus
1922                              the array upper bound is the string length.
1923                              There is no such thing in C as a completely empty
1924                              string.  */
1925                           const char *sp = (yyvsp[0].sval).ptr; int count = (yyvsp[0].sval).length;
1926
1927                           std::vector<operation_up> args (count + 1);
1928                           for (int i = 0; i < count; ++i)
1929                             args[i] = (make_operation<long_const_operation>
1930                                        (parse_type (pstate)->builtin_char,
1931                                         *sp++));
1932                           args[count] = (make_operation<long_const_operation>
1933                                          (parse_type (pstate)->builtin_char,
1934                                           '\0'));
1935                           pstate->push_new<array_operation>
1936                             (0, (yyvsp[0].sval).length, std::move (args));
1937                         }
1938 #line 1940 "p-exp.c.tmp"
1939     break;
1940
1941   case 58: /* exp: THIS  */
1942 #line 586 "p-exp.y"
1943                         {
1944                           struct value * this_val;
1945                           struct type * this_type;
1946                           pstate->push_new<op_this_operation> ();
1947                           /* We need type of this.  */
1948                           this_val
1949                             = value_of_this_silent (pstate->language ());
1950                           if (this_val)
1951                             this_type = value_type (this_val);
1952                           else
1953                             this_type = NULL;
1954                           if (this_type)
1955                             {
1956                               if (this_type->code () == TYPE_CODE_PTR)
1957                                 {
1958                                   this_type = this_type->target_type ();
1959                                   pstate->wrap<unop_ind_operation> ();
1960                                 }
1961                             }
1962
1963                           current_type = this_type;
1964                         }
1965 #line 1967 "p-exp.c.tmp"
1966     break;
1967
1968   case 59: /* block: BLOCKNAME  */
1969 #line 613 "p-exp.y"
1970                         {
1971                           if ((yyvsp[0].ssym).sym.symbol != 0)
1972                               (yyval.bval) = (yyvsp[0].ssym).sym.symbol->value_block ();
1973                           else
1974                             {
1975                               std::string copy = copy_name ((yyvsp[0].ssym).stoken);
1976                               struct symtab *tem =
1977                                   lookup_symtab (copy.c_str ());
1978                               if (tem)
1979                                 (yyval.bval) = (tem->compunit ()->blockvector ()
1980                                       ->static_block ());
1981                               else
1982                                 error (_("No file or function \"%s\"."),
1983                                        copy.c_str ());
1984                             }
1985                         }
1986 #line 1988 "p-exp.c.tmp"
1987     break;
1988
1989   case 60: /* block: block COLONCOLON name  */
1990 #line 632 "p-exp.y"
1991                         {
1992                           std::string copy = copy_name ((yyvsp[0].sval));
1993                           struct symbol *tem
1994                             = lookup_symbol (copy.c_str (), (yyvsp[-2].bval),
1995                                              VAR_DOMAIN, NULL).symbol;
1996
1997                           if (!tem || tem->aclass () != LOC_BLOCK)
1998                             error (_("No function \"%s\" in specified context."),
1999                                    copy.c_str ());
2000                           (yyval.bval) = tem->value_block (); }
2001 #line 2003 "p-exp.c.tmp"
2002     break;
2003
2004   case 61: /* variable: block COLONCOLON name  */
2005 #line 645 "p-exp.y"
2006                         { struct block_symbol sym;
2007
2008                           std::string copy = copy_name ((yyvsp[0].sval));
2009                           sym = lookup_symbol (copy.c_str (), (yyvsp[-2].bval),
2010                                                VAR_DOMAIN, NULL);
2011                           if (sym.symbol == 0)
2012                             error (_("No symbol \"%s\" in specified context."),
2013                                    copy.c_str ());
2014
2015                           pstate->push_new<var_value_operation> (sym);
2016                         }
2017 #line 2019 "p-exp.c.tmp"
2018     break;
2019
2020   case 62: /* qualified_name: typebase COLONCOLON name  */
2021 #line 659 "p-exp.y"
2022                         {
2023                           struct type *type = (yyvsp[-2].tval);
2024
2025                           if (type->code () != TYPE_CODE_STRUCT
2026                               && type->code () != TYPE_CODE_UNION)
2027                             error (_("`%s' is not defined as an aggregate type."),
2028                                    type->name ());
2029
2030                           pstate->push_new<scope_operation>
2031                             (type, copy_name ((yyvsp[0].sval)));
2032                         }
2033 #line 2035 "p-exp.c.tmp"
2034     break;
2035
2036   case 64: /* variable: COLONCOLON name  */
2037 #line 674 "p-exp.y"
2038                         {
2039                           std::string name = copy_name ((yyvsp[0].sval));
2040
2041                           struct block_symbol sym
2042                             = lookup_symbol (name.c_str (), nullptr,
2043                                              VAR_DOMAIN, nullptr);
2044                           pstate->push_symbol (name.c_str (), sym);
2045                         }
2046 #line 2048 "p-exp.c.tmp"
2047     break;
2048
2049   case 65: /* variable: name_not_typename  */
2050 #line 685 "p-exp.y"
2051                         { struct block_symbol sym = (yyvsp[0].ssym).sym;
2052
2053                           if (sym.symbol)
2054                             {
2055                               if (symbol_read_needs_frame (sym.symbol))
2056                                 pstate->block_tracker->update (sym);
2057
2058                               pstate->push_new<var_value_operation> (sym);
2059                               current_type = sym.symbol->type (); }
2060                           else if ((yyvsp[0].ssym).is_a_field_of_this)
2061                             {
2062                               struct value * this_val;
2063                               struct type * this_type;
2064                               /* Object pascal: it hangs off of `this'.  Must
2065                                  not inadvertently convert from a method call
2066                                  to data ref.  */
2067                               pstate->block_tracker->update (sym);
2068                               operation_up thisop
2069                                 = make_operation<op_this_operation> ();
2070                               pstate->push_new<structop_operation>
2071                                 (std::move (thisop), copy_name ((yyvsp[0].ssym).stoken));
2072                               /* We need type of this.  */
2073                               this_val
2074                                 = value_of_this_silent (pstate->language ());
2075                               if (this_val)
2076                                 this_type = value_type (this_val);
2077                               else
2078                                 this_type = NULL;
2079                               if (this_type)
2080                                 current_type = lookup_struct_elt_type (
2081                                   this_type,
2082                                   copy_name ((yyvsp[0].ssym).stoken).c_str (), 0);
2083                               else
2084                                 current_type = NULL;
2085                             }
2086                           else
2087                             {
2088                               struct bound_minimal_symbol msymbol;
2089                               std::string arg = copy_name ((yyvsp[0].ssym).stoken);
2090
2091                               msymbol =
2092                                 lookup_bound_minimal_symbol (arg.c_str ());
2093                               if (msymbol.minsym != NULL)
2094                                 pstate->push_new<var_msym_value_operation>
2095                                   (msymbol);
2096                               else if (!have_full_symbols ()
2097                                        && !have_partial_symbols ())
2098                                 error (_("No symbol table is loaded.  "
2099                                        "Use the \"file\" command."));
2100                               else
2101                                 error (_("No symbol \"%s\" in current context."),
2102                                        arg.c_str ());
2103                             }
2104                         }
2105 #line 2107 "p-exp.c.tmp"
2106     break;
2107
2108   case 68: /* typebase: '^' typebase  */
2109 #line 758 "p-exp.y"
2110                         { (yyval.tval) = lookup_pointer_type ((yyvsp[0].tval)); }
2111 #line 2113 "p-exp.c.tmp"
2112     break;
2113
2114   case 69: /* typebase: TYPENAME  */
2115 #line 760 "p-exp.y"
2116                         { (yyval.tval) = (yyvsp[0].tsym).type; }
2117 #line 2119 "p-exp.c.tmp"
2118     break;
2119
2120   case 70: /* typebase: STRUCT name  */
2121 #line 762 "p-exp.y"
2122                         { (yyval.tval)
2123                             = lookup_struct (copy_name ((yyvsp[0].sval)).c_str (),
2124                                              pstate->expression_context_block);
2125                         }
2126 #line 2128 "p-exp.c.tmp"
2127     break;
2128
2129   case 71: /* typebase: CLASS name  */
2130 #line 767 "p-exp.y"
2131                         { (yyval.tval)
2132                             = lookup_struct (copy_name ((yyvsp[0].sval)).c_str (),
2133                                              pstate->expression_context_block);
2134                         }
2135 #line 2137 "p-exp.c.tmp"
2136     break;
2137
2138   case 72: /* name: NAME  */
2139 #line 776 "p-exp.y"
2140                      { (yyval.sval) = (yyvsp[0].ssym).stoken; }
2141 #line 2143 "p-exp.c.tmp"
2142     break;
2143
2144   case 73: /* name: BLOCKNAME  */
2145 #line 777 "p-exp.y"
2146                           { (yyval.sval) = (yyvsp[0].ssym).stoken; }
2147 #line 2149 "p-exp.c.tmp"
2148     break;
2149
2150   case 74: /* name: TYPENAME  */
2151 #line 778 "p-exp.y"
2152                          { (yyval.sval) = (yyvsp[0].tsym).stoken; }
2153 #line 2155 "p-exp.c.tmp"
2154     break;
2155
2156   case 75: /* name: NAME_OR_INT  */
2157 #line 779 "p-exp.y"
2158                              { (yyval.sval) = (yyvsp[0].ssym).stoken; }
2159 #line 2161 "p-exp.c.tmp"
2160     break;
2161
2162
2163 #line 2165 "p-exp.c.tmp"
2164
2165       default: break;
2166     }
2167   /* User semantic actions sometimes alter yychar, and that requires
2168      that yytoken be updated with the new translation.  We take the
2169      approach of translating immediately before every use of yytoken.
2170      One alternative is translating here after every semantic action,
2171      but that translation would be missed if the semantic action invokes
2172      YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
2173      if it invokes YYBACKUP.  In the case of YYABORT or YYACCEPT, an
2174      incorrect destructor might then be invoked immediately.  In the
2175      case of YYERROR or YYBACKUP, subsequent parser actions might lead
2176      to an incorrect destructor call or verbose syntax error message
2177      before the lookahead is translated.  */
2178   YY_SYMBOL_PRINT ("-> $$ =", YY_CAST (yysymbol_kind_t, yyr1[yyn]), &yyval, &yyloc);
2179
2180   YYPOPSTACK (yylen);
2181   yylen = 0;
2182
2183   *++yyvsp = yyval;
2184
2185   /* Now 'shift' the result of the reduction.  Determine what state
2186      that goes to, based on the state we popped back to and the rule
2187      number reduced by.  */
2188   {
2189     const int yylhs = yyr1[yyn] - YYNTOKENS;
2190     const int yyi = yypgoto[yylhs] + *yyssp;
2191     yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp
2192                ? yytable[yyi]
2193                : yydefgoto[yylhs]);
2194   }
2195
2196   goto yynewstate;
2197
2198
2199 /*--------------------------------------.
2200 | yyerrlab -- here on detecting error.  |
2201 `--------------------------------------*/
2202 yyerrlab:
2203   /* Make sure we have latest lookahead translation.  See comments at
2204      user semantic actions for why this is necessary.  */
2205   yytoken = yychar == YYEMPTY ? YYSYMBOL_YYEMPTY : YYTRANSLATE (yychar);
2206   /* If not already recovering from an error, report this error.  */
2207   if (!yyerrstatus)
2208     {
2209       ++yynerrs;
2210       yyerror (YY_("syntax error"));
2211     }
2212
2213   if (yyerrstatus == 3)
2214     {
2215       /* If just tried and failed to reuse lookahead token after an
2216          error, discard it.  */
2217
2218       if (yychar <= YYEOF)
2219         {
2220           /* Return failure if at end of input.  */
2221           if (yychar == YYEOF)
2222             YYABORT;
2223         }
2224       else
2225         {
2226           yydestruct ("Error: discarding",
2227                       yytoken, &yylval);
2228           yychar = YYEMPTY;
2229         }
2230     }
2231
2232   /* Else will try to reuse lookahead token after shifting the error
2233      token.  */
2234   goto yyerrlab1;
2235
2236
2237 /*---------------------------------------------------.
2238 | yyerrorlab -- error raised explicitly by YYERROR.  |
2239 `---------------------------------------------------*/
2240 yyerrorlab:
2241   /* Pacify compilers when the user code never invokes YYERROR and the
2242      label yyerrorlab therefore never appears in user code.  */
2243   if (0)
2244     YYERROR;
2245   ++yynerrs;
2246
2247   /* Do not reclaim the symbols of the rule whose action triggered
2248      this YYERROR.  */
2249   YYPOPSTACK (yylen);
2250   yylen = 0;
2251   YY_STACK_PRINT (yyss, yyssp);
2252   yystate = *yyssp;
2253   goto yyerrlab1;
2254
2255
2256 /*-------------------------------------------------------------.
2257 | yyerrlab1 -- common code for both syntax error and YYERROR.  |
2258 `-------------------------------------------------------------*/
2259 yyerrlab1:
2260   yyerrstatus = 3;      /* Each real token shifted decrements this.  */
2261
2262   /* Pop stack until we find a state that shifts the error token.  */
2263   for (;;)
2264     {
2265       yyn = yypact[yystate];
2266       if (!yypact_value_is_default (yyn))
2267         {
2268           yyn += YYSYMBOL_YYerror;
2269           if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYSYMBOL_YYerror)
2270             {
2271               yyn = yytable[yyn];
2272               if (0 < yyn)
2273                 break;
2274             }
2275         }
2276
2277       /* Pop the current state because it cannot handle the error token.  */
2278       if (yyssp == yyss)
2279         YYABORT;
2280
2281
2282       yydestruct ("Error: popping",
2283                   YY_ACCESSING_SYMBOL (yystate), yyvsp);
2284       YYPOPSTACK (1);
2285       yystate = *yyssp;
2286       YY_STACK_PRINT (yyss, yyssp);
2287     }
2288
2289   YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
2290   *++yyvsp = yylval;
2291   YY_IGNORE_MAYBE_UNINITIALIZED_END
2292
2293
2294   /* Shift the error token.  */
2295   YY_SYMBOL_PRINT ("Shifting", YY_ACCESSING_SYMBOL (yyn), yyvsp, yylsp);
2296
2297   yystate = yyn;
2298   goto yynewstate;
2299
2300
2301 /*-------------------------------------.
2302 | yyacceptlab -- YYACCEPT comes here.  |
2303 `-------------------------------------*/
2304 yyacceptlab:
2305   yyresult = 0;
2306   goto yyreturnlab;
2307
2308
2309 /*-----------------------------------.
2310 | yyabortlab -- YYABORT comes here.  |
2311 `-----------------------------------*/
2312 yyabortlab:
2313   yyresult = 1;
2314   goto yyreturnlab;
2315
2316
2317 /*-----------------------------------------------------------.
2318 | yyexhaustedlab -- YYNOMEM (memory exhaustion) comes here.  |
2319 `-----------------------------------------------------------*/
2320 yyexhaustedlab:
2321   yyerror (YY_("memory exhausted"));
2322   yyresult = 2;
2323   goto yyreturnlab;
2324
2325
2326 /*----------------------------------------------------------.
2327 | yyreturnlab -- parsing is finished, clean up and return.  |
2328 `----------------------------------------------------------*/
2329 yyreturnlab:
2330   if (yychar != YYEMPTY)
2331     {
2332       /* Make sure we have latest lookahead translation.  See comments at
2333          user semantic actions for why this is necessary.  */
2334       yytoken = YYTRANSLATE (yychar);
2335       yydestruct ("Cleanup: discarding lookahead",
2336                   yytoken, &yylval);
2337     }
2338   /* Do not reclaim the symbols of the rule whose action triggered
2339      this YYABORT or YYACCEPT.  */
2340   YYPOPSTACK (yylen);
2341   YY_STACK_PRINT (yyss, yyssp);
2342   while (yyssp != yyss)
2343     {
2344       yydestruct ("Cleanup: popping",
2345                   YY_ACCESSING_SYMBOL (+*yyssp), yyvsp);
2346       YYPOPSTACK (1);
2347     }
2348 #ifndef yyoverflow
2349   if (yyss != yyssa)
2350     YYSTACK_FREE (yyss);
2351 #endif
2352
2353   return yyresult;
2354 }
2355
2356 #line 793 "p-exp.y"
2357
2358
2359 /* Take care of parsing a number (anything that starts with a digit).
2360    Set yylval and return the token type; update lexptr.
2361    LEN is the number of characters in it.  */
2362
2363 /*** Needs some error checking for the float case ***/
2364
2365 static int
2366 parse_number (struct parser_state *par_state,
2367               const char *p, int len, int parsed_float, YYSTYPE *putithere)
2368 {
2369   ULONGEST n = 0;
2370   ULONGEST prevn = 0;
2371
2372   int i = 0;
2373   int c;
2374   int base = input_radix;
2375   int unsigned_p = 0;
2376
2377   /* Number of "L" suffixes encountered.  */
2378   int long_p = 0;
2379
2380   /* We have found a "L" or "U" suffix.  */
2381   int found_suffix = 0;
2382
2383   if (parsed_float)
2384     {
2385       /* Handle suffixes: 'f' for float, 'l' for long double.
2386          FIXME: This appears to be an extension -- do we want this?  */
2387       if (len >= 1 && tolower (p[len - 1]) == 'f')
2388         {
2389           putithere->typed_val_float.type
2390             = parse_type (par_state)->builtin_float;
2391           len--;
2392         }
2393       else if (len >= 1 && tolower (p[len - 1]) == 'l')
2394         {
2395           putithere->typed_val_float.type
2396             = parse_type (par_state)->builtin_long_double;
2397           len--;
2398         }
2399       /* Default type for floating-point literals is double.  */
2400       else
2401         {
2402           putithere->typed_val_float.type
2403             = parse_type (par_state)->builtin_double;
2404         }
2405
2406       if (!parse_float (p, len,
2407                         putithere->typed_val_float.type,
2408                         putithere->typed_val_float.val))
2409         return ERROR;
2410       return FLOAT;
2411     }
2412
2413   /* Handle base-switching prefixes 0x, 0t, 0d, 0.  */
2414   if (p[0] == '0' && len > 1)
2415     switch (p[1])
2416       {
2417       case 'x':
2418       case 'X':
2419         if (len >= 3)
2420           {
2421             p += 2;
2422             base = 16;
2423             len -= 2;
2424           }
2425         break;
2426
2427       case 't':
2428       case 'T':
2429       case 'd':
2430       case 'D':
2431         if (len >= 3)
2432           {
2433             p += 2;
2434             base = 10;
2435             len -= 2;
2436           }
2437         break;
2438
2439       default:
2440         base = 8;
2441         break;
2442       }
2443
2444   while (len-- > 0)
2445     {
2446       c = *p++;
2447       if (c >= 'A' && c <= 'Z')
2448         c += 'a' - 'A';
2449       if (c != 'l' && c != 'u')
2450         n *= base;
2451       if (c >= '0' && c <= '9')
2452         {
2453           if (found_suffix)
2454             return ERROR;
2455           n += i = c - '0';
2456         }
2457       else
2458         {
2459           if (base > 10 && c >= 'a' && c <= 'f')
2460             {
2461               if (found_suffix)
2462                 return ERROR;
2463               n += i = c - 'a' + 10;
2464             }
2465           else if (c == 'l')
2466             {
2467               ++long_p;
2468               found_suffix = 1;
2469             }
2470           else if (c == 'u')
2471             {
2472               unsigned_p = 1;
2473               found_suffix = 1;
2474             }
2475           else
2476             return ERROR;       /* Char not a digit */
2477         }
2478       if (i >= base)
2479         return ERROR;           /* Invalid digit in this base.  */
2480
2481       if (c != 'l' && c != 'u')
2482         {
2483           /* Test for overflow.  */
2484           if (prevn == 0 && n == 0)
2485             ;
2486           else if (prevn >= n)
2487             error (_("Numeric constant too large."));
2488         }
2489       prevn = n;
2490     }
2491
2492   /* An integer constant is an int, a long, or a long long.  An L
2493      suffix forces it to be long; an LL suffix forces it to be long
2494      long.  If not forced to a larger size, it gets the first type of
2495      the above that it fits in.  To figure out whether it fits, we
2496      shift it right and see whether anything remains.  Note that we
2497      can't shift sizeof (LONGEST) * HOST_CHAR_BIT bits or more in one
2498      operation, because many compilers will warn about such a shift
2499      (which always produces a zero result).  Sometimes gdbarch_int_bit
2500      or gdbarch_long_bit will be that big, sometimes not.  To deal with
2501      the case where it is we just always shift the value more than
2502      once, with fewer bits each time.  */
2503
2504   int int_bits = gdbarch_int_bit (par_state->gdbarch ());
2505   int long_bits = gdbarch_long_bit (par_state->gdbarch ());
2506   int long_long_bits = gdbarch_long_long_bit (par_state->gdbarch ());
2507   bool have_signed = !unsigned_p;
2508   bool have_int = long_p == 0;
2509   bool have_long = long_p <= 1;
2510   if (have_int && have_signed && fits_in_type (1, n, int_bits, true))
2511     putithere->typed_val_int.type = parse_type (par_state)->builtin_int;
2512   else if (have_int && fits_in_type (1, n, int_bits, false))
2513     putithere->typed_val_int.type
2514       = parse_type (par_state)->builtin_unsigned_int;
2515   else if (have_long && have_signed && fits_in_type (1, n, long_bits, true))
2516     putithere->typed_val_int.type = parse_type (par_state)->builtin_long;
2517   else if (have_long && fits_in_type (1, n, long_bits, false))
2518     putithere->typed_val_int.type
2519       = parse_type (par_state)->builtin_unsigned_long;
2520   else if (have_signed && fits_in_type (1, n, long_long_bits, true))
2521     putithere->typed_val_int.type
2522       = parse_type (par_state)->builtin_long_long;
2523   else if (fits_in_type (1, n, long_long_bits, false))
2524     putithere->typed_val_int.type
2525       = parse_type (par_state)->builtin_unsigned_long_long;
2526   else
2527     error (_("Numeric constant too large."));
2528   putithere->typed_val_int.val = n;
2529
2530    return INT;
2531 }
2532
2533
2534 struct type_push
2535 {
2536   struct type *stored;
2537   struct type_push *next;
2538 };
2539
2540 static struct type_push *tp_top = NULL;
2541
2542 static void
2543 push_current_type (void)
2544 {
2545   struct type_push *tpnew;
2546   tpnew = (struct type_push *) xmalloc (sizeof (struct type_push));
2547   tpnew->next = tp_top;
2548   tpnew->stored = current_type;
2549   current_type = NULL;
2550   tp_top = tpnew;
2551 }
2552
2553 static void
2554 pop_current_type (void)
2555 {
2556   struct type_push *tp = tp_top;
2557   if (tp)
2558     {
2559       current_type = tp->stored;
2560       tp_top = tp->next;
2561       xfree (tp);
2562     }
2563 }
2564
2565 struct token
2566 {
2567   const char *oper;
2568   int token;
2569   enum exp_opcode opcode;
2570 };
2571
2572 static const struct token tokentab3[] =
2573   {
2574     {"shr", RSH, OP_NULL},
2575     {"shl", LSH, OP_NULL},
2576     {"and", ANDAND, OP_NULL},
2577     {"div", DIV, OP_NULL},
2578     {"not", NOT, OP_NULL},
2579     {"mod", MOD, OP_NULL},
2580     {"inc", INCREMENT, OP_NULL},
2581     {"dec", DECREMENT, OP_NULL},
2582     {"xor", XOR, OP_NULL}
2583   };
2584
2585 static const struct token tokentab2[] =
2586   {
2587     {"or", OR, OP_NULL},
2588     {"<>", NOTEQUAL, OP_NULL},
2589     {"<=", LEQ, OP_NULL},
2590     {">=", GEQ, OP_NULL},
2591     {":=", ASSIGN, OP_NULL},
2592     {"::", COLONCOLON, OP_NULL} };
2593
2594 /* Allocate uppercased var: */
2595 /* make an uppercased copy of tokstart.  */
2596 static char *
2597 uptok (const char *tokstart, int namelen)
2598 {
2599   int i;
2600   char *uptokstart = (char *)xmalloc(namelen+1);
2601   for (i = 0;i <= namelen;i++)
2602     {
2603       if ((tokstart[i]>='a' && tokstart[i]<='z'))
2604         uptokstart[i] = tokstart[i]-('a'-'A');
2605       else
2606         uptokstart[i] = tokstart[i];
2607     }
2608   uptokstart[namelen]='\0';
2609   return uptokstart;
2610 }
2611
2612 /* Read one token, getting characters through lexptr.  */
2613
2614 static int
2615 yylex (void)
2616 {
2617   int c;
2618   int namelen;
2619   const char *tokstart;
2620   char *uptokstart;
2621   const char *tokptr;
2622   int explen, tempbufindex;
2623   static char *tempbuf;
2624   static int tempbufsize;
2625
2626  retry:
2627
2628   pstate->prev_lexptr = pstate->lexptr;
2629
2630   tokstart = pstate->lexptr;
2631   explen = strlen (pstate->lexptr);
2632
2633   /* See if it is a special token of length 3.  */
2634   if (explen > 2)
2635     for (const auto &token : tokentab3)
2636       if (strncasecmp (tokstart, token.oper, 3) == 0
2637           && (!isalpha (token.oper[0]) || explen == 3
2638               || (!isalpha (tokstart[3])
2639                   && !isdigit (tokstart[3]) && tokstart[3] != '_')))
2640         {
2641           pstate->lexptr += 3;
2642           yylval.opcode = token.opcode;
2643           return token.token;
2644         }
2645
2646   /* See if it is a special token of length 2.  */
2647   if (explen > 1)
2648     for (const auto &token : tokentab2)
2649       if (strncasecmp (tokstart, token.oper, 2) == 0
2650           && (!isalpha (token.oper[0]) || explen == 2
2651               || (!isalpha (tokstart[2])
2652                   && !isdigit (tokstart[2]) && tokstart[2] != '_')))
2653         {
2654           pstate->lexptr += 2;
2655           yylval.opcode = token.opcode;
2656           return token.token;
2657         }
2658
2659   switch (c = *tokstart)
2660     {
2661     case 0:
2662       if (search_field && pstate->parse_completion)
2663         return COMPLETE;
2664       else
2665        return 0;
2666
2667     case ' ':
2668     case '\t':
2669     case '\n':
2670       pstate->lexptr++;
2671       goto retry;
2672
2673     case '\'':
2674       /* We either have a character constant ('0' or '\177' for example)
2675          or we have a quoted symbol reference ('foo(int,int)' in object pascal
2676          for example).  */
2677       pstate->lexptr++;
2678       c = *pstate->lexptr++;
2679       if (c == '\\')
2680         c = parse_escape (pstate->gdbarch (), &pstate->lexptr);
2681       else if (c == '\'')
2682         error (_("Empty character constant."));
2683
2684       yylval.typed_val_int.val = c;
2685       yylval.typed_val_int.type = parse_type (pstate)->builtin_char;
2686
2687       c = *pstate->lexptr++;
2688       if (c != '\'')
2689         {
2690           namelen = skip_quoted (tokstart) - tokstart;
2691           if (namelen > 2)
2692             {
2693               pstate->lexptr = tokstart + namelen;
2694               if (pstate->lexptr[-1] != '\'')
2695                 error (_("Unmatched single quote."));
2696               namelen -= 2;
2697               tokstart++;
2698               uptokstart = uptok(tokstart,namelen);
2699               goto tryname;
2700             }
2701           error (_("Invalid character constant."));
2702         }
2703       return INT;
2704
2705     case '(':
2706       paren_depth++;
2707       pstate->lexptr++;
2708       return c;
2709
2710     case ')':
2711       if (paren_depth == 0)
2712         return 0;
2713       paren_depth--;
2714       pstate->lexptr++;
2715       return c;
2716
2717     case ',':
2718       if (pstate->comma_terminates && paren_depth == 0)
2719         return 0;
2720       pstate->lexptr++;
2721       return c;
2722
2723     case '.':
2724       /* Might be a floating point number.  */
2725       if (pstate->lexptr[1] < '0' || pstate->lexptr[1] > '9')
2726         {
2727           goto symbol;          /* Nope, must be a symbol.  */
2728         }
2729
2730       /* FALL THRU.  */
2731
2732     case '0':
2733     case '1':
2734     case '2':
2735     case '3':
2736     case '4':
2737     case '5':
2738     case '6':
2739     case '7':
2740     case '8':
2741     case '9':
2742       {
2743         /* It's a number.  */
2744         int got_dot = 0, got_e = 0, toktype;
2745         const char *p = tokstart;
2746         int hex = input_radix > 10;
2747
2748         if (c == '0' && (p[1] == 'x' || p[1] == 'X'))
2749           {
2750             p += 2;
2751             hex = 1;
2752           }
2753         else if (c == '0' && (p[1]=='t' || p[1]=='T'
2754                               || p[1]=='d' || p[1]=='D'))
2755           {
2756             p += 2;
2757             hex = 0;
2758           }
2759
2760         for (;; ++p)
2761           {
2762             /* This test includes !hex because 'e' is a valid hex digit
2763                and thus does not indicate a floating point number when
2764                the radix is hex.  */
2765             if (!hex && !got_e && (*p == 'e' || *p == 'E'))
2766               got_dot = got_e = 1;
2767             /* This test does not include !hex, because a '.' always indicates
2768                a decimal floating point number regardless of the radix.  */
2769             else if (!got_dot && *p == '.')
2770               got_dot = 1;
2771             else if (got_e && (p[-1] == 'e' || p[-1] == 'E')
2772                      && (*p == '-' || *p == '+'))
2773               /* This is the sign of the exponent, not the end of the
2774                  number.  */
2775               continue;
2776             /* We will take any letters or digits.  parse_number will
2777                complain if past the radix, or if L or U are not final.  */
2778             else if ((*p < '0' || *p > '9')
2779                      && ((*p < 'a' || *p > 'z')
2780                                   && (*p < 'A' || *p > 'Z')))
2781               break;
2782           }
2783         toktype = parse_number (pstate, tokstart,
2784                                 p - tokstart, got_dot | got_e, &yylval);
2785         if (toktype == ERROR)
2786           {
2787             char *err_copy = (char *) alloca (p - tokstart + 1);
2788
2789             memcpy (err_copy, tokstart, p - tokstart);
2790             err_copy[p - tokstart] = 0;
2791             error (_("Invalid number \"%s\"."), err_copy);
2792           }
2793         pstate->lexptr = p;
2794         return toktype;
2795       }
2796
2797     case '+':
2798     case '-':
2799     case '*':
2800     case '/':
2801     case '|':
2802     case '&':
2803     case '^':
2804     case '~':
2805     case '!':
2806     case '@':
2807     case '<':
2808     case '>':
2809     case '[':
2810     case ']':
2811     case '?':
2812     case ':':
2813     case '=':
2814     case '{':
2815     case '}':
2816     symbol:
2817       pstate->lexptr++;
2818       return c;
2819
2820     case '"':
2821
2822       /* Build the gdb internal form of the input string in tempbuf,
2823          translating any standard C escape forms seen.  Note that the
2824          buffer is null byte terminated *only* for the convenience of
2825          debugging gdb itself and printing the buffer contents when
2826          the buffer contains no embedded nulls.  Gdb does not depend
2827          upon the buffer being null byte terminated, it uses the length
2828          string instead.  This allows gdb to handle C strings (as well
2829          as strings in other languages) with embedded null bytes.  */
2830
2831       tokptr = ++tokstart;
2832       tempbufindex = 0;
2833
2834       do {
2835         /* Grow the static temp buffer if necessary, including allocating
2836            the first one on demand.  */
2837         if (tempbufindex + 1 >= tempbufsize)
2838           {
2839             tempbuf = (char *) xrealloc (tempbuf, tempbufsize += 64);
2840           }
2841
2842         switch (*tokptr)
2843           {
2844           case '\0':
2845           case '"':
2846             /* Do nothing, loop will terminate.  */
2847             break;
2848           case '\\':
2849             ++tokptr;
2850             c = parse_escape (pstate->gdbarch (), &tokptr);
2851             if (c == -1)
2852               {
2853                 continue;
2854               }
2855             tempbuf[tempbufindex++] = c;
2856             break;
2857           default:
2858             tempbuf[tempbufindex++] = *tokptr++;
2859             break;
2860           }
2861       } while ((*tokptr != '"') && (*tokptr != '\0'));
2862       if (*tokptr++ != '"')
2863         {
2864           error (_("Unterminated string in expression."));
2865         }
2866       tempbuf[tempbufindex] = '\0';     /* See note above.  */
2867       yylval.sval.ptr = tempbuf;
2868       yylval.sval.length = tempbufindex;
2869       pstate->lexptr = tokptr;
2870       return (STRING);
2871     }
2872
2873   if (!(c == '_' || c == '$'
2874         || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')))
2875     /* We must have come across a bad character (e.g. ';').  */
2876     error (_("Invalid character '%c' in expression."), c);
2877
2878   /* It's a name.  See how long it is.  */
2879   namelen = 0;
2880   for (c = tokstart[namelen];
2881        (c == '_' || c == '$' || (c >= '0' && c <= '9')
2882         || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '<');)
2883     {
2884       /* Template parameter lists are part of the name.
2885          FIXME: This mishandles `print $a<4&&$a>3'.  */
2886       if (c == '<')
2887         {
2888           int i = namelen;
2889           int nesting_level = 1;
2890           while (tokstart[++i])
2891             {
2892               if (tokstart[i] == '<')
2893                 nesting_level++;
2894               else if (tokstart[i] == '>')
2895                 {
2896                   if (--nesting_level == 0)
2897                     break;
2898                 }
2899             }
2900           if (tokstart[i] == '>')
2901             namelen = i;
2902           else
2903             break;
2904         }
2905
2906       /* do NOT uppercase internals because of registers !!!  */
2907       c = tokstart[++namelen];
2908     }
2909
2910   uptokstart = uptok(tokstart,namelen);
2911
2912   /* The token "if" terminates the expression and is NOT
2913      removed from the input stream.  */
2914   if (namelen == 2 && uptokstart[0] == 'I' && uptokstart[1] == 'F')
2915     {
2916       xfree (uptokstart);
2917       return 0;
2918     }
2919
2920   pstate->lexptr += namelen;
2921
2922   tryname:
2923
2924   /* Catch specific keywords.  Should be done with a data structure.  */
2925   switch (namelen)
2926     {
2927     case 6:
2928       if (strcmp (uptokstart, "OBJECT") == 0)
2929         {
2930           xfree (uptokstart);
2931           return CLASS;
2932         }
2933       if (strcmp (uptokstart, "RECORD") == 0)
2934         {
2935           xfree (uptokstart);
2936           return STRUCT;
2937         }
2938       if (strcmp (uptokstart, "SIZEOF") == 0)
2939         {
2940           xfree (uptokstart);
2941           return SIZEOF;
2942         }
2943       break;
2944     case 5:
2945       if (strcmp (uptokstart, "CLASS") == 0)
2946         {
2947           xfree (uptokstart);
2948           return CLASS;
2949         }
2950       if (strcmp (uptokstart, "FALSE") == 0)
2951         {
2952           yylval.lval = 0;
2953           xfree (uptokstart);
2954           return FALSEKEYWORD;
2955         }
2956       break;
2957     case 4:
2958       if (strcmp (uptokstart, "TRUE") == 0)
2959         {
2960           yylval.lval = 1;
2961           xfree (uptokstart);
2962           return TRUEKEYWORD;
2963         }
2964       if (strcmp (uptokstart, "SELF") == 0)
2965         {
2966           /* Here we search for 'this' like
2967              inserted in FPC stabs debug info.  */
2968           static const char this_name[] = "this";
2969
2970           if (lookup_symbol (this_name, pstate->expression_context_block,
2971                              VAR_DOMAIN, NULL).symbol)
2972             {
2973               xfree (uptokstart);
2974               return THIS;
2975             }
2976         }
2977       break;
2978     default:
2979       break;
2980     }
2981
2982   yylval.sval.ptr = tokstart;
2983   yylval.sval.length = namelen;
2984
2985   if (*tokstart == '$')
2986     {
2987       xfree (uptokstart);
2988       return DOLLAR_VARIABLE;
2989     }
2990
2991   /* Use token-type BLOCKNAME for symbols that happen to be defined as
2992      functions or symtabs.  If this is not so, then ...
2993      Use token-type TYPENAME for symbols that happen to be defined
2994      currently as names of types; NAME for other symbols.
2995      The caller is not constrained to care about the distinction.  */
2996   {
2997     std::string tmp = copy_name (yylval.sval);
2998     struct symbol *sym;
2999     struct field_of_this_result is_a_field_of_this;
3000     int is_a_field = 0;
3001     int hextype;
3002
3003     is_a_field_of_this.type = NULL;
3004     if (search_field && current_type)
3005       is_a_field = (lookup_struct_elt_type (current_type,
3006                                             tmp.c_str (), 1) != NULL);
3007     if (is_a_field)
3008       sym = NULL;
3009     else
3010       sym = lookup_symbol (tmp.c_str (), pstate->expression_context_block,
3011                            VAR_DOMAIN, &is_a_field_of_this).symbol;
3012     /* second chance uppercased (as Free Pascal does).  */
3013     if (!sym && is_a_field_of_this.type == NULL && !is_a_field)
3014       {
3015        for (int i = 0; i <= namelen; i++)
3016          {
3017            if ((tmp[i] >= 'a' && tmp[i] <= 'z'))
3018              tmp[i] -= ('a'-'A');
3019          }
3020        if (search_field && current_type)
3021          is_a_field = (lookup_struct_elt_type (current_type,
3022                                                tmp.c_str (), 1) != NULL);
3023        if (is_a_field)
3024          sym = NULL;
3025        else
3026          sym = lookup_symbol (tmp.c_str (), pstate->expression_context_block,
3027                               VAR_DOMAIN, &is_a_field_of_this).symbol;
3028       }
3029     /* Third chance Capitalized (as GPC does).  */
3030     if (!sym && is_a_field_of_this.type == NULL && !is_a_field)
3031       {
3032        for (int i = 0; i <= namelen; i++)
3033          {
3034            if (i == 0)
3035              {
3036               if ((tmp[i] >= 'a' && tmp[i] <= 'z'))
3037                 tmp[i] -= ('a'-'A');
3038              }
3039            else
3040            if ((tmp[i] >= 'A' && tmp[i] <= 'Z'))
3041              tmp[i] -= ('A'-'a');
3042           }
3043        if (search_field && current_type)
3044          is_a_field = (lookup_struct_elt_type (current_type,
3045                                                tmp.c_str (), 1) != NULL);
3046        if (is_a_field)
3047          sym = NULL;
3048        else
3049          sym = lookup_symbol (tmp.c_str (), pstate->expression_context_block,
3050                               VAR_DOMAIN, &is_a_field_of_this).symbol;
3051       }
3052
3053     if (is_a_field || (is_a_field_of_this.type != NULL))
3054       {
3055         tempbuf = (char *) xrealloc (tempbuf, namelen + 1);
3056         strncpy (tempbuf, tmp.c_str (), namelen);
3057         tempbuf [namelen] = 0;
3058         yylval.sval.ptr = tempbuf;
3059         yylval.sval.length = namelen;
3060         yylval.ssym.sym.symbol = NULL;
3061         yylval.ssym.sym.block = NULL;
3062         xfree (uptokstart);
3063         yylval.ssym.is_a_field_of_this = is_a_field_of_this.type != NULL;
3064         if (is_a_field)
3065           return FIELDNAME;
3066         else
3067           return NAME;
3068       }
3069     /* Call lookup_symtab, not lookup_partial_symtab, in case there are
3070        no psymtabs (coff, xcoff, or some future change to blow away the
3071        psymtabs once once symbols are read).  */
3072     if ((sym && sym->aclass () == LOC_BLOCK)
3073         || lookup_symtab (tmp.c_str ()))
3074       {
3075         yylval.ssym.sym.symbol = sym;
3076         yylval.ssym.sym.block = NULL;
3077         yylval.ssym.is_a_field_of_this = is_a_field_of_this.type != NULL;
3078         xfree (uptokstart);
3079         return BLOCKNAME;
3080       }
3081     if (sym && sym->aclass () == LOC_TYPEDEF)
3082         {
3083 #if 1
3084           /* Despite the following flaw, we need to keep this code enabled.
3085              Because we can get called from check_stub_method, if we don't
3086              handle nested types then it screws many operations in any
3087              program which uses nested types.  */
3088           /* In "A::x", if x is a member function of A and there happens
3089              to be a type (nested or not, since the stabs don't make that
3090              distinction) named x, then this code incorrectly thinks we
3091              are dealing with nested types rather than a member function.  */
3092
3093           const char *p;
3094           const char *namestart;
3095           struct symbol *best_sym;
3096
3097           /* Look ahead to detect nested types.  This probably should be
3098              done in the grammar, but trying seemed to introduce a lot
3099              of shift/reduce and reduce/reduce conflicts.  It's possible
3100              that it could be done, though.  Or perhaps a non-grammar, but
3101              less ad hoc, approach would work well.  */
3102
3103           /* Since we do not currently have any way of distinguishing
3104              a nested type from a non-nested one (the stabs don't tell
3105              us whether a type is nested), we just ignore the
3106              containing type.  */
3107
3108           p = pstate->lexptr;
3109           best_sym = sym;
3110           while (1)
3111             {
3112               /* Skip whitespace.  */
3113               while (*p == ' ' || *p == '\t' || *p == '\n')
3114                 ++p;
3115               if (*p == ':' && p[1] == ':')
3116                 {
3117                   /* Skip the `::'.  */
3118                   p += 2;
3119                   /* Skip whitespace.  */
3120                   while (*p == ' ' || *p == '\t' || *p == '\n')
3121                     ++p;
3122                   namestart = p;
3123                   while (*p == '_' || *p == '$' || (*p >= '0' && *p <= '9')
3124                          || (*p >= 'a' && *p <= 'z')
3125                          || (*p >= 'A' && *p <= 'Z'))
3126                     ++p;
3127                   if (p != namestart)
3128                     {
3129                       struct symbol *cur_sym;
3130                       /* As big as the whole rest of the expression, which is
3131                          at least big enough.  */
3132                       char *ncopy
3133                         = (char *) alloca (tmp.size () + strlen (namestart)
3134                                            + 3);
3135                       char *tmp1;
3136
3137                       tmp1 = ncopy;
3138                       memcpy (tmp1, tmp.c_str (), tmp.size ());
3139                       tmp1 += tmp.size ();
3140                       memcpy (tmp1, "::", 2);
3141                       tmp1 += 2;
3142                       memcpy (tmp1, namestart, p - namestart);
3143                       tmp1[p - namestart] = '\0';
3144                       cur_sym
3145                         = lookup_symbol (ncopy,
3146                                          pstate->expression_context_block,
3147                                          VAR_DOMAIN, NULL).symbol;
3148                       if (cur_sym)
3149                         {
3150                           if (cur_sym->aclass () == LOC_TYPEDEF)
3151                             {
3152                               best_sym = cur_sym;
3153                               pstate->lexptr = p;
3154                             }
3155                           else
3156                             break;
3157                         }
3158                       else
3159                         break;
3160                     }
3161                   else
3162                     break;
3163                 }
3164               else
3165                 break;
3166             }
3167
3168           yylval.tsym.type = best_sym->type ();
3169 #else /* not 0 */
3170           yylval.tsym.type = sym->type ();
3171 #endif /* not 0 */
3172           xfree (uptokstart);
3173           return TYPENAME;
3174         }
3175     yylval.tsym.type
3176       = language_lookup_primitive_type (pstate->language (),
3177                                         pstate->gdbarch (), tmp.c_str ());
3178     if (yylval.tsym.type != NULL)
3179       {
3180         xfree (uptokstart);
3181         return TYPENAME;
3182       }
3183
3184     /* Input names that aren't symbols but ARE valid hex numbers,
3185        when the input radix permits them, can be names or numbers
3186        depending on the parse.  Note we support radixes > 16 here.  */
3187     if (!sym
3188         && ((tokstart[0] >= 'a' && tokstart[0] < 'a' + input_radix - 10)
3189             || (tokstart[0] >= 'A' && tokstart[0] < 'A' + input_radix - 10)))
3190       {
3191         YYSTYPE newlval;        /* Its value is ignored.  */
3192         hextype = parse_number (pstate, tokstart, namelen, 0, &newlval);
3193         if (hextype == INT)
3194           {
3195             yylval.ssym.sym.symbol = sym;
3196             yylval.ssym.sym.block = NULL;
3197             yylval.ssym.is_a_field_of_this = is_a_field_of_this.type != NULL;
3198             xfree (uptokstart);
3199             return NAME_OR_INT;
3200           }
3201       }
3202
3203     xfree(uptokstart);
3204     /* Any other kind of symbol.  */
3205     yylval.ssym.sym.symbol = sym;
3206     yylval.ssym.sym.block = NULL;
3207     return NAME;
3208   }
3209 }
3210
3211 /* See language.h.  */
3212
3213 int
3214 pascal_language::parser (struct parser_state *par_state) const
3215 {
3216   /* Setting up the parser state.  */
3217   scoped_restore pstate_restore = make_scoped_restore (&pstate);
3218   gdb_assert (par_state != NULL);
3219   pstate = par_state;
3220   paren_depth = 0;
3221
3222   int result = yyparse ();
3223   if (!result)
3224     pstate->set_operation (pstate->pop ());
3225   return result;
3226 }
3227
3228 static void
3229 yyerror (const char *msg)
3230 {
3231   if (pstate->prev_lexptr)
3232     pstate->lexptr = pstate->prev_lexptr;
3233
3234   error (_("A %s in expression, near `%s'."), msg, pstate->lexptr);
3235 }