1 /* A Bison parser, made by GNU Bison 3.8.2. */
3 /* Bison implementation for Yacc-like parsers in C
5 Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2021 Free Software Foundation,
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.
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.
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/>. */
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.
31 This special exception was added by the Free Software Foundation in
32 version 2.2 of Bison. */
34 /* C LALR(1) parser skeleton written by Richard Stallman, by
35 simplifying the original so-called "semantic" parser. */
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. */
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. */
48 /* Identify Bison output, and Bison version. */
51 /* Bison version string. */
52 #define YYBISON_VERSION "3.8.2"
55 #define YYSKELETON_NAME "yacc.c"
69 /* First part of user prologue. */
75 #include "expression.h"
77 #include "parser-defs.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. */
84 #include "completer.h"
87 #define parse_type(ps) builtin_type (ps->gdbarch ())
89 /* Remap normal yacc parser interface names (yyparse, yylex, yyerror,
91 #define GDB_YY_REMAP_PREFIX pascal_
94 /* The state of the parser, used internally when we are parsing the
97 static struct parser_state *pstate = NULL;
99 /* Depth of parentheses. */
100 static int paren_depth;
104 static int yylex (void);
106 static void yyerror (const char *);
108 static char *uptok (const char *, int);
110 using namespace expr;
112 #line 113 "p-exp.c.tmp"
116 # define YY_CAST(Type, Val) static_cast<Type> (Val)
117 # define YY_REINTERPRET_CAST(Type, Val) reinterpret_cast<Type> (Val)
119 # define YY_CAST(Type, Val) ((Type) (Val))
120 # define YY_REINTERPRET_CAST(Type, Val) ((Type) (Val))
123 # ifndef YY_NULLPTRPTR
124 # if defined __cplusplus
125 # if 201103L <= __cplusplus
126 # define YY_NULLPTRPTR nullptr
128 # define YY_NULLPTRPTR 0
131 # define YY_NULLPTRPTR ((void*)0)
150 YYEOF = 0, /* "end of file" */
151 YYerror = 256, /* error */
152 YYUNDEF = 257, /* "invalid token" */
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 */
175 ANDAND = 280, /* ANDAND */
176 NOTEQUAL = 281, /* NOTEQUAL */
183 UNARY = 288, /* UNARY */
184 INCREMENT = 289, /* INCREMENT */
185 DECREMENT = 290, /* DECREMENT */
186 ARROW = 291, /* ARROW */
187 BLOCKNAME = 292 /* BLOCKNAME */
189 typedef enum yytokentype yytoken_kind_t;
199 #define FIELDNAME 261
203 #define NAME_OR_INT 265
207 #define COLONCOLON 269
209 #define DOLLAR_VARIABLE 271
211 #define TRUEKEYWORD 273
212 #define FALSEKEYWORD 274
213 #define ABOVE_COMMA 275
227 #define INCREMENT 289
228 #define DECREMENT 290
230 #define BLOCKNAME 292
233 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
251 struct symtoken ssym;
253 const struct block *bval;
254 enum exp_opcode opcode;
255 struct internalvar *ivar;
261 #line 262 "p-exp.c.tmp"
264 typedef union YYSTYPE YYSTYPE;
265 # define YYSTYPE_IS_TRIVIAL 1
266 # define YYSTYPE_IS_DECLARED 1
270 extern YYSTYPE yylval;
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 */
355 typedef enum yysymbol_kind_t yysymbol_kind_t;
358 /* Second part of user prologue. */
361 /* YYSTYPE gets defined by %union */
362 static int parse_number (struct parser_state *,
363 const char *, int, int, YYSTYPE *);
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;
371 #line 372 "p-exp.c.tmp"
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. */
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 */
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. */
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;
400 typedef signed char yytype_int8;
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;
408 typedef short yytype_int16;
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>. */
417 # undef UINT_LEAST8_MAX
418 # undef UINT_LEAST16_MAX
419 # define UINT_LEAST8_MAX 255
420 # define UINT_LEAST16_MAX 65535
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;
431 typedef short yytype_uint8;
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;
442 typedef int yytype_uint16;
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
451 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
453 # define YYPTRDIFF_T ptrdiff_t
454 # define YYPTRDIFF_MAXIMUM PTRDIFF_MAX
456 # define YYPTRDIFF_T long
457 # define YYPTRDIFF_MAXIMUM LONG_MAX
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
470 # define YYSIZE_T unsigned
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)))
480 #define YYSIZEOF(X) YY_CAST (YYPTRDIFF_T, sizeof (X))
483 /* Stored state numbers (used for stacks). */
484 typedef yytype_int8 yy_state_t;
486 /* State numbers in computations. */
487 typedef int yy_state_fast_t;
490 # if defined YYENABLE_NLS && YYENABLE_NLS
492 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
493 # define YY_(Msgid) dgettext ("bison-runtime", Msgid)
497 # define YY_(Msgid) Msgid
502 #ifndef YY_ATTRIBUTE_PURE
503 # if defined __GNUC__ && 2 < __GNUC__ + (96 <= __GNUC_MINOR__)
504 # define YY_ATTRIBUTE_PURE __attribute__ ((__pure__))
506 # define YY_ATTRIBUTE_PURE
510 #ifndef YY_ATTRIBUTE_UNUSED
511 # if defined __GNUC__ && 2 < __GNUC__ + (7 <= __GNUC_MINOR__)
512 # define YY_ATTRIBUTE_UNUSED __attribute__ ((__unused__))
514 # define YY_ATTRIBUTE_UNUSED
518 /* Suppress unused-variable warnings by "using" E. */
519 #if ! defined lint || defined __GNUC__
520 # define YY_USE(E) ((void) (E))
522 # define YY_USE(E) /* empty */
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\"")
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\"")
537 # define YY_IGNORE_MAYBE_UNINITIALIZED_END \
538 _Pragma ("GCC diagnostic pop")
540 # define YY_INITIAL_VALUE(Value) Value
542 #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
543 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
544 # define YY_IGNORE_MAYBE_UNINITIALIZED_END
546 #ifndef YY_INITIAL_VALUE
547 # define YY_INITIAL_VALUE(Value) /* Nothing. */
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")
557 #ifndef YY_IGNORE_USELESS_CAST_BEGIN
558 # define YY_IGNORE_USELESS_CAST_BEGIN
559 # define YY_IGNORE_USELESS_CAST_END
563 #define YY_ASSERT(E) ((void) (0 && (E)))
565 #if !defined yyoverflow
567 /* The parser invokes alloca or xmalloc; define the necessary symbols. */
569 # ifdef YYSTACK_USE_ALLOCA
570 # if YYSTACK_USE_ALLOCA
572 # define YYSTACK_ALLOC __builtin_alloca
573 # elif defined __BUILTIN_VA_ARG_INCR
574 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
576 # define YYSTACK_ALLOC __alloca
577 # elif defined _MSC_VER
578 # define alloca _alloca
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
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 */
603 # define YYSTACK_ALLOC YYMALLOC
604 # define YYSTACK_FREE YYFREE
605 # ifndef YYSTACK_ALLOC_MAXIMUM
606 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
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
617 # define YYMALLOC xmalloc
618 # if ! defined xmalloc && ! defined EXIT_SUCCESS
619 void *xmalloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
623 # define YYFREE xfree
624 # if ! defined xfree && ! defined EXIT_SUCCESS
625 void xfree (void *); /* INFRINGES ON USER NAME SPACE */
629 #endif /* !defined yyoverflow */
631 #if (! defined yyoverflow \
632 && (! defined __cplusplus \
633 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
635 /* A type that is properly aligned for any stack member. */
638 yy_state_t yyss_alloc;
642 /* The size of the maximum gap between one aligned stack and the next. */
643 # define YYSTACK_GAP_MAXIMUM (YYSIZEOF (union yyalloc) - 1)
645 /* The size of an array large to enough to hold all stacks, each with
647 # define YYSTACK_BYTES(N) \
648 ((N) * (YYSIZEOF (yy_state_t) + YYSIZEOF (YYSTYPE)) \
649 + YYSTACK_GAP_MAXIMUM)
651 # define YYCOPY_NEEDED 1
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
658 # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
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); \
671 #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
672 /* Copy COUNT objects from SRC to DST. The source and destination do
675 # if defined __GNUC__ && 1 < __GNUC__
676 # define YYCOPY(Dst, Src, Count) \
677 __builtin_memcpy (Dst, Src, YY_CAST (YYSIZE_T, (Count)) * sizeof (*(Src)))
679 # define YYCOPY(Dst, Src, Count) \
683 for (yyi = 0; yyi < (Count); yyi++) \
684 (Dst)[yyi] = (Src)[yyi]; \
689 #endif /* !YYCOPY_NEEDED */
691 /* YYFINAL -- State number of the termination state. */
693 /* YYLAST -- Last index in YYTABLE. */
696 /* YYNTOKENS -- Number of terminals. */
698 /* YYNNTS -- Number of nonterminals. */
700 /* YYNRULES -- Number of rules. */
702 /* YYNSTATES -- Number of states. */
703 #define YYNSTATES 126
705 /* YYMAXUTOK -- Last valid token kind. */
706 #define YYMAXUTOK 292
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]) \
716 /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
717 as returned by yylex. */
718 static const yytype_int8 yytranslate[] =
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,
753 /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
754 static const yytype_int16 yyrline[] =
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
767 /** Accessing symbol of state STATE. */
768 #define YY_ACCESSING_SYMBOL(State) YY_CAST (yysymbol_kind_t, yystos[State])
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;
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[] =
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
793 yysymbol_name (yysymbol_kind_t yysymbol)
795 return yytname[yysymbol];
799 #define YYPACT_NINF (-44)
801 #define yypact_value_is_default(Yyn) \
802 ((Yyn) == YYPACT_NINF)
804 #define YYTABLE_NINF (-61)
806 #define yytable_value_is_error(Yyn) \
809 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
811 static const yytype_int16 yypact[] =
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
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[] =
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,
848 /* YYPGOTO[NTERM-NUM]. */
849 static const yytype_int8 yypgoto[] =
851 -44, -44, -44, -44, -44, -20, -18, -44, -44, -44,
852 -44, -44, -44, -44, -44, -44, 16, 50, -7, -44
855 /* YYDEFGOTO[NTERM-NUM]. */
856 static const yytype_int8 yydefgoto[] =
858 0, 1, 2, 26, 27, 28, 29, 30, 107, 108,
859 120, 106, 31, 32, 33, 34, 47, 36, 42, 37
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[] =
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
907 static const yytype_int8 yycheck[] =
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
949 /* YYSTOS[STATE-NUM] -- The symbol kind of the accessing symbol of
951 static const yytype_int8 yystos[] =
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
968 /* YYR1[RULE-NUM] -- Symbol kind of the left-hand side of rule RULE-NUM. */
969 static const yytype_int8 yyr1[] =
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
981 /* YYR2[RULE-NUM] -- Number of symbols on the right-hand side of rule RULE-NUM. */
982 static const yytype_int8 yyr2[] =
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
995 enum { YYENOMEM = -2 };
997 #define yyerrok (yyerrstatus = 0)
998 #define yyclearin (yychar = YYEMPTY)
1000 #define YYACCEPT goto yyacceptlab
1001 #define YYABORT goto yyabortlab
1002 #define YYERROR goto yyerrorlab
1003 #define YYNOMEM goto yyexhaustedlab
1006 #define YYRECOVERING() (!!yyerrstatus)
1008 #define YYBACKUP(Token, Value) \
1010 if (yychar == YYEMPTY) \
1014 YYPOPSTACK (yylen); \
1020 yyerror (YY_("syntax error: cannot back up")); \
1025 /* Backward compatibility with an undocumented macro.
1026 Use YYerror or YYUNDEF. */
1027 #define YYERRCODE YYUNDEF
1030 /* Enable debugging if requested. */
1034 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
1035 # define YYFPRINTF fprintf
1038 # define YYDPRINTF(Args) \
1047 # define YY_SYMBOL_PRINT(Title, Kind, Value, Location) \
1051 YYFPRINTF (stderr, "%s ", Title); \
1052 yy_symbol_print (stderr, \
1054 YYFPRINTF (stderr, "\n"); \
1059 /*-----------------------------------.
1060 | Print this symbol's value on YYO. |
1061 `-----------------------------------*/
1064 yy_symbol_value_print (FILE *yyo,
1065 yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep)
1067 FILE *yyoutput = yyo;
1071 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1073 YY_IGNORE_MAYBE_UNINITIALIZED_END
1077 /*---------------------------.
1078 | Print this symbol on YYO. |
1079 `---------------------------*/
1082 yy_symbol_print (FILE *yyo,
1083 yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep)
1085 YYFPRINTF (yyo, "%s %s (",
1086 yykind < YYNTOKENS ? "token" : "nterm", yysymbol_name (yykind));
1088 yy_symbol_value_print (yyo, yykind, yyvaluep);
1089 YYFPRINTF (yyo, ")");
1092 /*------------------------------------------------------------------.
1093 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
1095 `------------------------------------------------------------------*/
1098 yy_stack_print (yy_state_t *yybottom, yy_state_t *yytop)
1100 YYFPRINTF (stderr, "Stack now");
1101 for (; yybottom <= yytop; yybottom++)
1103 int yybot = *yybottom;
1104 YYFPRINTF (stderr, " %d", yybot);
1106 YYFPRINTF (stderr, "\n");
1109 # define YY_STACK_PRINT(Bottom, Top) \
1112 yy_stack_print ((Bottom), (Top)); \
1116 /*------------------------------------------------.
1117 | Report that the YYRULE is going to be reduced. |
1118 `------------------------------------------------*/
1121 yy_reduce_print (yy_state_t *yyssp, YYSTYPE *yyvsp,
1124 int yylno = yyrline[yyrule];
1125 int yynrhs = yyr2[yyrule];
1127 YYFPRINTF (stderr, "Reducing stack by rule %d (line %d):\n",
1129 /* The symbols being reduced. */
1130 for (yyi = 0; yyi < yynrhs; yyi++)
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");
1140 # define YY_REDUCE_PRINT(Rule) \
1143 yy_reduce_print (yyssp, yyvsp, Rule); \
1146 /* Nonzero means print parse trace. It is left uninitialized so that
1147 multiple parsers can coexist. */
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 */
1157 /* YYINITDEPTH -- initial size of the parser's stacks. */
1159 # define YYINITDEPTH 200
1162 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
1163 if the built-in stack extension method is used).
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. */
1170 # define YYMAXDEPTH 10000
1178 /*-----------------------------------------------.
1179 | Release the memory associated to this symbol. |
1180 `-----------------------------------------------*/
1183 yydestruct (const char *yymsg,
1184 yysymbol_kind_t yykind, YYSTYPE *yyvaluep)
1189 YY_SYMBOL_PRINT (yymsg, yykind, yyvaluep, yylocationp);
1191 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1193 YY_IGNORE_MAYBE_UNINITIALIZED_END
1197 /* Lookahead token kind. */
1200 /* The semantic value of the lookahead symbol. */
1202 /* Number of syntax errors so far. */
1215 yy_state_fast_t yystate = 0;
1216 /* Number of tokens to shift before error messages enabled. */
1217 int yyerrstatus = 0;
1219 /* Refer to the stacks through separate pointers, to allow yyoverflow
1220 to xreallocate them elsewhere. */
1223 YYPTRDIFF_T yystacksize = YYINITDEPTH;
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;
1230 /* The semantic value stack: array, bottom, top. */
1231 YYSTYPE yyvsa[YYINITDEPTH];
1232 YYSTYPE *yyvs = yyvsa;
1233 YYSTYPE *yyvsp = yyvs;
1236 /* The return value of yyparse. */
1238 /* Lookahead symbol kind. */
1239 yysymbol_kind_t yytoken = YYSYMBOL_YYEMPTY;
1240 /* The variables used to return semantic value and location from the
1246 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1248 /* The number of symbols on the RHS of the reduced rule.
1249 Keep to zero when no symbol should be popped. */
1252 YYDPRINTF ((stderr, "Starting parse\n"));
1254 yychar = YYEMPTY; /* Cause a token to be read. */
1259 /*------------------------------------------------------------.
1260 | yynewstate -- push a new state, which is found in yystate. |
1261 `------------------------------------------------------------*/
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. */
1268 /*--------------------------------------------------------------------.
1269 | yysetstate -- set current state (the top of the stack) to yystate. |
1270 `--------------------------------------------------------------------*/
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);
1279 if (yyss + yystacksize - 1 <= yyssp)
1280 #if !defined yyoverflow && !defined YYSTACK_RELOCATE
1284 /* Get the current used size of the three stacks, in elements. */
1285 YYPTRDIFF_T yysize = yyssp - yyss + 1;
1287 # if defined yyoverflow
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
1292 yy_state_t *yyss1 = yyss;
1293 YYSTYPE *yyvs1 = yyvs;
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),
1306 # else /* defined YYSTACK_RELOCATE */
1307 /* Extend the stack our own way. */
1308 if (YYMAXDEPTH <= yystacksize)
1311 if (YYMAXDEPTH < yystacksize)
1312 yystacksize = YYMAXDEPTH;
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))));
1321 YYSTACK_RELOCATE (yyss_alloc, yyss);
1322 YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1323 # undef YYSTACK_RELOCATE
1325 YYSTACK_FREE (yyss1);
1329 yyssp = yyss + yysize - 1;
1330 yyvsp = yyvs + yysize - 1;
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
1337 if (yyss + yystacksize - 1 <= yyssp)
1340 #endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */
1343 if (yystate == YYFINAL)
1353 /* Do appropriate processing given the current state. Read a
1354 lookahead token if we need one and don't already have one. */
1356 /* First try to decide what to do without reference to lookahead token. */
1357 yyn = yypact[yystate];
1358 if (yypact_value_is_default (yyn))
1361 /* Not known => get a lookahead token if don't already have one. */
1363 /* YYCHAR is either empty, or end-of-input, or a valid lookahead. */
1364 if (yychar == YYEMPTY)
1366 YYDPRINTF ((stderr, "Reading a token\n"));
1370 if (yychar <= YYEOF)
1373 yytoken = YYSYMBOL_YYEOF;
1374 YYDPRINTF ((stderr, "Now at end of input.\n"));
1376 else if (yychar == YYerror)
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. */
1383 yytoken = YYSYMBOL_YYerror;
1388 yytoken = YYTRANSLATE (yychar);
1389 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1392 /* If the proper action on seeing token YYTOKEN is to reduce or to
1393 detect an error, take that action. */
1395 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1400 if (yytable_value_is_error (yyn))
1406 /* Count tokens shifted since error; after three, turn off error
1411 /* Shift the lookahead token. */
1412 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1414 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1416 YY_IGNORE_MAYBE_UNINITIALIZED_END
1418 /* Discard the shifted token. */
1423 /*-----------------------------------------------------------.
1424 | yydefault -- do the default action for the current state. |
1425 `-----------------------------------------------------------*/
1427 yyn = yydefact[yystate];
1433 /*-----------------------------.
1434 | yyreduce -- do a reduction. |
1435 `-----------------------------*/
1437 /* yyn is the number of a rule to reduce with. */
1440 /* If YYLEN is nonzero, implement the default value of the action:
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];
1451 YY_REDUCE_PRINT (yyn);
1454 case 2: /* $@1: %empty */
1456 { current_type = NULL;
1458 leftdiv_is_integer = 0;
1460 #line 1462 "p-exp.c.tmp"
1463 case 3: /* start: $@1 normal_start */
1466 #line 1468 "p-exp.c.tmp"
1469 case 6: /* type_exp: type */
1472 pstate->push_new<type_operation> ((yyvsp[0].tval));
1473 current_type = (yyvsp[0].tval); }
1474 #line 1476 "p-exp.c.tmp"
1477 case 8: /* exp1: exp1 ',' exp */
1479 { pstate->wrap2<comma_operation> (); }
1480 #line 1482 "p-exp.c.tmp"
1483 case 9: /* exp: exp '^' */
1485 { pstate->wrap<unop_ind_operation> ();
1487 current_type = current_type->target_type (); }
1488 #line 1490 "p-exp.c.tmp"
1491 case 10: /* exp: '@' exp */
1493 { pstate->wrap<unop_addr_operation> ();
1495 current_type = TYPE_POINTER_TYPE (current_type); }
1496 #line 1498 "p-exp.c.tmp"
1499 case 11: /* exp: '-' exp */
1501 { pstate->wrap<unary_neg_operation> (); }
1502 #line 1504 "p-exp.c.tmp"
1505 case 12: /* exp: NOT exp */
1507 { pstate->wrap<unary_logical_not_operation> (); }
1508 #line 1510 "p-exp.c.tmp"
1511 case 13: /* exp: INCREMENT '(' exp ')' */
1513 { pstate->wrap<preinc_operation> (); }
1514 #line 1516 "p-exp.c.tmp"
1517 case 14: /* exp: DECREMENT '(' exp ')' */
1519 { pstate->wrap<predec_operation> (); }
1520 #line 1522 "p-exp.c.tmp"
1523 case 15: /* field_exp: exp '.' */
1525 { search_field = 1; }
1526 #line 1528 "p-exp.c.tmp"
1529 case 16: /* exp: field_exp FIELDNAME */
1532 pstate->push_new<structop_operation>
1533 (pstate->pop (), copy_name ((yyvsp[0].sval)));
1537 while (current_type->code ()
1540 current_type->target_type ();
1541 current_type = lookup_struct_elt_type (
1542 current_type, (yyvsp[0].sval).ptr, 0);
1545 #line 1547 "p-exp.c.tmp"
1548 case 17: /* exp: field_exp name */
1551 pstate->push_new<structop_operation>
1552 (pstate->pop (), copy_name ((yyvsp[0].sval)));
1556 while (current_type->code ()
1559 current_type->target_type ();
1560 current_type = lookup_struct_elt_type (
1561 current_type, (yyvsp[0].sval).ptr, 0);
1564 #line 1566 "p-exp.c.tmp"
1567 case 18: /* exp: field_exp name COMPLETE */
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));
1576 #line 1578 "p-exp.c.tmp"
1579 case 19: /* exp: field_exp COMPLETE */
1582 structop_base_operation *op
1583 = new structop_ptr_operation (pstate->pop (), "");
1584 pstate->mark_struct_expression (op);
1585 pstate->push (operation_up (op));
1587 #line 1589 "p-exp.c.tmp"
1590 case 20: /* $@2: %empty */
1592 { const char *arrayname;
1594 = pascal_is_string_type (current_type, NULL, NULL,
1595 NULL, NULL, &arrayname);
1596 if (arrayfieldindex)
1600 ->field (arrayfieldindex - 1).type ());
1601 pstate->push_new<structop_operation>
1602 (pstate->pop (), arrayname);
1604 push_current_type (); }
1605 #line 1607 "p-exp.c.tmp"
1608 case 21: /* exp: exp '[' $@2 exp1 ']' */
1610 { pop_current_type ();
1611 pstate->wrap2<subscript_operation> ();
1613 current_type = current_type->target_type (); }
1614 #line 1616 "p-exp.c.tmp"
1617 case 22: /* $@3: %empty */
1619 { push_current_type ();
1620 pstate->start_arglist (); }
1621 #line 1623 "p-exp.c.tmp"
1624 case 23: /* exp: exp '(' $@3 arglist ')' */
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 ();
1633 current_type = current_type->target_type ();
1635 #line 1637 "p-exp.c.tmp"
1638 case 25: /* arglist: exp */
1640 { pstate->arglist_len = 1; }
1641 #line 1643 "p-exp.c.tmp"
1644 case 26: /* arglist: arglist ',' exp */
1646 { pstate->arglist_len++; }
1647 #line 1649 "p-exp.c.tmp"
1650 case 27: /* exp: type '(' exp ')' */
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> ();
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"
1666 case 28: /* exp: '(' exp1 ')' */
1669 #line 1671 "p-exp.c.tmp"
1672 case 29: /* exp: exp '*' exp */
1674 { pstate->wrap2<mul_operation> (); }
1675 #line 1677 "p-exp.c.tmp"
1678 case 30: /* $@4: %empty */
1681 if (current_type && is_integral_type (current_type))
1682 leftdiv_is_integer = 1;
1684 #line 1686 "p-exp.c.tmp"
1687 case 31: /* exp: exp '/' $@4 exp */
1690 if (leftdiv_is_integer && current_type
1691 && is_integral_type (current_type))
1693 pstate->push_new<unop_cast_operation>
1695 parse_type (pstate)->builtin_long_double);
1697 = parse_type (pstate)->builtin_long_double;
1698 leftdiv_is_integer = 0;
1701 pstate->wrap2<div_operation> ();
1703 #line 1705 "p-exp.c.tmp"
1706 case 32: /* exp: exp DIV exp */
1708 { pstate->wrap2<intdiv_operation> (); }
1709 #line 1711 "p-exp.c.tmp"
1712 case 33: /* exp: exp MOD exp */
1714 { pstate->wrap2<rem_operation> (); }
1715 #line 1717 "p-exp.c.tmp"
1718 case 34: /* exp: exp '+' exp */
1720 { pstate->wrap2<add_operation> (); }
1721 #line 1723 "p-exp.c.tmp"
1724 case 35: /* exp: exp '-' exp */
1726 { pstate->wrap2<sub_operation> (); }
1727 #line 1729 "p-exp.c.tmp"
1730 case 36: /* exp: exp LSH exp */
1732 { pstate->wrap2<lsh_operation> (); }
1733 #line 1735 "p-exp.c.tmp"
1736 case 37: /* exp: exp RSH exp */
1738 { pstate->wrap2<rsh_operation> (); }
1739 #line 1741 "p-exp.c.tmp"
1742 case 38: /* exp: exp '=' exp */
1745 pstate->wrap2<equal_operation> ();
1746 current_type = parse_type (pstate)->builtin_bool;
1748 #line 1750 "p-exp.c.tmp"
1751 case 39: /* exp: exp NOTEQUAL exp */
1754 pstate->wrap2<notequal_operation> ();
1755 current_type = parse_type (pstate)->builtin_bool;
1757 #line 1759 "p-exp.c.tmp"
1760 case 40: /* exp: exp LEQ exp */
1763 pstate->wrap2<leq_operation> ();
1764 current_type = parse_type (pstate)->builtin_bool;
1766 #line 1768 "p-exp.c.tmp"
1769 case 41: /* exp: exp GEQ exp */
1772 pstate->wrap2<geq_operation> ();
1773 current_type = parse_type (pstate)->builtin_bool;
1775 #line 1777 "p-exp.c.tmp"
1778 case 42: /* exp: exp '<' exp */
1781 pstate->wrap2<less_operation> ();
1782 current_type = parse_type (pstate)->builtin_bool;
1784 #line 1786 "p-exp.c.tmp"
1787 case 43: /* exp: exp '>' exp */
1790 pstate->wrap2<gtr_operation> ();
1791 current_type = parse_type (pstate)->builtin_bool;
1793 #line 1795 "p-exp.c.tmp"
1796 case 44: /* exp: exp ANDAND exp */
1798 { pstate->wrap2<bitwise_and_operation> (); }
1799 #line 1801 "p-exp.c.tmp"
1802 case 45: /* exp: exp XOR exp */
1804 { pstate->wrap2<bitwise_xor_operation> (); }
1805 #line 1807 "p-exp.c.tmp"
1808 case 46: /* exp: exp OR exp */
1810 { pstate->wrap2<bitwise_ior_operation> (); }
1811 #line 1813 "p-exp.c.tmp"
1814 case 47: /* exp: exp ASSIGN exp */
1816 { pstate->wrap2<assign_operation> (); }
1817 #line 1819 "p-exp.c.tmp"
1820 case 48: /* exp: TRUEKEYWORD */
1823 pstate->push_new<bool_operation> ((yyvsp[0].lval));
1824 current_type = parse_type (pstate)->builtin_bool;
1826 #line 1828 "p-exp.c.tmp"
1829 case 49: /* exp: FALSEKEYWORD */
1832 pstate->push_new<bool_operation> ((yyvsp[0].lval));
1833 current_type = parse_type (pstate)->builtin_bool;
1835 #line 1837 "p-exp.c.tmp"
1838 case 50: /* exp: INT */
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;
1845 #line 1847 "p-exp.c.tmp"
1848 case 51: /* exp: NAME_OR_INT */
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;
1858 #line 1860 "p-exp.c.tmp"
1861 case 52: /* exp: FLOAT */
1865 std::copy (std::begin ((yyvsp[0].typed_val_float).val), std::end ((yyvsp[0].typed_val_float).val),
1867 pstate->push_new<float_const_operation> ((yyvsp[0].typed_val_float).type, data);
1869 #line 1871 "p-exp.c.tmp"
1872 case 54: /* exp: DOLLAR_VARIABLE */
1875 pstate->push_dollar ((yyvsp[0].sval));
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
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)
1889 scoped_value_mark mark;
1892 = value_of_internalvar (pstate->gdbarch (),
1894 current_type = value_type (val);
1897 #line 1899 "p-exp.c.tmp"
1900 case 55: /* exp: SIZEOF '(' type ')' */
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"
1911 case 56: /* exp: SIZEOF '(' exp ')' */
1913 { pstate->wrap<unop_sizeof_operation> ();
1914 current_type = parse_type (pstate)->builtin_int; }
1915 #line 1917 "p-exp.c.tmp"
1918 case 57: /* exp: STRING */
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
1925 const char *sp = (yyvsp[0].sval).ptr; int count = (yyvsp[0].sval).length;
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,
1932 args[count] = (make_operation<long_const_operation>
1933 (parse_type (pstate)->builtin_char,
1935 pstate->push_new<array_operation>
1936 (0, (yyvsp[0].sval).length, std::move (args));
1938 #line 1940 "p-exp.c.tmp"
1941 case 58: /* exp: THIS */
1944 struct value * this_val;
1945 struct type * this_type;
1946 pstate->push_new<op_this_operation> ();
1947 /* We need type of this. */
1949 = value_of_this_silent (pstate->language ());
1951 this_type = value_type (this_val);
1956 if (this_type->code () == TYPE_CODE_PTR)
1958 this_type = this_type->target_type ();
1959 pstate->wrap<unop_ind_operation> ();
1963 current_type = this_type;
1965 #line 1967 "p-exp.c.tmp"
1968 case 59: /* block: BLOCKNAME */
1971 if ((yyvsp[0].ssym).sym.symbol != 0)
1972 (yyval.bval) = (yyvsp[0].ssym).sym.symbol->value_block ();
1975 std::string copy = copy_name ((yyvsp[0].ssym).stoken);
1976 struct symtab *tem =
1977 lookup_symtab (copy.c_str ());
1979 (yyval.bval) = (tem->compunit ()->blockvector ()
1982 error (_("No file or function \"%s\"."),
1986 #line 1988 "p-exp.c.tmp"
1989 case 60: /* block: block COLONCOLON name */
1992 std::string copy = copy_name ((yyvsp[0].sval));
1994 = lookup_symbol (copy.c_str (), (yyvsp[-2].bval),
1995 VAR_DOMAIN, NULL).symbol;
1997 if (!tem || tem->aclass () != LOC_BLOCK)
1998 error (_("No function \"%s\" in specified context."),
2000 (yyval.bval) = tem->value_block (); }
2001 #line 2003 "p-exp.c.tmp"
2004 case 61: /* variable: block COLONCOLON name */
2006 { struct block_symbol sym;
2008 std::string copy = copy_name ((yyvsp[0].sval));
2009 sym = lookup_symbol (copy.c_str (), (yyvsp[-2].bval),
2011 if (sym.symbol == 0)
2012 error (_("No symbol \"%s\" in specified context."),
2015 pstate->push_new<var_value_operation> (sym);
2017 #line 2019 "p-exp.c.tmp"
2020 case 62: /* qualified_name: typebase COLONCOLON name */
2023 struct type *type = (yyvsp[-2].tval);
2025 if (type->code () != TYPE_CODE_STRUCT
2026 && type->code () != TYPE_CODE_UNION)
2027 error (_("`%s' is not defined as an aggregate type."),
2030 pstate->push_new<scope_operation>
2031 (type, copy_name ((yyvsp[0].sval)));
2033 #line 2035 "p-exp.c.tmp"
2036 case 64: /* variable: COLONCOLON name */
2039 std::string name = copy_name ((yyvsp[0].sval));
2041 struct block_symbol sym
2042 = lookup_symbol (name.c_str (), nullptr,
2043 VAR_DOMAIN, nullptr);
2044 pstate->push_symbol (name.c_str (), sym);
2046 #line 2048 "p-exp.c.tmp"
2049 case 65: /* variable: name_not_typename */
2051 { struct block_symbol sym = (yyvsp[0].ssym).sym;
2055 if (symbol_read_needs_frame (sym.symbol))
2056 pstate->block_tracker->update (sym);
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)
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
2067 pstate->block_tracker->update (sym);
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. */
2074 = value_of_this_silent (pstate->language ());
2076 this_type = value_type (this_val);
2080 current_type = lookup_struct_elt_type (
2082 copy_name ((yyvsp[0].ssym).stoken).c_str (), 0);
2084 current_type = NULL;
2088 struct bound_minimal_symbol msymbol;
2089 std::string arg = copy_name ((yyvsp[0].ssym).stoken);
2092 lookup_bound_minimal_symbol (arg.c_str ());
2093 if (msymbol.minsym != NULL)
2094 pstate->push_new<var_msym_value_operation>
2096 else if (!have_full_symbols ()
2097 && !have_partial_symbols ())
2098 error (_("No symbol table is loaded. "
2099 "Use the \"file\" command."));
2101 error (_("No symbol \"%s\" in current context."),
2105 #line 2107 "p-exp.c.tmp"
2108 case 68: /* typebase: '^' typebase */
2110 { (yyval.tval) = lookup_pointer_type ((yyvsp[0].tval)); }
2111 #line 2113 "p-exp.c.tmp"
2114 case 69: /* typebase: TYPENAME */
2116 { (yyval.tval) = (yyvsp[0].tsym).type; }
2117 #line 2119 "p-exp.c.tmp"
2120 case 70: /* typebase: STRUCT name */
2123 = lookup_struct (copy_name ((yyvsp[0].sval)).c_str (),
2124 pstate->expression_context_block);
2126 #line 2128 "p-exp.c.tmp"
2129 case 71: /* typebase: CLASS name */
2132 = lookup_struct (copy_name ((yyvsp[0].sval)).c_str (),
2133 pstate->expression_context_block);
2135 #line 2137 "p-exp.c.tmp"
2138 case 72: /* name: NAME */
2140 { (yyval.sval) = (yyvsp[0].ssym).stoken; }
2141 #line 2143 "p-exp.c.tmp"
2144 case 73: /* name: BLOCKNAME */
2146 { (yyval.sval) = (yyvsp[0].ssym).stoken; }
2147 #line 2149 "p-exp.c.tmp"
2150 case 74: /* name: TYPENAME */
2152 { (yyval.sval) = (yyvsp[0].tsym).stoken; }
2153 #line 2155 "p-exp.c.tmp"
2156 case 75: /* name: NAME_OR_INT */
2158 { (yyval.sval) = (yyvsp[0].ssym).stoken; }
2159 #line 2161 "p-exp.c.tmp"
2163 #line 2165 "p-exp.c.tmp"
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);
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. */
2189 const int yylhs = yyr1[yyn] - YYNTOKENS;
2190 const int yyi = yypgoto[yylhs] + *yyssp;
2191 yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp
2193 : yydefgoto[yylhs]);
2199 /*--------------------------------------.
2200 | yyerrlab -- here on detecting error. |
2201 `--------------------------------------*/
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. */
2210 yyerror (YY_("syntax error"));
2213 if (yyerrstatus == 3)
2215 /* If just tried and failed to reuse lookahead token after an
2216 error, discard it. */
2218 if (yychar <= YYEOF)
2220 /* Return failure if at end of input. */
2221 if (yychar == YYEOF)
2226 yydestruct ("Error: discarding",
2232 /* Else will try to reuse lookahead token after shifting the error
2237 /*---------------------------------------------------.
2238 | yyerrorlab -- error raised explicitly by YYERROR. |
2239 `---------------------------------------------------*/
2241 /* Pacify compilers when the user code never invokes YYERROR and the
2242 label yyerrorlab therefore never appears in user code. */
2247 /* Do not reclaim the symbols of the rule whose action triggered
2251 YY_STACK_PRINT (yyss, yyssp);
2256 /*-------------------------------------------------------------.
2257 | yyerrlab1 -- common code for both syntax error and YYERROR. |
2258 `-------------------------------------------------------------*/
2260 yyerrstatus = 3; /* Each real token shifted decrements this. */
2262 /* Pop stack until we find a state that shifts the error token. */
2265 yyn = yypact[yystate];
2266 if (!yypact_value_is_default (yyn))
2268 yyn += YYSYMBOL_YYerror;
2269 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYSYMBOL_YYerror)
2277 /* Pop the current state because it cannot handle the error token. */
2282 yydestruct ("Error: popping",
2283 YY_ACCESSING_SYMBOL (yystate), yyvsp);
2286 YY_STACK_PRINT (yyss, yyssp);
2289 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
2291 YY_IGNORE_MAYBE_UNINITIALIZED_END
2294 /* Shift the error token. */
2295 YY_SYMBOL_PRINT ("Shifting", YY_ACCESSING_SYMBOL (yyn), yyvsp, yylsp);
2301 /*-------------------------------------.
2302 | yyacceptlab -- YYACCEPT comes here. |
2303 `-------------------------------------*/
2309 /*-----------------------------------.
2310 | yyabortlab -- YYABORT comes here. |
2311 `-----------------------------------*/
2317 /*-----------------------------------------------------------.
2318 | yyexhaustedlab -- YYNOMEM (memory exhaustion) comes here. |
2319 `-----------------------------------------------------------*/
2321 yyerror (YY_("memory exhausted"));
2326 /*----------------------------------------------------------.
2327 | yyreturnlab -- parsing is finished, clean up and return. |
2328 `----------------------------------------------------------*/
2330 if (yychar != YYEMPTY)
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",
2338 /* Do not reclaim the symbols of the rule whose action triggered
2339 this YYABORT or YYACCEPT. */
2341 YY_STACK_PRINT (yyss, yyssp);
2342 while (yyssp != yyss)
2344 yydestruct ("Cleanup: popping",
2345 YY_ACCESSING_SYMBOL (+*yyssp), yyvsp);
2350 YYSTACK_FREE (yyss);
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. */
2363 /*** Needs some error checking for the float case ***/
2366 parse_number (struct parser_state *par_state,
2367 const char *p, int len, int parsed_float, YYSTYPE *putithere)
2374 int base = input_radix;
2377 /* Number of "L" suffixes encountered. */
2380 /* We have found a "L" or "U" suffix. */
2381 int found_suffix = 0;
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')
2389 putithere->typed_val_float.type
2390 = parse_type (par_state)->builtin_float;
2393 else if (len >= 1 && tolower (p[len - 1]) == 'l')
2395 putithere->typed_val_float.type
2396 = parse_type (par_state)->builtin_long_double;
2399 /* Default type for floating-point literals is double. */
2402 putithere->typed_val_float.type
2403 = parse_type (par_state)->builtin_double;
2406 if (!parse_float (p, len,
2407 putithere->typed_val_float.type,
2408 putithere->typed_val_float.val))
2413 /* Handle base-switching prefixes 0x, 0t, 0d, 0. */
2414 if (p[0] == '0' && len > 1)
2447 if (c >= 'A' && c <= 'Z')
2449 if (c != 'l' && c != 'u')
2451 if (c >= '0' && c <= '9')
2459 if (base > 10 && c >= 'a' && c <= 'f')
2463 n += i = c - 'a' + 10;
2476 return ERROR; /* Char not a digit */
2479 return ERROR; /* Invalid digit in this base. */
2481 if (c != 'l' && c != 'u')
2483 /* Test for overflow. */
2484 if (prevn == 0 && n == 0)
2486 else if (prevn >= n)
2487 error (_("Numeric constant too large."));
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. */
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;
2527 error (_("Numeric constant too large."));
2528 putithere->typed_val_int.val = n;
2536 struct type *stored;
2537 struct type_push *next;
2540 static struct type_push *tp_top = NULL;
2543 push_current_type (void)
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;
2554 pop_current_type (void)
2556 struct type_push *tp = tp_top;
2559 current_type = tp->stored;
2569 enum exp_opcode opcode;
2572 static const struct token tokentab3[] =
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}
2585 static const struct token tokentab2[] =
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} };
2594 /* Allocate uppercased var: */
2595 /* make an uppercased copy of tokstart. */
2597 uptok (const char *tokstart, int namelen)
2600 char *uptokstart = (char *)xmalloc(namelen+1);
2601 for (i = 0;i <= namelen;i++)
2603 if ((tokstart[i]>='a' && tokstart[i]<='z'))
2604 uptokstart[i] = tokstart[i]-('a'-'A');
2606 uptokstart[i] = tokstart[i];
2608 uptokstart[namelen]='\0';
2612 /* Read one token, getting characters through lexptr. */
2619 const char *tokstart;
2622 int explen, tempbufindex;
2623 static char *tempbuf;
2624 static int tempbufsize;
2628 pstate->prev_lexptr = pstate->lexptr;
2630 tokstart = pstate->lexptr;
2631 explen = strlen (pstate->lexptr);
2633 /* See if it is a special token of length 3. */
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] != '_')))
2641 pstate->lexptr += 3;
2642 yylval.opcode = token.opcode;
2646 /* See if it is a special token of length 2. */
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] != '_')))
2654 pstate->lexptr += 2;
2655 yylval.opcode = token.opcode;
2659 switch (c = *tokstart)
2662 if (search_field && pstate->parse_completion)
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
2678 c = *pstate->lexptr++;
2680 c = parse_escape (pstate->gdbarch (), &pstate->lexptr);
2682 error (_("Empty character constant."));
2684 yylval.typed_val_int.val = c;
2685 yylval.typed_val_int.type = parse_type (pstate)->builtin_char;
2687 c = *pstate->lexptr++;
2690 namelen = skip_quoted (tokstart) - tokstart;
2693 pstate->lexptr = tokstart + namelen;
2694 if (pstate->lexptr[-1] != '\'')
2695 error (_("Unmatched single quote."));
2698 uptokstart = uptok(tokstart,namelen);
2701 error (_("Invalid character constant."));
2711 if (paren_depth == 0)
2718 if (pstate->comma_terminates && paren_depth == 0)
2724 /* Might be a floating point number. */
2725 if (pstate->lexptr[1] < '0' || pstate->lexptr[1] > '9')
2727 goto symbol; /* Nope, must be a symbol. */
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;
2748 if (c == '0' && (p[1] == 'x' || p[1] == 'X'))
2753 else if (c == '0' && (p[1]=='t' || p[1]=='T'
2754 || p[1]=='d' || p[1]=='D'))
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 == '.')
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
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')))
2783 toktype = parse_number (pstate, tokstart,
2784 p - tokstart, got_dot | got_e, &yylval);
2785 if (toktype == ERROR)
2787 char *err_copy = (char *) alloca (p - tokstart + 1);
2789 memcpy (err_copy, tokstart, p - tokstart);
2790 err_copy[p - tokstart] = 0;
2791 error (_("Invalid number \"%s\"."), err_copy);
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. */
2831 tokptr = ++tokstart;
2835 /* Grow the static temp buffer if necessary, including allocating
2836 the first one on demand. */
2837 if (tempbufindex + 1 >= tempbufsize)
2839 tempbuf = (char *) xrealloc (tempbuf, tempbufsize += 64);
2846 /* Do nothing, loop will terminate. */
2850 c = parse_escape (pstate->gdbarch (), &tokptr);
2855 tempbuf[tempbufindex++] = c;
2858 tempbuf[tempbufindex++] = *tokptr++;
2861 } while ((*tokptr != '"') && (*tokptr != '\0'));
2862 if (*tokptr++ != '"')
2864 error (_("Unterminated string in expression."));
2866 tempbuf[tempbufindex] = '\0'; /* See note above. */
2867 yylval.sval.ptr = tempbuf;
2868 yylval.sval.length = tempbufindex;
2869 pstate->lexptr = tokptr;
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);
2878 /* It's a name. See how long it is. */
2880 for (c = tokstart[namelen];
2881 (c == '_' || c == '$' || (c >= '0' && c <= '9')
2882 || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '<');)
2884 /* Template parameter lists are part of the name.
2885 FIXME: This mishandles `print $a<4&&$a>3'. */
2889 int nesting_level = 1;
2890 while (tokstart[++i])
2892 if (tokstart[i] == '<')
2894 else if (tokstart[i] == '>')
2896 if (--nesting_level == 0)
2900 if (tokstart[i] == '>')
2906 /* do NOT uppercase internals because of registers !!! */
2907 c = tokstart[++namelen];
2910 uptokstart = uptok(tokstart,namelen);
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')
2920 pstate->lexptr += namelen;
2924 /* Catch specific keywords. Should be done with a data structure. */
2928 if (strcmp (uptokstart, "OBJECT") == 0)
2933 if (strcmp (uptokstart, "RECORD") == 0)
2938 if (strcmp (uptokstart, "SIZEOF") == 0)
2945 if (strcmp (uptokstart, "CLASS") == 0)
2950 if (strcmp (uptokstart, "FALSE") == 0)
2954 return FALSEKEYWORD;
2958 if (strcmp (uptokstart, "TRUE") == 0)
2964 if (strcmp (uptokstart, "SELF") == 0)
2966 /* Here we search for 'this' like
2967 inserted in FPC stabs debug info. */
2968 static const char this_name[] = "this";
2970 if (lookup_symbol (this_name, pstate->expression_context_block,
2971 VAR_DOMAIN, NULL).symbol)
2982 yylval.sval.ptr = tokstart;
2983 yylval.sval.length = namelen;
2985 if (*tokstart == '$')
2988 return DOLLAR_VARIABLE;
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. */
2997 std::string tmp = copy_name (yylval.sval);
2999 struct field_of_this_result is_a_field_of_this;
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);
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)
3015 for (int i = 0; i <= namelen; i++)
3017 if ((tmp[i] >= 'a' && tmp[i] <= 'z'))
3018 tmp[i] -= ('a'-'A');
3020 if (search_field && current_type)
3021 is_a_field = (lookup_struct_elt_type (current_type,
3022 tmp.c_str (), 1) != NULL);
3026 sym = lookup_symbol (tmp.c_str (), pstate->expression_context_block,
3027 VAR_DOMAIN, &is_a_field_of_this).symbol;
3029 /* Third chance Capitalized (as GPC does). */
3030 if (!sym && is_a_field_of_this.type == NULL && !is_a_field)
3032 for (int i = 0; i <= namelen; i++)
3036 if ((tmp[i] >= 'a' && tmp[i] <= 'z'))
3037 tmp[i] -= ('a'-'A');
3040 if ((tmp[i] >= 'A' && tmp[i] <= 'Z'))
3041 tmp[i] -= ('A'-'a');
3043 if (search_field && current_type)
3044 is_a_field = (lookup_struct_elt_type (current_type,
3045 tmp.c_str (), 1) != NULL);
3049 sym = lookup_symbol (tmp.c_str (), pstate->expression_context_block,
3050 VAR_DOMAIN, &is_a_field_of_this).symbol;
3053 if (is_a_field || (is_a_field_of_this.type != NULL))
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;
3063 yylval.ssym.is_a_field_of_this = is_a_field_of_this.type != NULL;
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 ()))
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;
3081 if (sym && sym->aclass () == LOC_TYPEDEF)
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. */
3094 const char *namestart;
3095 struct symbol *best_sym;
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. */
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
3112 /* Skip whitespace. */
3113 while (*p == ' ' || *p == '\t' || *p == '\n')
3115 if (*p == ':' && p[1] == ':')
3117 /* Skip the `::'. */
3119 /* Skip whitespace. */
3120 while (*p == ' ' || *p == '\t' || *p == '\n')
3123 while (*p == '_' || *p == '$' || (*p >= '0' && *p <= '9')
3124 || (*p >= 'a' && *p <= 'z')
3125 || (*p >= 'A' && *p <= 'Z'))
3129 struct symbol *cur_sym;
3130 /* As big as the whole rest of the expression, which is
3131 at least big enough. */
3133 = (char *) alloca (tmp.size () + strlen (namestart)
3138 memcpy (tmp1, tmp.c_str (), tmp.size ());
3139 tmp1 += tmp.size ();
3140 memcpy (tmp1, "::", 2);
3142 memcpy (tmp1, namestart, p - namestart);
3143 tmp1[p - namestart] = '\0';
3145 = lookup_symbol (ncopy,
3146 pstate->expression_context_block,
3147 VAR_DOMAIN, NULL).symbol;
3150 if (cur_sym->aclass () == LOC_TYPEDEF)
3168 yylval.tsym.type = best_sym->type ();
3170 yylval.tsym.type = sym->type ();
3176 = language_lookup_primitive_type (pstate->language (),
3177 pstate->gdbarch (), tmp.c_str ());
3178 if (yylval.tsym.type != NULL)
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. */
3188 && ((tokstart[0] >= 'a' && tokstart[0] < 'a' + input_radix - 10)
3189 || (tokstart[0] >= 'A' && tokstart[0] < 'A' + input_radix - 10)))
3191 YYSTYPE newlval; /* Its value is ignored. */
3192 hextype = parse_number (pstate, tokstart, namelen, 0, &newlval);
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;
3204 /* Any other kind of symbol. */
3205 yylval.ssym.sym.symbol = sym;
3206 yylval.ssym.sym.block = NULL;
3211 /* See language.h. */
3214 pascal_language::parser (struct parser_state *par_state) const
3216 /* Setting up the parser state. */
3217 scoped_restore pstate_restore = make_scoped_restore (&pstate);
3218 gdb_assert (par_state != NULL);
3222 int result = yyparse ();
3224 pstate->set_operation (pstate->pop ());
3229 yyerror (const char *msg)
3231 if (pstate->prev_lexptr)
3232 pstate->lexptr = pstate->prev_lexptr;
3234 error (_("A %s in expression, near `%s'."), msg, pstate->lexptr);