GDB (xrefs)
/tmp/gdb-8.1/gdb/d-exp.c
Go to the documentation of this file.
1 /* A Bison parser, made by GNU Bison 3.0.4. */
2 
3 /* Bison implementation for Yacc-like parsers in C
4 
5  Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
6 
7  This program is free software: you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation, either version 3 of the License, or
10  (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program. If not, see <http://www.gnu.org/licenses/>. */
19 
20 /* As a special exception, you may create a larger work that contains
21  part or all of the Bison parser skeleton and distribute that work
22  under terms of your choice, so long as that work isn't itself a
23  parser generator using the skeleton or a modified version thereof
24  as a parser skeleton. Alternatively, if you modify or redistribute
25  the parser skeleton itself, you may (at your option) remove this
26  special exception, which will cause the skeleton and the resulting
27  Bison output files to be licensed under the GNU General Public
28  License without this special exception.
29 
30  This special exception was added by the Free Software Foundation in
31  version 2.2 of Bison. */
32 
33 /* C LALR(1) parser skeleton written by Richard Stallman, by
34  simplifying the original so-called "semantic" parser. */
35 
36 /* All symbols defined below should begin with yy or YY, to avoid
37  infringing on user name space. This should be done even for local
38  variables, as they might otherwise be expanded by user macros.
39  There are some unavoidable exceptions within include files to
40  define necessary library symbols; they are noted "INFRINGES ON
41  USER NAME SPACE" below. */
42 
43 /* Identify Bison output. */
44 #define YYBISON 1
45 
46 /* Bison version. */
47 #define YYBISON_VERSION "3.0.4"
48 
49 /* Skeleton name. */
50 #define YYSKELETON_NAME "yacc.c"
51 
52 /* Pure parsers. */
53 #define YYPURE 0
54 
55 /* Push parsers. */
56 #define YYPUSH 0
57 
58 /* Pull parsers. */
59 #define YYPULL 1
60 
61 
62 
63 
64 /* Copy the first part of user declarations. */
65 #line 39 "d-exp.y" /* yacc.c:339 */
66 
67 
68 #include "defs.h"
69 #include <ctype.h>
70 #include "expression.h"
71 #include "value.h"
72 #include "parser-defs.h"
73 #include "language.h"
74 #include "c-lang.h"
75 #include "d-lang.h"
76 #include "bfd.h" /* Required by objfiles.h. */
77 #include "symfile.h" /* Required by objfiles.h. */
78 #include "objfiles.h" /* For have_full_symbols and have_partial_symbols */
79 #include "charset.h"
80 #include "block.h"
81 
82 #define parse_type(ps) builtin_type (parse_gdbarch (ps))
83 #define parse_d_type(ps) builtin_d_type (parse_gdbarch (ps))
84 
85 /* Remap normal yacc parser interface names (yyparse, yylex, yyerror,
86  etc). */
87 #define GDB_YY_REMAP_PREFIX d_
88 #include "yy-remap.h"
89 
90 /* The state of the parser, used internally when we are parsing the
91  expression. */
92 
93 static struct parser_state *pstate = NULL;
94 
95 int yyparse (void);
96 
97 static int yylex (void);
98 
99 void yyerror (const char *);
100 
101 static int type_aggregate_p (struct type *);
102 
103 
104 #line 105 "d-exp.c" /* yacc.c:339 */
105 
106 # ifndef YY_NULLPTRPTR
107 # if defined __cplusplus && 201103L <= __cplusplus
108 # define YY_NULLPTRPTR nullptr
109 # else
110 # define YY_NULLPTRPTR 0
111 # endif
112 # endif
113 
114 /* Enabling verbose error messages. */
115 #ifdef YYERROR_VERBOSE
116 # undef YYERROR_VERBOSE
117 # define YYERROR_VERBOSE 1
118 #else
119 # define YYERROR_VERBOSE 0
120 #endif
121 
122 
123 /* Debug traces. */
124 #ifndef YYDEBUG
125 # define YYDEBUG 0
126 #endif
127 #if YYDEBUG
128 extern int yydebug;
129 #endif
130 
131 /* Token type. */
132 #ifndef YYTOKENTYPE
133 # define YYTOKENTYPE
135  {
136  IDENTIFIER = 258,
138  TYPENAME = 260,
139  COMPLETE = 261,
140  NAME_OR_INT = 262,
145  ENTRY = 267,
146  ERROR = 268,
169  OROR = 291,
170  ANDAND = 292,
171  EQUAL = 293,
172  NOTEQUAL = 294,
173  LEQ = 295,
174  GEQ = 296,
175  LSH = 297,
176  RSH = 298,
177  HATHAT = 299,
178  IDENTITY = 300,
179  NOTIDENTITY = 301,
180  INCREMENT = 302,
181  DECREMENT = 303,
182  DOTDOT = 304
183  };
184 #endif
185 /* Tokens. */
186 #define IDENTIFIER 258
187 #define UNKNOWN_NAME 259
188 #define TYPENAME 260
189 #define COMPLETE 261
190 #define NAME_OR_INT 262
191 #define INTEGER_LITERAL 263
192 #define FLOAT_LITERAL 264
193 #define CHARACTER_LITERAL 265
194 #define STRING_LITERAL 266
195 #define ENTRY 267
196 #define ERROR 268
197 #define TRUE_KEYWORD 269
198 #define FALSE_KEYWORD 270
199 #define NULL_KEYWORD 271
200 #define SUPER_KEYWORD 272
201 #define CAST_KEYWORD 273
202 #define SIZEOF_KEYWORD 274
203 #define TYPEOF_KEYWORD 275
204 #define TYPEID_KEYWORD 276
205 #define INIT_KEYWORD 277
206 #define IMMUTABLE_KEYWORD 278
207 #define CONST_KEYWORD 279
208 #define SHARED_KEYWORD 280
209 #define STRUCT_KEYWORD 281
210 #define UNION_KEYWORD 282
211 #define CLASS_KEYWORD 283
212 #define INTERFACE_KEYWORD 284
213 #define ENUM_KEYWORD 285
214 #define TEMPLATE_KEYWORD 286
215 #define DELEGATE_KEYWORD 287
216 #define FUNCTION_KEYWORD 288
217 #define DOLLAR_VARIABLE 289
218 #define ASSIGN_MODIFY 290
219 #define OROR 291
220 #define ANDAND 292
221 #define EQUAL 293
222 #define NOTEQUAL 294
223 #define LEQ 295
224 #define GEQ 296
225 #define LSH 297
226 #define RSH 298
227 #define HATHAT 299
228 #define IDENTITY 300
229 #define NOTIDENTITY 301
230 #define INCREMENT 302
231 #define DECREMENT 303
232 #define DOTDOT 304
233 
234 /* Value type. */
235 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
236 
237 union YYSTYPE
238 {
239 #line 83 "d-exp.y" /* yacc.c:355 */
240 
241  struct {
242  LONGEST val;
243  struct type *type;
244  } typed_val_int;
245  struct {
246  gdb_byte val[16];
247  struct type *type;
248  } typed_val_float;
249  struct symbol *sym;
250  struct type *tval;
251  struct typed_stoken tsval;
252  struct stoken sval;
253  struct ttype tsym;
254  struct symtoken ssym;
255  int ival;
256  int voidval;
257  struct block *bval;
258  enum exp_opcode opcode;
259  struct stoken_vector svec;
260 
261 
262 #line 263 "d-exp.c" /* yacc.c:355 */
263 };
264 
265 typedef union YYSTYPE YYSTYPE;
266 # define YYSTYPE_IS_TRIVIAL 1
267 # define YYSTYPE_IS_DECLARED 1
268 #endif
269 
270 
271 extern YYSTYPE yylval;
272 
273 int yyparse (void);
274 
275 
276 
277 /* Copy the second part of user declarations. */
278 #line 105 "d-exp.y" /* yacc.c:358 */
279 
280 /* YYSTYPE gets defined by %union */
281 static int parse_number (struct parser_state *, const char *,
282  int, int, YYSTYPE *);
283 
284 #line 285 "d-exp.c" /* yacc.c:358 */
285 
286 #ifdef short
287 # undef short
288 #endif
289 
290 #ifdef YYTYPE_UINT8
291 typedef YYTYPE_UINT8 yytype_uint8;
292 #else
293 typedef unsigned char yytype_uint8;
294 #endif
295 
296 #ifdef YYTYPE_INT8
297 typedef YYTYPE_INT8 yytype_int8;
298 #else
299 typedef signed char yytype_int8;
300 #endif
301 
302 #ifdef YYTYPE_UINT16
303 typedef YYTYPE_UINT16 yytype_uint16;
304 #else
305 typedef unsigned short int yytype_uint16;
306 #endif
307 
308 #ifdef YYTYPE_INT16
309 typedef YYTYPE_INT16 yytype_int16;
310 #else
311 typedef short int yytype_int16;
312 #endif
313 
314 #ifndef YYSIZE_T
315 # ifdef __SIZE_TYPE__
316 # define YYSIZE_T __SIZE_TYPE__
317 # elif defined size_t
318 # define YYSIZE_T size_t
319 # elif ! defined YYSIZE_T
320 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
321 # define YYSIZE_T size_t
322 # else
323 # define YYSIZE_T unsigned int
324 # endif
325 #endif
326 
327 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
328 
329 #ifndef YY_
330 # if defined YYENABLE_NLS && YYENABLE_NLS
331 # if ENABLE_NLS
332 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
333 # define YY_(Msgid) dgettext ("bison-runtime", Msgid)
334 # endif
335 # endif
336 # ifndef YY_
337 # define YY_(Msgid) Msgid
338 # endif
339 #endif
340 
341 #ifndef YY_ATTRIBUTE
342 # if (defined __GNUC__ \
343  && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \
344  || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C
345 # define YY_ATTRIBUTE(Spec) __attribute__(Spec)
346 # else
347 # define YY_ATTRIBUTE(Spec) /* empty */
348 # endif
349 #endif
350 
351 #ifndef YY_ATTRIBUTE_PURE
352 # define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__))
353 #endif
354 
355 #ifndef YY_ATTRIBUTE_UNUSED
356 # define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__))
357 #endif
358 
359 #if !defined _Noreturn \
360  && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112)
361 # if defined _MSC_VER && 1200 <= _MSC_VER
362 # define _Noreturn __declspec (noreturn)
363 # else
364 # define _Noreturn YY_ATTRIBUTE ((__noreturn__))
365 # endif
366 #endif
367 
368 /* Suppress unused-variable warnings by "using" E. */
369 #if ! defined lint || defined __GNUC__
370 # define YYUSE(E) ((void) (E))
371 #else
372 # define YYUSE(E) /* empty */
373 #endif
374 
375 #if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
376 /* Suppress an incorrect diagnostic about yylval being uninitialized. */
377 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
378  _Pragma ("GCC diagnostic push") \
379  _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
380  _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
381 # define YY_IGNORE_MAYBE_UNINITIALIZED_END \
382  _Pragma ("GCC diagnostic pop")
383 #else
384 # define YY_INITIAL_VALUE(Value) Value
385 #endif
386 #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
387 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
388 # define YY_IGNORE_MAYBE_UNINITIALIZED_END
389 #endif
390 #ifndef YY_INITIAL_VALUE
391 # define YY_INITIAL_VALUE(Value) /* Nothing. */
392 #endif
393 
394 
395 #if ! defined yyoverflow || YYERROR_VERBOSE
396 
397 /* The parser invokes alloca or xmalloc; define the necessary symbols. */
398 
399 # ifdef YYSTACK_USE_ALLOCA
400 # if YYSTACK_USE_ALLOCA
401 # ifdef __GNUC__
402 # define YYSTACK_ALLOC __builtin_alloca
403 # elif defined __BUILTIN_VA_ARG_INCR
404 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
405 # elif defined _AIX
406 # define YYSTACK_ALLOC __alloca
407 # elif defined _MSC_VER
408 # define alloca _alloca
409 # else
410 # define YYSTACK_ALLOC alloca
411 # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
412 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
413  /* Use EXIT_SUCCESS as a witness for stdlib.h. */
414 # ifndef EXIT_SUCCESS
415 # define EXIT_SUCCESS 0
416 # endif
417 # endif
418 # endif
419 # endif
420 # endif
421 
422 # ifdef YYSTACK_ALLOC
423  /* Pacify GCC's 'empty if-body' warning. */
424 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
425 # ifndef YYSTACK_ALLOC_MAXIMUM
426  /* The OS might guarantee only one guard page at the bottom of the stack,
427  and a page size can be as small as 4096 bytes. So we cannot safely
428  invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
429  to allow for a few compiler-allocated temporary stack slots. */
430 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
431 # endif
432 # else
433 # define YYSTACK_ALLOC YYMALLOC
434 # define YYSTACK_FREE YYFREE
435 # ifndef YYSTACK_ALLOC_MAXIMUM
436 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
437 # endif
438 # if (defined __cplusplus && ! defined EXIT_SUCCESS \
439  && ! ((defined YYMALLOC || defined xmalloc) \
440  && (defined YYFREE || defined xfree)))
441 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
442 # ifndef EXIT_SUCCESS
443 # define EXIT_SUCCESS 0
444 # endif
445 # endif
446 # ifndef YYMALLOC
447 # define YYMALLOC xmalloc
448 # if ! defined xmalloc && ! defined EXIT_SUCCESS
449 void *xmalloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
450 # endif
451 # endif
452 # ifndef YYFREE
453 # define YYFREE xfree
454 # if ! defined xfree && ! defined EXIT_SUCCESS
455 void xfree (void *); /* INFRINGES ON USER NAME SPACE */
456 # endif
457 # endif
458 # endif
459 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
460 
461 
462 #if (! defined yyoverflow \
463  && (! defined __cplusplus \
464  || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
465 
466 /* A type that is properly aligned for any stack member. */
467 union yyalloc
468 {
471 };
472 
473 /* The size of the maximum gap between one aligned stack and the next. */
474 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
475 
476 /* The size of an array large to enough to hold all stacks, each with
477  N elements. */
478 # define YYSTACK_BYTES(N) \
479  ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
480  + YYSTACK_GAP_MAXIMUM)
481 
482 # define YYCOPY_NEEDED 1
483 
484 /* Relocate STACK from its old location to the new one. The
485  local variables YYSIZE and YYSTACKSIZE give the old and new number of
486  elements in the stack, and YYPTR gives the new location of the
487  stack. Advance YYPTR to a properly aligned location for the next
488  stack. */
489 # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
490  do \
491  { \
492  YYSIZE_T yynewbytes; \
493  YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
494  Stack = &yyptr->Stack_alloc; \
495  yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
496  yyptr += yynewbytes / sizeof (*yyptr); \
497  } \
498  while (0)
499 
500 #endif
501 
502 #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
503 /* Copy COUNT objects from SRC to DST. The source and destination do
504  not overlap. */
505 # ifndef YYCOPY
506 # if defined __GNUC__ && 1 < __GNUC__
507 # define YYCOPY(Dst, Src, Count) \
508  __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src)))
509 # else
510 # define YYCOPY(Dst, Src, Count) \
511  do \
512  { \
513  YYSIZE_T yyi; \
514  for (yyi = 0; yyi < (Count); yyi++) \
515  (Dst)[yyi] = (Src)[yyi]; \
516  } \
517  while (0)
518 # endif
519 # endif
520 #endif /* !YYCOPY_NEEDED */
521 
522 /* YYFINAL -- State number of the termination state. */
523 #define YYFINAL 70
524 /* YYLAST -- Last index in YYTABLE. */
525 #define YYLAST 200
526 
527 /* YYNTOKENS -- Number of terminals. */
528 #define YYNTOKENS 71
529 /* YYNNTS -- Number of nonterminals. */
530 #define YYNNTS 35
531 /* YYNRULES -- Number of rules. */
532 #define YYNRULES 104
533 /* YYNSTATES -- Number of states. */
534 #define YYNSTATES 169
535 
536 /* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned
537  by yylex, with out-of-bounds checking. */
538 #define YYUNDEFTOK 2
539 #define YYMAXUTOK 304
540 
541 #define YYTRANSLATE(YYX) \
542  ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
543 
544 /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
545  as returned by yylex, without out-of-bounds checking. */
546 static const yytype_uint8 yytranslate[] =
547 {
548  0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
549  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
550  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
551  2, 2, 2, 68, 2, 2, 2, 56, 43, 2,
552  64, 69, 54, 52, 36, 53, 62, 55, 2, 2,
553  2, 2, 2, 2, 2, 2, 2, 2, 66, 2,
554  46, 37, 47, 38, 2, 2, 2, 2, 2, 2,
555  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
556  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
557  2, 63, 2, 70, 42, 2, 2, 2, 2, 2,
558  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
559  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
560  2, 2, 2, 2, 41, 2, 67, 2, 2, 2,
561  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
562  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
563  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
564  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
565  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
566  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
567  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
568  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
569  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
570  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
571  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
572  2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
573  2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
574  5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
575  15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
576  25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
577  35, 39, 40, 44, 45, 48, 49, 50, 51, 57,
578  58, 59, 60, 61, 65
579 };
580 
581 #if YYDEBUG
582  /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
583 static const yytype_uint16 yyrline[] =
584 {
585  0, 178, 178, 179, 185, 189, 190, 195, 196, 198,
586  205, 206, 211, 212, 217, 218, 223, 224, 229, 230,
587  235, 236, 241, 242, 243, 244, 248, 250, 255, 257,
588  262, 264, 266, 268, 273, 274, 276, 281, 282, 284,
589  286, 291, 292, 294, 296, 300, 302, 304, 306, 308,
590  310, 312, 314, 316, 318, 319, 323, 327, 333, 334,
591  339, 340, 348, 352, 357, 359, 361, 363, 364, 365,
592  369, 371, 377, 378, 383, 382, 391, 404, 406, 411,
593  413, 461, 512, 514, 522, 529, 533, 537, 542, 547,
594  552, 558, 563, 568, 573, 577, 592, 610, 612, 616,
595  625, 627, 629, 632, 638
596 };
597 #endif
598 
599 #if YYDEBUG || YYERROR_VERBOSE || 0
600 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
601  First, the terminals, then, starting at YYNTOKENS, nonterminals. */
602 static const char *const yytname[] =
603 {
604  "$end", "error", "$undefined", "IDENTIFIER", "UNKNOWN_NAME", "TYPENAME",
605  "COMPLETE", "NAME_OR_INT", "INTEGER_LITERAL", "FLOAT_LITERAL",
606  "CHARACTER_LITERAL", "STRING_LITERAL", "ENTRY", "ERROR", "TRUE_KEYWORD",
607  "FALSE_KEYWORD", "NULL_KEYWORD", "SUPER_KEYWORD", "CAST_KEYWORD",
608  "SIZEOF_KEYWORD", "TYPEOF_KEYWORD", "TYPEID_KEYWORD", "INIT_KEYWORD",
609  "IMMUTABLE_KEYWORD", "CONST_KEYWORD", "SHARED_KEYWORD", "STRUCT_KEYWORD",
610  "UNION_KEYWORD", "CLASS_KEYWORD", "INTERFACE_KEYWORD", "ENUM_KEYWORD",
611  "TEMPLATE_KEYWORD", "DELEGATE_KEYWORD", "FUNCTION_KEYWORD",
612  "DOLLAR_VARIABLE", "ASSIGN_MODIFY", "','", "'='", "'?'", "OROR",
613  "ANDAND", "'|'", "'^'", "'&'", "EQUAL", "NOTEQUAL", "'<'", "'>'", "LEQ",
614  "GEQ", "LSH", "RSH", "'+'", "'-'", "'*'", "'/'", "'%'", "HATHAT",
615  "IDENTITY", "NOTIDENTITY", "INCREMENT", "DECREMENT", "'.'", "'['", "'('",
616  "DOTDOT", "':'", "'~'", "'!'", "')'", "']'", "$accept", "start",
617  "Expression", "CommaExpression", "AssignExpression",
618  "ConditionalExpression", "OrOrExpression", "AndAndExpression",
619  "OrExpression", "XorExpression", "AndExpression", "CmpExpression",
620  "EqualExpression", "IdentityExpression", "RelExpression",
621  "ShiftExpression", "AddExpression", "MulExpression", "UnaryExpression",
622  "CastExpression", "PowExpression", "PostfixExpression", "ArgumentList",
623  "ArgumentList_opt", "CallExpression", "$@1", "IndexExpression",
624  "SliceExpression", "PrimaryExpression", "ArrayLiteral", "IdentifierExp",
625  "StringExp", "TypeExp", "BasicType2", "BasicType", YY_NULLPTRPTR
626 };
627 #endif
628 
629 # ifdef YYPRINT
630 /* YYTOKNUM[NUM] -- (External) token number corresponding to the
631  (internal) symbol number NUM (which must be that of a token). */
632 static const yytype_uint16 yytoknum[] =
633 {
634  0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
635  265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
636  275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
637  285, 286, 287, 288, 289, 290, 44, 61, 63, 291,
638  292, 124, 94, 38, 293, 294, 60, 62, 295, 296,
639  297, 298, 43, 45, 42, 47, 37, 299, 300, 301,
640  302, 303, 46, 91, 40, 304, 58, 126, 33, 41,
641  93
642 };
643 # endif
644 
645 #define YYPACT_NINF -91
646 
647 #define yypact_value_is_default(Yystate) \
648  (!!((Yystate) == (-91)))
649 
650 #define YYTABLE_NINF -1
651 
652 #define yytable_value_is_error(Yytable_value) \
653  0
654 
655  /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
656  STATE-NUM. */
657 static const yytype_int16 yypact[] =
658 {
659  132, -91, -91, -91, -91, -91, -91, -91, -91, -91,
660  -91, -43, -27, -91, 132, 132, 132, 132, 132, 132,
661  132, 132, 132, 132, 30, -91, -91, 17, -8, 0,
662  14, 21, 35, 12, -91, -91, -91, -91, -1, -34,
663  -31, -91, -91, -91, 43, -91, -91, -91, -91, -91,
664  -91, 72, 22, -37, 6, 132, -91, 22, -91, -91,
665  -91, -91, -91, -91, 49, 16, 19, -49, -91, -91,
666  -91, 132, 132, 132, 132, 132, 132, 132, 132, 132,
667  132, 132, 132, 132, 132, 132, 132, 132, 132, 132,
668  132, 132, 132, 132, 132, 132, 132, -91, -91, 9,
669  58, -91, -91, 13, -37, 81, -91, 6, 24, 25,
670  132, -91, -91, 132, -91, -91, -91, 29, 14, 21,
671  35, 12, -91, -9, -9, -9, -9, -9, -9, -34,
672  -34, -9, -9, -31, -31, -31, -91, -91, -91, -91,
673  84, -91, -91, -91, 26, -30, 132, -91, -91, -91,
674  28, 27, 132, -91, -91, -91, 132, -91, 132, -91,
675  33, -37, -91, -91, -91, 38, -91, -91, -91
676 };
677 
678  /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
679  Performed when YYTABLE does not specify something else to do. Zero
680  means the default is an error. */
681 static const yytype_uint8 yydefact[] =
682 {
683  0, 94, 104, 83, 87, 88, 89, 95, 85, 86,
684  84, 0, 0, 82, 0, 0, 0, 0, 0, 0,
685  72, 0, 0, 0, 0, 2, 4, 5, 7, 10,
686  12, 14, 16, 18, 20, 23, 24, 25, 22, 34,
687  37, 41, 54, 55, 58, 67, 68, 69, 60, 91,
688  80, 90, 3, 98, 0, 0, 45, 0, 50, 49,
689  48, 46, 47, 70, 73, 0, 0, 0, 52, 51,
690  1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
691  0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
692  0, 0, 0, 0, 0, 0, 0, 65, 66, 0,
693  0, 74, 96, 0, 100, 0, 99, 0, 0, 0,
694  0, 93, 79, 97, 6, 9, 8, 0, 13, 15,
695  17, 19, 21, 26, 27, 30, 32, 31, 33, 35,
696  36, 28, 29, 38, 39, 40, 42, 43, 44, 59,
697  62, 61, 64, 77, 70, 0, 72, 53, 81, 101,
698  0, 0, 0, 92, 71, 57, 0, 63, 0, 76,
699  0, 102, 97, 56, 11, 0, 75, 103, 78
700 };
701 
702  /* YYPGOTO[NTERM-NUM]. */
703 static const yytype_int8 yypgoto[] =
704 {
705  -91, -91, 1, 42, -13, -47, -91, 39, 40, 46,
706  37, 41, -91, -91, -91, 73, -35, -56, -14, -91,
707  -91, -91, 31, -22, -91, -91, -91, -91, -91, -91,
708  48, -91, 10, -90, -91
709 };
710 
711  /* YYDEFGOTO[NTERM-NUM]. */
712 static const yytype_int16 yydefgoto[] =
713 {
714  -1, 24, 25, 26, 27, 28, 29, 30, 31, 32,
715  33, 34, 35, 36, 37, 38, 39, 40, 41, 42,
716  43, 44, 64, 65, 45, 146, 46, 47, 48, 49,
717  50, 51, 57, 106, 53
718 };
719 
720  /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
721  positive, shift that token. If negative, reduce the rule whose
722  number is the opposite. If YYTABLE_NINF, syntax error. */
723 static const yytype_uint8 yytable[] =
724 {
725  56, 58, 59, 60, 61, 62, 110, 63, 68, 69,
726  52, 2, 140, 103, 149, 141, 1, 104, 90, 91,
727  113, 54, 66, 93, 94, 95, 105, 72, 142, 73,
728  70, 67, 147, 92, 133, 134, 135, 55, 74, 75,
729  159, 86, 87, 80, 81, 82, 83, 84, 85, 86,
730  87, 129, 130, 71, 76, 79, 109, 88, 89, 115,
731  116, 1, 77, 2, 108, 3, 4, 5, 6, 7,
732  107, 167, 8, 9, 10, 117, 11, 78, 12, 136,
733  137, 138, 139, 102, 103, 110, 111, 144, 112, 150,
734  157, 158, 13, 152, 153, 156, 162, 154, 161, 155,
735  96, 14, 166, 97, 98, 99, 100, 101, 168, 164,
736  15, 16, 17, 114, 118, 121, 119, 151, 18, 19,
737  122, 20, 21, 120, 160, 22, 23, 0, 143, 0,
738  0, 145, 0, 63, 0, 1, 0, 2, 163, 3,
739  4, 5, 6, 7, 0, 165, 8, 9, 10, 0,
740  11, 148, 12, 123, 124, 125, 126, 127, 128, 0,
741  0, 131, 132, 0, 0, 0, 13, 0, 0, 0,
742  0, 0, 0, 0, 0, 14, 0, 0, 0, 0,
743  0, 0, 0, 0, 15, 16, 17, 0, 0, 0,
744  0, 0, 18, 19, 0, 20, 21, 0, 0, 22,
745  23
746 };
747 
748 static const yytype_int16 yycheck[] =
749 {
750  14, 15, 16, 17, 18, 19, 36, 20, 22, 23,
751  0, 5, 3, 62, 104, 6, 3, 54, 52, 53,
752  69, 64, 21, 54, 55, 56, 63, 35, 19, 37,
753  0, 21, 19, 67, 90, 91, 92, 64, 38, 39,
754  70, 50, 51, 44, 45, 46, 47, 48, 49, 50,
755  51, 86, 87, 36, 40, 43, 55, 58, 59, 72,
756  73, 3, 41, 5, 54, 7, 8, 9, 10, 11,
757  64, 161, 14, 15, 16, 74, 18, 42, 20, 93,
758  94, 95, 96, 11, 62, 36, 70, 100, 69, 8,
759  6, 65, 34, 69, 69, 66, 69, 110, 70, 113,
760  57, 43, 69, 60, 61, 62, 63, 64, 70, 156,
761  52, 53, 54, 71, 75, 78, 76, 107, 60, 61,
762  79, 63, 64, 77, 146, 67, 68, -1, 70, -1,
763  -1, 100, -1, 146, -1, 3, -1, 5, 152, 7,
764  8, 9, 10, 11, -1, 158, 14, 15, 16, -1,
765  18, 103, 20, 80, 81, 82, 83, 84, 85, -1,
766  -1, 88, 89, -1, -1, -1, 34, -1, -1, -1,
767  -1, -1, -1, -1, -1, 43, -1, -1, -1, -1,
768  -1, -1, -1, -1, 52, 53, 54, -1, -1, -1,
769  -1, -1, 60, 61, -1, 63, 64, -1, -1, 67,
770  68
771 };
772 
773  /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
774  symbol of state STATE-NUM. */
775 static const yytype_uint8 yystos[] =
776 {
777  0, 3, 5, 7, 8, 9, 10, 11, 14, 15,
778  16, 18, 20, 34, 43, 52, 53, 54, 60, 61,
779  63, 64, 67, 68, 72, 73, 74, 75, 76, 77,
780  78, 79, 80, 81, 82, 83, 84, 85, 86, 87,
781  88, 89, 90, 91, 92, 95, 97, 98, 99, 100,
782  101, 102, 103, 105, 64, 64, 89, 103, 89, 89,
783  89, 89, 89, 75, 93, 94, 73, 103, 89, 89,
784  0, 36, 35, 37, 38, 39, 40, 41, 42, 43,
785  44, 45, 46, 47, 48, 49, 50, 51, 58, 59,
786  52, 53, 67, 54, 55, 56, 57, 60, 61, 62,
787  63, 64, 11, 62, 54, 63, 104, 64, 103, 73,
788  36, 70, 69, 69, 74, 75, 75, 73, 78, 79,
789  80, 81, 82, 86, 86, 86, 86, 86, 86, 87,
790  87, 86, 86, 88, 88, 88, 89, 89, 89, 89,
791  3, 6, 19, 70, 75, 93, 96, 19, 101, 104,
792  8, 103, 69, 69, 75, 89, 66, 6, 65, 70,
793  94, 70, 69, 89, 76, 75, 69, 104, 70
794 };
795 
796  /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
797 static const yytype_uint8 yyr1[] =
798 {
799  0, 71, 72, 72, 73, 74, 74, 75, 75, 75,
800  76, 76, 77, 77, 78, 78, 79, 79, 80, 80,
801  81, 81, 82, 82, 82, 82, 83, 83, 84, 84,
802  85, 85, 85, 85, 86, 86, 86, 87, 87, 87,
803  87, 88, 88, 88, 88, 89, 89, 89, 89, 89,
804  89, 89, 89, 89, 89, 89, 90, 90, 91, 91,
805  92, 92, 92, 92, 92, 92, 92, 92, 92, 92,
806  93, 93, 94, 94, 96, 95, 97, 98, 98, 99,
807  99, 99, 99, 99, 99, 99, 99, 99, 99, 99,
808  99, 99, 99, 100, 101, 102, 102, 103, 103, 103,
809  104, 104, 104, 104, 105
810 };
811 
812  /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */
813 static const yytype_uint8 yyr2[] =
814 {
815  0, 2, 1, 1, 1, 1, 3, 1, 3, 3,
816  1, 5, 1, 3, 1, 3, 1, 3, 1, 3,
817  1, 3, 1, 1, 1, 1, 3, 3, 3, 3,
818  3, 3, 3, 3, 1, 3, 3, 1, 3, 3,
819  3, 1, 3, 3, 3, 2, 2, 2, 2, 2,
820  2, 2, 2, 3, 1, 1, 5, 4, 1, 3,
821  1, 3, 3, 4, 3, 2, 2, 1, 1, 1,
822  1, 3, 0, 1, 0, 5, 4, 3, 6, 3,
823  1, 3, 1, 1, 1, 1, 1, 1, 1, 1,
824  1, 1, 4, 3, 1, 1, 2, 3, 1, 2,
825  1, 2, 3, 4, 1
826 };
827 
828 
829 #define yyerrok (yyerrstatus = 0)
830 #define yyclearin (yychar = YYEMPTY)
831 #define YYEMPTY (-2)
832 #define YYEOF 0
833 
834 #define YYACCEPT goto yyacceptlab
835 #define YYABORT goto yyabortlab
836 #define YYERROR goto yyerrorlab
837 
838 
839 #define YYRECOVERING() (!!yyerrstatus)
840 
841 #define YYBACKUP(Token, Value) \
842 do \
843  if (yychar == YYEMPTY) \
844  { \
845  yychar = (Token); \
846  yylval = (Value); \
847  YYPOPSTACK (yylen); \
848  yystate = *yyssp; \
849  goto yybackup; \
850  } \
851  else \
852  { \
853  yyerror (YY_("syntax error: cannot back up")); \
854  YYERROR; \
855  } \
856 while (0)
857 
858 /* Error token number */
859 #define YYTERROR 1
860 #define YYERRCODE 256
861 
862 
863 
864 /* Enable debugging if requested. */
865 #if YYDEBUG
866 
867 # ifndef YYFPRINTF
868 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
869 # define YYFPRINTF fprintf
870 # endif
871 
872 # define YYDPRINTF(Args) \
873 do { \
874  if (yydebug) \
875  YYFPRINTF Args; \
876 } while (0)
877 
878 /* This macro is provided for backward compatibility. */
879 #ifndef YY_LOCATION_PRINT
880 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
881 #endif
882 
883 
884 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
885 do { \
886  if (yydebug) \
887  { \
888  YYFPRINTF (stderr, "%s ", Title); \
889  yy_symbol_print (stderr, \
890  Type, Value); \
891  YYFPRINTF (stderr, "\n"); \
892  } \
893 } while (0)
894 
895 
896 /*----------------------------------------.
897 | Print this symbol's value on YYOUTPUT. |
898 `----------------------------------------*/
899 
900 static void
901 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
902 {
903  FILE *yyo = yyoutput;
904  YYUSE (yyo);
905  if (!yyvaluep)
906  return;
907 # ifdef YYPRINT
908  if (yytype < YYNTOKENS)
909  YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
910 # endif
911  YYUSE (yytype);
912 }
913 
914 
915 /*--------------------------------.
916 | Print this symbol on YYOUTPUT. |
917 `--------------------------------*/
918 
919 static void
920 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
921 {
922  YYFPRINTF (yyoutput, "%s %s (",
923  yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]);
924 
925  yy_symbol_value_print (yyoutput, yytype, yyvaluep);
926  YYFPRINTF (yyoutput, ")");
927 }
928 
929 /*------------------------------------------------------------------.
930 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
931 | TOP (included). |
932 `------------------------------------------------------------------*/
933 
934 static void
936 {
937  YYFPRINTF (stderr, "Stack now");
938  for (; yybottom <= yytop; yybottom++)
939  {
940  int yybot = *yybottom;
941  YYFPRINTF (stderr, " %d", yybot);
942  }
943  YYFPRINTF (stderr, "\n");
944 }
945 
946 # define YY_STACK_PRINT(Bottom, Top) \
947 do { \
948  if (yydebug) \
949  yy_stack_print ((Bottom), (Top)); \
950 } while (0)
951 
952 
953 /*------------------------------------------------.
954 | Report that the YYRULE is going to be reduced. |
955 `------------------------------------------------*/
956 
957 static void
959 {
960  unsigned long int yylno = yyrline[yyrule];
961  int yynrhs = yyr2[yyrule];
962  int yyi;
963  YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
964  yyrule - 1, yylno);
965  /* The symbols being reduced. */
966  for (yyi = 0; yyi < yynrhs; yyi++)
967  {
968  YYFPRINTF (stderr, " $%d = ", yyi + 1);
969  yy_symbol_print (stderr,
970  yystos[yyssp[yyi + 1 - yynrhs]],
971  &(yyvsp[(yyi + 1) - (yynrhs)])
972  );
973  YYFPRINTF (stderr, "\n");
974  }
975 }
976 
977 # define YY_REDUCE_PRINT(Rule) \
978 do { \
979  if (yydebug) \
980  yy_reduce_print (yyssp, yyvsp, Rule); \
981 } while (0)
982 
983 /* Nonzero means print parse trace. It is left uninitialized so that
984  multiple parsers can coexist. */
986 #else /* !YYDEBUG */
987 # define YYDPRINTF(Args)
988 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
989 # define YY_STACK_PRINT(Bottom, Top)
990 # define YY_REDUCE_PRINT(Rule)
991 #endif /* !YYDEBUG */
992 
993 
994 /* YYINITDEPTH -- initial size of the parser's stacks. */
995 #ifndef YYINITDEPTH
996 # define YYINITDEPTH 200
997 #endif
998 
999 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
1000  if the built-in stack extension method is used).
1001 
1002  Do not make this value too large; the results are undefined if
1003  YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
1004  evaluated with infinite-precision integer arithmetic. */
1005 
1006 #ifndef YYMAXDEPTH
1007 # define YYMAXDEPTH 10000
1008 #endif
1009 
1010 
1011 #if YYERROR_VERBOSE
1012 
1013 # ifndef yystrlen
1014 # if defined __GLIBC__ && defined _STRING_H
1015 # define yystrlen strlen
1016 # else
1017 /* Return the length of YYSTR. */
1018 static YYSIZE_T
1019 yystrlen (const char *yystr)
1020 {
1021  YYSIZE_T yylen;
1022  for (yylen = 0; yystr[yylen]; yylen++)
1023  continue;
1024  return yylen;
1025 }
1026 # endif
1027 # endif
1028 
1029 # ifndef yystpcpy
1030 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
1031 # define yystpcpy stpcpy
1032 # else
1033 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
1034  YYDEST. */
1035 static char *
1036 yystpcpy (char *yydest, const char *yysrc)
1037 {
1038  char *yyd = yydest;
1039  const char *yys = yysrc;
1040 
1041  while ((*yyd++ = *yys++) != '\0')
1042  continue;
1043 
1044  return yyd - 1;
1045 }
1046 # endif
1047 # endif
1048 
1049 # ifndef yytnamerr
1050 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
1051  quotes and backslashes, so that it's suitable for yyerror. The
1052  heuristic is that double-quoting is unnecessary unless the string
1053  contains an apostrophe, a comma, or backslash (other than
1054  backslash-backslash). YYSTR is taken from yytname. If YYRES is
1055  null, do not copy; instead, return the length of what the result
1056  would have been. */
1057 static YYSIZE_T
1058 yytnamerr (char *yyres, const char *yystr)
1059 {
1060  if (*yystr == '"')
1061  {
1062  YYSIZE_T yyn = 0;
1063  char const *yyp = yystr;
1064 
1065  for (;;)
1066  switch (*++yyp)
1067  {
1068  case '\'':
1069  case ',':
1070  goto do_not_strip_quotes;
1071 
1072  case '\\':
1073  if (*++yyp != '\\')
1074  goto do_not_strip_quotes;
1075  /* Fall through. */
1076  default:
1077  if (yyres)
1078  yyres[yyn] = *yyp;
1079  yyn++;
1080  break;
1081 
1082  case '"':
1083  if (yyres)
1084  yyres[yyn] = '\0';
1085  return yyn;
1086  }
1087  do_not_strip_quotes: ;
1088  }
1089 
1090  if (! yyres)
1091  return yystrlen (yystr);
1092 
1093  return yystpcpy (yyres, yystr) - yyres;
1094 }
1095 # endif
1096 
1097 /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
1098  about the unexpected token YYTOKEN for the state stack whose top is
1099  YYSSP.
1100 
1101  Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is
1102  not large enough to hold the message. In that case, also set
1103  *YYMSG_ALLOC to the required number of bytes. Return 2 if the
1104  required number of bytes is too large to store. */
1105 static int
1106 yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
1107  yytype_int16 *yyssp, int yytoken)
1108 {
1109  YYSIZE_T yysize0 = yytnamerr (YY_NULLPTRPTR, yytname[yytoken]);
1110  YYSIZE_T yysize = yysize0;
1111  enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1112  /* Internationalized format string. */
1113  const char *yyformat = YY_NULLPTRPTR;
1114  /* Arguments of yyformat. */
1115  char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1116  /* Number of reported tokens (one for the "unexpected", one per
1117  "expected"). */
1118  int yycount = 0;
1119 
1120  /* There are many possibilities here to consider:
1121  - If this state is a consistent state with a default action, then
1122  the only way this function was invoked is if the default action
1123  is an error action. In that case, don't check for expected
1124  tokens because there are none.
1125  - The only way there can be no lookahead present (in yychar) is if
1126  this state is a consistent state with a default action. Thus,
1127  detecting the absence of a lookahead is sufficient to determine
1128  that there is no unexpected or expected token to report. In that
1129  case, just report a simple "syntax error".
1130  - Don't assume there isn't a lookahead just because this state is a
1131  consistent state with a default action. There might have been a
1132  previous inconsistent state, consistent state with a non-default
1133  action, or user semantic action that manipulated yychar.
1134  - Of course, the expected token list depends on states to have
1135  correct lookahead information, and it depends on the parser not
1136  to perform extra reductions after fetching a lookahead from the
1137  scanner and before detecting a syntax error. Thus, state merging
1138  (from LALR or IELR) and default reductions corrupt the expected
1139  token list. However, the list is correct for canonical LR with
1140  one exception: it will still contain any token that will not be
1141  accepted due to an error action in a later state.
1142  */
1143  if (yytoken != YYEMPTY)
1144  {
1145  int yyn = yypact[*yyssp];
1146  yyarg[yycount++] = yytname[yytoken];
1147  if (!yypact_value_is_default (yyn))
1148  {
1149  /* Start YYX at -YYN if negative to avoid negative indexes in
1150  YYCHECK. In other words, skip the first -YYN actions for
1151  this state because they are default actions. */
1152  int yyxbegin = yyn < 0 ? -yyn : 0;
1153  /* Stay within bounds of both yycheck and yytname. */
1154  int yychecklim = YYLAST - yyn + 1;
1155  int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1156  int yyx;
1157 
1158  for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1159  if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
1160  && !yytable_value_is_error (yytable[yyx + yyn]))
1161  {
1162  if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1163  {
1164  yycount = 1;
1165  yysize = yysize0;
1166  break;
1167  }
1168  yyarg[yycount++] = yytname[yyx];
1169  {
1170  YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTRPTR, yytname[yyx]);
1171  if (! (yysize <= yysize1
1172  && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1173  return 2;
1174  yysize = yysize1;
1175  }
1176  }
1177  }
1178  }
1179 
1180  switch (yycount)
1181  {
1182 # define YYCASE_(N, S) \
1183  case N: \
1184  yyformat = S; \
1185  break
1186  YYCASE_(0, YY_("syntax error"));
1187  YYCASE_(1, YY_("syntax error, unexpected %s"));
1188  YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
1189  YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
1190  YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
1191  YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
1192 # undef YYCASE_
1193  }
1194 
1195  {
1196  YYSIZE_T yysize1 = yysize + yystrlen (yyformat);
1197  if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1198  return 2;
1199  yysize = yysize1;
1200  }
1201 
1202  if (*yymsg_alloc < yysize)
1203  {
1204  *yymsg_alloc = 2 * yysize;
1205  if (! (yysize <= *yymsg_alloc
1206  && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
1207  *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
1208  return 1;
1209  }
1210 
1211  /* Avoid sprintf, as that infringes on the user's name space.
1212  Don't have undefined behavior even if the translation
1213  produced a string with the wrong number of "%s"s. */
1214  {
1215  char *yyp = *yymsg;
1216  int yyi = 0;
1217  while ((*yyp = *yyformat) != '\0')
1218  if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
1219  {
1220  yyp += yytnamerr (yyp, yyarg[yyi++]);
1221  yyformat += 2;
1222  }
1223  else
1224  {
1225  yyp++;
1226  yyformat++;
1227  }
1228  }
1229  return 0;
1230 }
1231 #endif /* YYERROR_VERBOSE */
1232 
1233 /*-----------------------------------------------.
1234 | Release the memory associated to this symbol. |
1235 `-----------------------------------------------*/
1236 
1237 static void
1238 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
1239 {
1240  YYUSE (yyvaluep);
1241  if (!yymsg)
1242  yymsg = "Deleting";
1243  YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1244 
1246  YYUSE (yytype);
1248 }
1249 
1250 
1251 
1252 
1253 /* The lookahead symbol. */
1255 
1256 /* The semantic value of the lookahead symbol. */
1258 /* Number of syntax errors so far. */
1260 
1261 
1262 /*----------.
1263 | yyparse. |
1264 `----------*/
1265 
1266 int
1267 yyparse (void)
1268 {
1269  int yystate;
1270  /* Number of tokens to shift before error messages enabled. */
1271  int yyerrstatus;
1272 
1273  /* The stacks and their tools:
1274  'yyss': related to states.
1275  'yyvs': related to semantic values.
1276 
1277  Refer to the stacks through separate pointers, to allow yyoverflow
1278  to xreallocate them elsewhere. */
1279 
1280  /* The state stack. */
1281  yytype_int16 yyssa[YYINITDEPTH];
1282  yytype_int16 *yyss;
1284 
1285  /* The semantic value stack. */
1286  YYSTYPE yyvsa[YYINITDEPTH];
1287  YYSTYPE *yyvs;
1288  YYSTYPE *yyvsp;
1289 
1291 
1292  int yyn;
1293  int yyresult;
1294  /* Lookahead token as an internal (translated) token number. */
1295  int yytoken = 0;
1296  /* The variables used to return semantic value and location from the
1297  action routines. */
1298  YYSTYPE yyval;
1299 
1300 #if YYERROR_VERBOSE
1301  /* Buffer for error messages, and its allocated size. */
1302  char yymsgbuf[128];
1303  char *yymsg = yymsgbuf;
1304  YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1305 #endif
1306 
1307 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1308 
1309  /* The number of symbols on the RHS of the reduced rule.
1310  Keep to zero when no symbol should be popped. */
1311  int yylen = 0;
1312 
1313  yyssp = yyss = yyssa;
1314  yyvsp = yyvs = yyvsa;
1316 
1317  YYDPRINTF ((stderr, "Starting parse\n"));
1318 
1319  yystate = 0;
1320  yyerrstatus = 0;
1321  yynerrs = 0;
1322  yychar = YYEMPTY; /* Cause a token to be read. */
1323  goto yysetstate;
1324 
1325 /*------------------------------------------------------------.
1326 | yynewstate -- Push a new state, which is found in yystate. |
1327 `------------------------------------------------------------*/
1328  yynewstate:
1329  /* In all cases, when you get here, the value and location stacks
1330  have just been pushed. So pushing a state here evens the stacks. */
1331  yyssp++;
1332 
1333  yysetstate:
1334  *yyssp = yystate;
1335 
1336  if (yyss + yystacksize - 1 <= yyssp)
1337  {
1338  /* Get the current used size of the three stacks, in elements. */
1339  YYSIZE_T yysize = yyssp - yyss + 1;
1340 
1341 #ifdef yyoverflow
1342  {
1343  /* Give user a chance to xreallocate the stack. Use copies of
1344  these so that the &'s don't force the real ones into
1345  memory. */
1346  YYSTYPE *yyvs1 = yyvs;
1347  yytype_int16 *yyss1 = yyss;
1348 
1349  /* Each stack pointer address is followed by the size of the
1350  data in use in that stack, in bytes. This used to be a
1351  conditional around just the two extra args, but that might
1352  be undefined if yyoverflow is a macro. */
1353  yyoverflow (YY_("memory exhausted"),
1354  &yyss1, yysize * sizeof (*yyssp),
1355  &yyvs1, yysize * sizeof (*yyvsp),
1356  &yystacksize);
1357 
1358  yyss = yyss1;
1359  yyvs = yyvs1;
1360  }
1361 #else /* no yyoverflow */
1362 # ifndef YYSTACK_RELOCATE
1363  goto yyexhaustedlab;
1364 # else
1365  /* Extend the stack our own way. */
1366  if (YYMAXDEPTH <= yystacksize)
1367  goto yyexhaustedlab;
1368  yystacksize *= 2;
1369  if (YYMAXDEPTH < yystacksize)
1371 
1372  {
1373  yytype_int16 *yyss1 = yyss;
1374  union yyalloc *yyptr =
1376  if (! yyptr)
1377  goto yyexhaustedlab;
1380 # undef YYSTACK_RELOCATE
1381  if (yyss1 != yyssa)
1382  YYSTACK_FREE (yyss1);
1383  }
1384 # endif
1385 #endif /* no yyoverflow */
1386 
1387  yyssp = yyss + yysize - 1;
1388  yyvsp = yyvs + yysize - 1;
1389 
1390  YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1391  (unsigned long int) yystacksize));
1392 
1393  if (yyss + yystacksize - 1 <= yyssp)
1394  YYABORT;
1395  }
1396 
1397  YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1398 
1399  if (yystate == YYFINAL)
1400  YYACCEPT;
1401 
1402  goto yybackup;
1403 
1404 /*-----------.
1405 | yybackup. |
1406 `-----------*/
1407 yybackup:
1408 
1409  /* Do appropriate processing given the current state. Read a
1410  lookahead token if we need one and don't already have one. */
1411 
1412  /* First try to decide what to do without reference to lookahead token. */
1413  yyn = yypact[yystate];
1414  if (yypact_value_is_default (yyn))
1415  goto yydefault;
1416 
1417  /* Not known => get a lookahead token if don't already have one. */
1418 
1419  /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1420  if (yychar == YYEMPTY)
1421  {
1422  YYDPRINTF ((stderr, "Reading a token: "));
1423  yychar = yylex ();
1424  }
1425 
1426  if (yychar <= YYEOF)
1427  {
1428  yychar = yytoken = YYEOF;
1429  YYDPRINTF ((stderr, "Now at end of input.\n"));
1430  }
1431  else
1432  {
1433  yytoken = YYTRANSLATE (yychar);
1434  YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1435  }
1436 
1437  /* If the proper action on seeing token YYTOKEN is to reduce or to
1438  detect an error, take that action. */
1439  yyn += yytoken;
1440  if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1441  goto yydefault;
1442  yyn = yytable[yyn];
1443  if (yyn <= 0)
1444  {
1445  if (yytable_value_is_error (yyn))
1446  goto yyerrlab;
1447  yyn = -yyn;
1448  goto yyreduce;
1449  }
1450 
1451  /* Count tokens shifted since error; after three, turn off error
1452  status. */
1453  if (yyerrstatus)
1454  yyerrstatus--;
1455 
1456  /* Shift the lookahead token. */
1457  YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1458 
1459  /* Discard the shifted token. */
1460  yychar = YYEMPTY;
1461 
1462  yystate = yyn;
1464  *++yyvsp = yylval;
1466 
1467  goto yynewstate;
1468 
1469 
1470 /*-----------------------------------------------------------.
1471 | yydefault -- do the default action for the current state. |
1472 `-----------------------------------------------------------*/
1473 yydefault:
1474  yyn = yydefact[yystate];
1475  if (yyn == 0)
1476  goto yyerrlab;
1477  goto yyreduce;
1478 
1479 
1480 /*-----------------------------.
1481 | yyreduce -- Do a reduction. |
1482 `-----------------------------*/
1483 yyreduce:
1484  /* yyn is the number of a rule to reduce with. */
1485  yylen = yyr2[yyn];
1486 
1487  /* If YYLEN is nonzero, implement the default value of the action:
1488  '$$ = $1'.
1489 
1490  Otherwise, the following line sets YYVAL to garbage.
1491  This behavior is undocumented and Bison
1492  users should not rely upon it. Assigning to YYVAL
1493  unconditionally makes the parser a bit smaller, and it avoids a
1494  GCC warning that YYVAL may be used uninitialized. */
1495  yyval = yyvsp[1-yylen];
1496 
1497 
1498  YY_REDUCE_PRINT (yyn);
1499  switch (yyn)
1500  {
1501  case 6:
1502 #line 191 "d-exp.y" /* yacc.c:1646 */
1503  { write_exp_elt_opcode (pstate, BINOP_COMMA); }
1504 #line 1506 "d-exp.c" /* yacc.c:1646 */
1505  break;
1506 
1507  case 8:
1508 #line 197 "d-exp.y" /* yacc.c:1646 */
1509  { write_exp_elt_opcode (pstate, BINOP_ASSIGN); }
1510 #line 1512 "d-exp.c" /* yacc.c:1646 */
1511  break;
1512 
1513  case 9:
1514 #line 199 "d-exp.y" /* yacc.c:1646 */
1515  { write_exp_elt_opcode (pstate, BINOP_ASSIGN_MODIFY);
1516  write_exp_elt_opcode (pstate, (yyvsp[-1].opcode));
1517  write_exp_elt_opcode (pstate, BINOP_ASSIGN_MODIFY); }
1518 #line 1520 "d-exp.c" /* yacc.c:1646 */
1519  break;
1520 
1521  case 11:
1522 #line 207 "d-exp.y" /* yacc.c:1646 */
1523  { write_exp_elt_opcode (pstate, TERNOP_COND); }
1524 #line 1526 "d-exp.c" /* yacc.c:1646 */
1525  break;
1526 
1527  case 13:
1528 #line 213 "d-exp.y" /* yacc.c:1646 */
1529  { write_exp_elt_opcode (pstate, BINOP_LOGICAL_OR); }
1530 #line 1532 "d-exp.c" /* yacc.c:1646 */
1531  break;
1532 
1533  case 15:
1534 #line 219 "d-exp.y" /* yacc.c:1646 */
1535  { write_exp_elt_opcode (pstate, BINOP_LOGICAL_AND); }
1536 #line 1538 "d-exp.c" /* yacc.c:1646 */
1537  break;
1538 
1539  case 17:
1540 #line 225 "d-exp.y" /* yacc.c:1646 */
1541  { write_exp_elt_opcode (pstate, BINOP_BITWISE_IOR); }
1542 #line 1544 "d-exp.c" /* yacc.c:1646 */
1543  break;
1544 
1545  case 19:
1546 #line 231 "d-exp.y" /* yacc.c:1646 */
1547  { write_exp_elt_opcode (pstate, BINOP_BITWISE_XOR); }
1548 #line 1550 "d-exp.c" /* yacc.c:1646 */
1549  break;
1550 
1551  case 21:
1552 #line 237 "d-exp.y" /* yacc.c:1646 */
1553  { write_exp_elt_opcode (pstate, BINOP_BITWISE_AND); }
1554 #line 1556 "d-exp.c" /* yacc.c:1646 */
1555  break;
1556 
1557  case 26:
1558 #line 249 "d-exp.y" /* yacc.c:1646 */
1559  { write_exp_elt_opcode (pstate, BINOP_EQUAL); }
1560 #line 1562 "d-exp.c" /* yacc.c:1646 */
1561  break;
1562 
1563  case 27:
1564 #line 251 "d-exp.y" /* yacc.c:1646 */
1565  { write_exp_elt_opcode (pstate, BINOP_NOTEQUAL); }
1566 #line 1568 "d-exp.c" /* yacc.c:1646 */
1567  break;
1568 
1569  case 28:
1570 #line 256 "d-exp.y" /* yacc.c:1646 */
1571  { write_exp_elt_opcode (pstate, BINOP_EQUAL); }
1572 #line 1574 "d-exp.c" /* yacc.c:1646 */
1573  break;
1574 
1575  case 29:
1576 #line 258 "d-exp.y" /* yacc.c:1646 */
1577  { write_exp_elt_opcode (pstate, BINOP_NOTEQUAL); }
1578 #line 1580 "d-exp.c" /* yacc.c:1646 */
1579  break;
1580 
1581  case 30:
1582 #line 263 "d-exp.y" /* yacc.c:1646 */
1583  { write_exp_elt_opcode (pstate, BINOP_LESS); }
1584 #line 1586 "d-exp.c" /* yacc.c:1646 */
1585  break;
1586 
1587  case 31:
1588 #line 265 "d-exp.y" /* yacc.c:1646 */
1589  { write_exp_elt_opcode (pstate, BINOP_LEQ); }
1590 #line 1592 "d-exp.c" /* yacc.c:1646 */
1591  break;
1592 
1593  case 32:
1594 #line 267 "d-exp.y" /* yacc.c:1646 */
1595  { write_exp_elt_opcode (pstate, BINOP_GTR); }
1596 #line 1598 "d-exp.c" /* yacc.c:1646 */
1597  break;
1598 
1599  case 33:
1600 #line 269 "d-exp.y" /* yacc.c:1646 */
1601  { write_exp_elt_opcode (pstate, BINOP_GEQ); }
1602 #line 1604 "d-exp.c" /* yacc.c:1646 */
1603  break;
1604 
1605  case 35:
1606 #line 275 "d-exp.y" /* yacc.c:1646 */
1607  { write_exp_elt_opcode (pstate, BINOP_LSH); }
1608 #line 1610 "d-exp.c" /* yacc.c:1646 */
1609  break;
1610 
1611  case 36:
1612 #line 277 "d-exp.y" /* yacc.c:1646 */
1613  { write_exp_elt_opcode (pstate, BINOP_RSH); }
1614 #line 1616 "d-exp.c" /* yacc.c:1646 */
1615  break;
1616 
1617  case 38:
1618 #line 283 "d-exp.y" /* yacc.c:1646 */
1619  { write_exp_elt_opcode (pstate, BINOP_ADD); }
1620 #line 1622 "d-exp.c" /* yacc.c:1646 */
1621  break;
1622 
1623  case 39:
1624 #line 285 "d-exp.y" /* yacc.c:1646 */
1625  { write_exp_elt_opcode (pstate, BINOP_SUB); }
1626 #line 1628 "d-exp.c" /* yacc.c:1646 */
1627  break;
1628 
1629  case 40:
1630 #line 287 "d-exp.y" /* yacc.c:1646 */
1631  { write_exp_elt_opcode (pstate, BINOP_CONCAT); }
1632 #line 1634 "d-exp.c" /* yacc.c:1646 */
1633  break;
1634 
1635  case 42:
1636 #line 293 "d-exp.y" /* yacc.c:1646 */
1637  { write_exp_elt_opcode (pstate, BINOP_MUL); }
1638 #line 1640 "d-exp.c" /* yacc.c:1646 */
1639  break;
1640 
1641  case 43:
1642 #line 295 "d-exp.y" /* yacc.c:1646 */
1643  { write_exp_elt_opcode (pstate, BINOP_DIV); }
1644 #line 1646 "d-exp.c" /* yacc.c:1646 */
1645  break;
1646 
1647  case 44:
1648 #line 297 "d-exp.y" /* yacc.c:1646 */
1649  { write_exp_elt_opcode (pstate, BINOP_REM); }
1650 #line 1652 "d-exp.c" /* yacc.c:1646 */
1651  break;
1652 
1653  case 45:
1654 #line 301 "d-exp.y" /* yacc.c:1646 */
1655  { write_exp_elt_opcode (pstate, UNOP_ADDR); }
1656 #line 1658 "d-exp.c" /* yacc.c:1646 */
1657  break;
1658 
1659  case 46:
1660 #line 303 "d-exp.y" /* yacc.c:1646 */
1661  { write_exp_elt_opcode (pstate, UNOP_PREINCREMENT); }
1662 #line 1664 "d-exp.c" /* yacc.c:1646 */
1663  break;
1664 
1665  case 47:
1666 #line 305 "d-exp.y" /* yacc.c:1646 */
1667  { write_exp_elt_opcode (pstate, UNOP_PREDECREMENT); }
1668 #line 1670 "d-exp.c" /* yacc.c:1646 */
1669  break;
1670 
1671  case 48:
1672 #line 307 "d-exp.y" /* yacc.c:1646 */
1673  { write_exp_elt_opcode (pstate, UNOP_IND); }
1674 #line 1676 "d-exp.c" /* yacc.c:1646 */
1675  break;
1676 
1677  case 49:
1678 #line 309 "d-exp.y" /* yacc.c:1646 */
1679  { write_exp_elt_opcode (pstate, UNOP_NEG); }
1680 #line 1682 "d-exp.c" /* yacc.c:1646 */
1681  break;
1682 
1683  case 50:
1684 #line 311 "d-exp.y" /* yacc.c:1646 */
1685  { write_exp_elt_opcode (pstate, UNOP_PLUS); }
1686 #line 1688 "d-exp.c" /* yacc.c:1646 */
1687  break;
1688 
1689  case 51:
1690 #line 313 "d-exp.y" /* yacc.c:1646 */
1691  { write_exp_elt_opcode (pstate, UNOP_LOGICAL_NOT); }
1692 #line 1694 "d-exp.c" /* yacc.c:1646 */
1693  break;
1694 
1695  case 52:
1696 #line 315 "d-exp.y" /* yacc.c:1646 */
1697  { write_exp_elt_opcode (pstate, UNOP_COMPLEMENT); }
1698 #line 1700 "d-exp.c" /* yacc.c:1646 */
1699  break;
1700 
1701  case 53:
1702 #line 317 "d-exp.y" /* yacc.c:1646 */
1703  { write_exp_elt_opcode (pstate, UNOP_SIZEOF); }
1704 #line 1706 "d-exp.c" /* yacc.c:1646 */
1705  break;
1706 
1707  case 56:
1708 #line 324 "d-exp.y" /* yacc.c:1646 */
1709  { write_exp_elt_opcode (pstate, UNOP_CAST_TYPE); }
1710 #line 1712 "d-exp.c" /* yacc.c:1646 */
1711  break;
1712 
1713  case 57:
1714 #line 328 "d-exp.y" /* yacc.c:1646 */
1715  { write_exp_elt_opcode (pstate, UNOP_CAST_TYPE); }
1716 #line 1718 "d-exp.c" /* yacc.c:1646 */
1717  break;
1718 
1719  case 59:
1720 #line 335 "d-exp.y" /* yacc.c:1646 */
1721  { write_exp_elt_opcode (pstate, BINOP_EXP); }
1722 #line 1724 "d-exp.c" /* yacc.c:1646 */
1723  break;
1724 
1725  case 61:
1726 #line 341 "d-exp.y" /* yacc.c:1646 */
1727  { struct stoken s;
1729  write_exp_elt_opcode (pstate, STRUCTOP_STRUCT);
1730  s.ptr = "";
1731  s.length = 0;
1732  write_exp_string (pstate, s);
1733  write_exp_elt_opcode (pstate, STRUCTOP_STRUCT); }
1734 #line 1736 "d-exp.c" /* yacc.c:1646 */
1735  break;
1736 
1737  case 62:
1738 #line 349 "d-exp.y" /* yacc.c:1646 */
1739  { write_exp_elt_opcode (pstate, STRUCTOP_STRUCT);
1740  write_exp_string (pstate, (yyvsp[0].sval));
1741  write_exp_elt_opcode (pstate, STRUCTOP_STRUCT); }
1742 #line 1744 "d-exp.c" /* yacc.c:1646 */
1743  break;
1744 
1745  case 63:
1746 #line 353 "d-exp.y" /* yacc.c:1646 */
1748  write_exp_elt_opcode (pstate, STRUCTOP_STRUCT);
1749  write_exp_string (pstate, (yyvsp[-1].sval));
1750  write_exp_elt_opcode (pstate, STRUCTOP_STRUCT); }
1751 #line 1753 "d-exp.c" /* yacc.c:1646 */
1752  break;
1753 
1754  case 64:
1755 #line 358 "d-exp.y" /* yacc.c:1646 */
1756  { write_exp_elt_opcode (pstate, UNOP_SIZEOF); }
1757 #line 1759 "d-exp.c" /* yacc.c:1646 */
1758  break;
1759 
1760  case 65:
1761 #line 360 "d-exp.y" /* yacc.c:1646 */
1762  { write_exp_elt_opcode (pstate, UNOP_POSTINCREMENT); }
1763 #line 1765 "d-exp.c" /* yacc.c:1646 */
1764  break;
1765 
1766  case 66:
1767 #line 362 "d-exp.y" /* yacc.c:1646 */
1768  { write_exp_elt_opcode (pstate, UNOP_POSTDECREMENT); }
1769 #line 1771 "d-exp.c" /* yacc.c:1646 */
1770  break;
1771 
1772  case 70:
1773 #line 370 "d-exp.y" /* yacc.c:1646 */
1774  { arglist_len = 1; }
1775 #line 1777 "d-exp.c" /* yacc.c:1646 */
1776  break;
1777 
1778  case 71:
1779 #line 372 "d-exp.y" /* yacc.c:1646 */
1780  { arglist_len++; }
1781 #line 1783 "d-exp.c" /* yacc.c:1646 */
1782  break;
1783 
1784  case 72:
1785 #line 377 "d-exp.y" /* yacc.c:1646 */
1786  { arglist_len = 0; }
1787 #line 1789 "d-exp.c" /* yacc.c:1646 */
1788  break;
1789 
1790  case 74:
1791 #line 383 "d-exp.y" /* yacc.c:1646 */
1792  { start_arglist (); }
1793 #line 1795 "d-exp.c" /* yacc.c:1646 */
1794  break;
1795 
1796  case 75:
1797 #line 385 "d-exp.y" /* yacc.c:1646 */
1798  { write_exp_elt_opcode (pstate, OP_FUNCALL);
1800  write_exp_elt_opcode (pstate, OP_FUNCALL); }
1801 #line 1803 "d-exp.c" /* yacc.c:1646 */
1802  break;
1803 
1804  case 76:
1805 #line 392 "d-exp.y" /* yacc.c:1646 */
1806  { if (arglist_len > 0)
1807  {
1808  write_exp_elt_opcode (pstate, MULTI_SUBSCRIPT);
1810  write_exp_elt_opcode (pstate, MULTI_SUBSCRIPT);
1811  }
1812  else
1813  write_exp_elt_opcode (pstate, BINOP_SUBSCRIPT);
1814  }
1815 #line 1817 "d-exp.c" /* yacc.c:1646 */
1816  break;
1817 
1818  case 77:
1819 #line 405 "d-exp.y" /* yacc.c:1646 */
1820  { /* Do nothing. */ }
1821 #line 1823 "d-exp.c" /* yacc.c:1646 */
1822  break;
1823 
1824  case 78:
1825 #line 407 "d-exp.y" /* yacc.c:1646 */
1826  { write_exp_elt_opcode (pstate, TERNOP_SLICE); }
1827 #line 1829 "d-exp.c" /* yacc.c:1646 */
1828  break;
1829 
1830  case 79:
1831 #line 412 "d-exp.y" /* yacc.c:1646 */
1832  { /* Do nothing. */ }
1833 #line 1835 "d-exp.c" /* yacc.c:1646 */
1834  break;
1835 
1836  case 80:
1837 #line 414 "d-exp.y" /* yacc.c:1646 */
1838  { struct bound_minimal_symbol msymbol;
1839  char *copy = copy_name ((yyvsp[0].sval));
1840  struct field_of_this_result is_a_field_of_this;
1841  struct block_symbol sym;
1842 
1843  /* Handle VAR, which could be local or global. */
1845  &is_a_field_of_this);
1846  if (sym.symbol && SYMBOL_CLASS (sym.symbol) != LOC_TYPEDEF)
1847  {
1848  if (symbol_read_needs_frame (sym.symbol))
1849  {
1850  if (innermost_block == 0
1851  || contained_in (sym.block, innermost_block))
1852  innermost_block = sym.block;
1853  }
1854 
1855  write_exp_elt_opcode (pstate, OP_VAR_VALUE);
1856  write_exp_elt_block (pstate, sym.block);
1857  write_exp_elt_sym (pstate, sym.symbol);
1858  write_exp_elt_opcode (pstate, OP_VAR_VALUE);
1859  }
1860  else if (is_a_field_of_this.type != NULL)
1861  {
1862  /* It hangs off of `this'. Must not inadvertently convert from a
1863  method call to data ref. */
1864  if (innermost_block == 0
1865  || contained_in (sym.block, innermost_block))
1866  innermost_block = sym.block;
1867  write_exp_elt_opcode (pstate, OP_THIS);
1868  write_exp_elt_opcode (pstate, OP_THIS);
1869  write_exp_elt_opcode (pstate, STRUCTOP_PTR);
1870  write_exp_string (pstate, (yyvsp[0].sval));
1871  write_exp_elt_opcode (pstate, STRUCTOP_PTR);
1872  }
1873  else
1874  {
1875  /* Lookup foreign name in global static symbols. */
1876  msymbol = lookup_bound_minimal_symbol (copy);
1877  if (msymbol.minsym != NULL)
1878  write_exp_msymbol (pstate, msymbol);
1879  else if (!have_full_symbols () && !have_partial_symbols ())
1880  error (_("No symbol table is loaded. Use the \"file\" command"));
1881  else
1882  error (_("No symbol \"%s\" in current context."), copy);
1883  }
1884  }
1885 #line 1887 "d-exp.c" /* yacc.c:1646 */
1886  break;
1887 
1888  case 81:
1889 #line 462 "d-exp.y" /* yacc.c:1646 */
1890  { struct type *type = check_typedef ((yyvsp[-2].tval));
1891 
1892  /* Check if the qualified name is in the global
1893  context. However if the symbol has not already
1894  been resolved, it's not likely to be found. */
1895  if (TYPE_CODE (type) == TYPE_CODE_MODULE)
1896  {
1897  struct bound_minimal_symbol msymbol;
1898  struct block_symbol sym;
1899  const char *type_name = TYPE_SAFE_NAME (type);
1900  int type_name_len = strlen (type_name);
1902  = string_printf ("%.*s.%.*s",
1903  type_name_len, type_name,
1904  (yyvsp[0].sval).length, (yyvsp[0].sval).ptr);
1905 
1906  sym =
1907  lookup_symbol (name.c_str (),
1908  (const struct block *) NULL,
1909  VAR_DOMAIN, NULL);
1910  if (sym.symbol)
1911  {
1912  write_exp_elt_opcode (pstate, OP_VAR_VALUE);
1915  write_exp_elt_opcode (pstate, OP_VAR_VALUE);
1916  break;
1917  }
1918 
1919  msymbol = lookup_bound_minimal_symbol (name.c_str ());
1920  if (msymbol.minsym != NULL)
1921  write_exp_msymbol (pstate, msymbol);
1922  else if (!have_full_symbols () && !have_partial_symbols ())
1923  error (_("No symbol table is loaded. Use the \"file\" command."));
1924  else
1925  error (_("No symbol \"%s\" in current context."),
1926  name.c_str ());
1927  }
1928 
1929  /* Check if the qualified name resolves as a member
1930  of an aggregate or an enum type. */
1931  if (!type_aggregate_p (type))
1932  error (_("`%s' is not defined as an aggregate type."),
1933  TYPE_SAFE_NAME (type));
1934 
1935  write_exp_elt_opcode (pstate, OP_SCOPE);
1937  write_exp_string (pstate, (yyvsp[0].sval));
1938  write_exp_elt_opcode (pstate, OP_SCOPE);
1939  }
1940 #line 1942 "d-exp.c" /* yacc.c:1646 */
1941  break;
1942 
1943  case 82:
1944 #line 513 "d-exp.y" /* yacc.c:1646 */
1945  { write_dollar_variable (pstate, (yyvsp[0].sval)); }
1946 #line 1948 "d-exp.c" /* yacc.c:1646 */
1947  break;
1948 
1949  case 83:
1950 #line 515 "d-exp.y" /* yacc.c:1646 */
1951  { YYSTYPE val;
1952  parse_number (pstate, (yyvsp[0].sval).ptr, (yyvsp[0].sval).length, 0, &val);
1953  write_exp_elt_opcode (pstate, OP_LONG);
1956  (LONGEST) val.typed_val_int.val);
1957  write_exp_elt_opcode (pstate, OP_LONG); }
1958 #line 1960 "d-exp.c" /* yacc.c:1646 */
1959  break;
1960 
1961  case 84:
1962 #line 523 "d-exp.y" /* yacc.c:1646 */
1963  { struct type *type = parse_d_type (pstate)->builtin_void;
1965  write_exp_elt_opcode (pstate, OP_LONG);
1968  write_exp_elt_opcode (pstate, OP_LONG); }
1969 #line 1971 "d-exp.c" /* yacc.c:1646 */
1970  break;
1971 
1972  case 85:
1973 #line 530 "d-exp.y" /* yacc.c:1646 */
1974  { write_exp_elt_opcode (pstate, OP_BOOL);
1976  write_exp_elt_opcode (pstate, OP_BOOL); }
1977 #line 1979 "d-exp.c" /* yacc.c:1646 */
1978  break;
1979 
1980  case 86:
1981 #line 534 "d-exp.y" /* yacc.c:1646 */
1982  { write_exp_elt_opcode (pstate, OP_BOOL);
1984  write_exp_elt_opcode (pstate, OP_BOOL); }
1985 #line 1987 "d-exp.c" /* yacc.c:1646 */
1986  break;
1987 
1988  case 87:
1989 #line 538 "d-exp.y" /* yacc.c:1646 */
1990  { write_exp_elt_opcode (pstate, OP_LONG);
1993  write_exp_elt_opcode (pstate, OP_LONG); }
1994 #line 1996 "d-exp.c" /* yacc.c:1646 */
1995  break;
1996 
1997  case 88:
1998 #line 543 "d-exp.y" /* yacc.c:1646 */
1999  { write_exp_elt_opcode (pstate, OP_FLOAT);
2002  write_exp_elt_opcode (pstate, OP_FLOAT); }
2003 #line 2005 "d-exp.c" /* yacc.c:1646 */
2004  break;
2005 
2006  case 89:
2007 #line 548 "d-exp.y" /* yacc.c:1646 */
2008  { struct stoken_vector vec;
2009  vec.len = 1;
2010  vec.tokens = &(yyvsp[0].tsval);
2011  write_exp_string_vector (pstate, (yyvsp[0].tsval).type, &vec); }
2012 #line 2014 "d-exp.c" /* yacc.c:1646 */
2013  break;
2014 
2015  case 90:
2016 #line 553 "d-exp.y" /* yacc.c:1646 */
2017  { int i;
2018  write_exp_string_vector (pstate, 0, &(yyvsp[0].svec));
2019  for (i = 0; i < (yyvsp[0].svec).len; ++i)
2020  xfree ((yyvsp[0].svec).tokens[i].ptr);
2021  xfree ((yyvsp[0].svec).tokens); }
2022 #line 2024 "d-exp.c" /* yacc.c:1646 */
2023  break;
2024 
2025  case 91:
2026 #line 559 "d-exp.y" /* yacc.c:1646 */
2027  { write_exp_elt_opcode (pstate, OP_ARRAY);
2029  write_exp_elt_longcst (pstate, (LONGEST) (yyvsp[0].ival) - 1);
2030  write_exp_elt_opcode (pstate, OP_ARRAY); }
2031 #line 2033 "d-exp.c" /* yacc.c:1646 */
2032  break;
2033 
2034  case 92:
2035 #line 564 "d-exp.y" /* yacc.c:1646 */
2036  { write_exp_elt_opcode (pstate, OP_TYPEOF); }
2037 #line 2039 "d-exp.c" /* yacc.c:1646 */
2038  break;
2039 
2040  case 93:
2041 #line 569 "d-exp.y" /* yacc.c:1646 */
2042  { (yyval.ival) = arglist_len; }
2043 #line 2045 "d-exp.c" /* yacc.c:1646 */
2044  break;
2045 
2046  case 95:
2047 #line 578 "d-exp.y" /* yacc.c:1646 */
2048  { /* We copy the string here, and not in the
2049  lexer, to guarantee that we do not leak a
2050  string. Note that we follow the
2051  NUL-termination convention of the
2052  lexer. */
2053  struct typed_stoken *vec = XNEW (struct typed_stoken);
2054  (yyval.svec).len = 1;
2055  (yyval.svec).tokens = vec;
2056 
2057  vec->type = (yyvsp[0].tsval).type;
2058  vec->length = (yyvsp[0].tsval).length;
2059  vec->ptr = (char *) xmalloc ((yyvsp[0].tsval).length + 1);
2060  memcpy (vec->ptr, (yyvsp[0].tsval).ptr, (yyvsp[0].tsval).length + 1);
2061  }
2062 #line 2064 "d-exp.c" /* yacc.c:1646 */
2063  break;
2064 
2065  case 96:
2066 #line 593 "d-exp.y" /* yacc.c:1646 */
2067  { /* Note that we NUL-terminate here, but just
2068  for convenience. */
2069  char *p;
2070  ++(yyval.svec).len;
2071  (yyval.svec).tokens
2072  = XRESIZEVEC (struct typed_stoken, (yyval.svec).tokens, (yyval.svec).len);
2073 
2074  p = (char *) xmalloc ((yyvsp[0].tsval).length + 1);
2075  memcpy (p, (yyvsp[0].tsval).ptr, (yyvsp[0].tsval).length + 1);
2076 
2077  (yyval.svec).tokens[(yyval.svec).len - 1].type = (yyvsp[0].tsval).type;
2078  (yyval.svec).tokens[(yyval.svec).len - 1].length = (yyvsp[0].tsval).length;
2079  (yyval.svec).tokens[(yyval.svec).len - 1].ptr = p;
2080  }
2081 #line 2083 "d-exp.c" /* yacc.c:1646 */
2082  break;
2083 
2084  case 97:
2085 #line 611 "d-exp.y" /* yacc.c:1646 */
2086  { /* Do nothing. */ }
2087 #line 2089 "d-exp.c" /* yacc.c:1646 */
2088  break;
2089 
2090  case 98:
2091 #line 613 "d-exp.y" /* yacc.c:1646 */
2092  { write_exp_elt_opcode (pstate, OP_TYPE);
2093  write_exp_elt_type (pstate, (yyvsp[0].tval));
2094  write_exp_elt_opcode (pstate, OP_TYPE); }
2095 #line 2097 "d-exp.c" /* yacc.c:1646 */
2096  break;
2097 
2098  case 99:
2099 #line 617 "d-exp.y" /* yacc.c:1646 */
2100  { (yyval.tval) = follow_types ((yyvsp[-1].tval));
2101  write_exp_elt_opcode (pstate, OP_TYPE);
2102  write_exp_elt_type (pstate, (yyval.tval));
2103  write_exp_elt_opcode (pstate, OP_TYPE);
2104  }
2105 #line 2107 "d-exp.c" /* yacc.c:1646 */
2106  break;
2107 
2108  case 100:
2109 #line 626 "d-exp.y" /* yacc.c:1646 */
2110  { push_type (tp_pointer); }
2111 #line 2113 "d-exp.c" /* yacc.c:1646 */
2112  break;
2113 
2114  case 101:
2115 #line 628 "d-exp.y" /* yacc.c:1646 */
2116  { push_type (tp_pointer); }
2117 #line 2119 "d-exp.c" /* yacc.c:1646 */
2118  break;
2119 
2120  case 102:
2121 #line 630 "d-exp.y" /* yacc.c:1646 */
2122  { push_type_int ((yyvsp[-1].typed_val_int).val);
2123  push_type (tp_array); }
2124 #line 2126 "d-exp.c" /* yacc.c:1646 */
2125  break;
2126 
2127  case 103:
2128 #line 633 "d-exp.y" /* yacc.c:1646 */
2129  { push_type_int ((yyvsp[-2].typed_val_int).val);
2130  push_type (tp_array); }
2131 #line 2133 "d-exp.c" /* yacc.c:1646 */
2132  break;
2133 
2134  case 104:
2135 #line 639 "d-exp.y" /* yacc.c:1646 */
2136  { (yyval.tval) = (yyvsp[0].tsym).type; }
2137 #line 2139 "d-exp.c" /* yacc.c:1646 */
2138  break;
2139 
2140 
2141 #line 2143 "d-exp.c" /* yacc.c:1646 */
2142  default: break;
2143  }
2144  /* User semantic actions sometimes alter yychar, and that requires
2145  that yytoken be updated with the new translation. We take the
2146  approach of translating immediately before every use of yytoken.
2147  One alternative is translating here after every semantic action,
2148  but that translation would be missed if the semantic action invokes
2149  YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
2150  if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
2151  incorrect destructor might then be invoked immediately. In the
2152  case of YYERROR or YYBACKUP, subsequent parser actions might lead
2153  to an incorrect destructor call or verbose syntax error message
2154  before the lookahead is translated. */
2155  YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
2156 
2157  YYPOPSTACK (yylen);
2158  yylen = 0;
2160 
2161  *++yyvsp = yyval;
2162 
2163  /* Now 'shift' the result of the reduction. Determine what state
2164  that goes to, based on the state we popped back to and the rule
2165  number reduced by. */
2166 
2167  yyn = yyr1[yyn];
2168 
2169  yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
2170  if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
2171  yystate = yytable[yystate];
2172  else
2173  yystate = yydefgoto[yyn - YYNTOKENS];
2174 
2175  goto yynewstate;
2176 
2177 
2178 /*--------------------------------------.
2179 | yyerrlab -- here on detecting error. |
2180 `--------------------------------------*/
2181 yyerrlab:
2182  /* Make sure we have latest lookahead translation. See comments at
2183  user semantic actions for why this is necessary. */
2184  yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
2185 
2186  /* If not already recovering from an error, report this error. */
2187  if (!yyerrstatus)
2188  {
2189  ++yynerrs;
2190 #if ! YYERROR_VERBOSE
2191  yyerror (YY_("syntax error"));
2192 #else
2193 # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
2194  yyssp, yytoken)
2195  {
2196  char const *yymsgp = YY_("syntax error");
2197  int yysyntax_error_status;
2198  yysyntax_error_status = YYSYNTAX_ERROR;
2199  if (yysyntax_error_status == 0)
2200  yymsgp = yymsg;
2201  else if (yysyntax_error_status == 1)
2202  {
2203  if (yymsg != yymsgbuf)
2204  YYSTACK_FREE (yymsg);
2205  yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
2206  if (!yymsg)
2207  {
2208  yymsg = yymsgbuf;
2209  yymsg_alloc = sizeof yymsgbuf;
2210  yysyntax_error_status = 2;
2211  }
2212  else
2213  {
2214  yysyntax_error_status = YYSYNTAX_ERROR;
2215  yymsgp = yymsg;
2216  }
2217  }
2218  yyerror (yymsgp);
2219  if (yysyntax_error_status == 2)
2220  goto yyexhaustedlab;
2221  }
2222 # undef YYSYNTAX_ERROR
2223 #endif
2224  }
2225 
2226 
2227 
2228  if (yyerrstatus == 3)
2229  {
2230  /* If just tried and failed to reuse lookahead token after an
2231  error, discard it. */
2232 
2233  if (yychar <= YYEOF)
2234  {
2235  /* Return failure if at end of input. */
2236  if (yychar == YYEOF)
2237  YYABORT;
2238  }
2239  else
2240  {
2241  yydestruct ("Error: discarding",
2242  yytoken, &yylval);
2243  yychar = YYEMPTY;
2244  }
2245  }
2246 
2247  /* Else will try to reuse lookahead token after shifting the error
2248  token. */
2249  goto yyerrlab1;
2250 
2251 
2252 /*---------------------------------------------------.
2253 | yyerrorlab -- error raised explicitly by YYERROR. |
2254 `---------------------------------------------------*/
2255 yyerrorlab:
2256 
2257  /* Pacify compilers like GCC when the user code never invokes
2258  YYERROR and the label yyerrorlab therefore never appears in user
2259  code. */
2260  if (/*CONSTCOND*/ 0)
2261  goto yyerrorlab;
2262 
2263  /* Do not reclaim the symbols of the rule whose action triggered
2264  this YYERROR. */
2265  YYPOPSTACK (yylen);
2266  yylen = 0;
2268  yystate = *yyssp;
2269  goto yyerrlab1;
2270 
2271 
2272 /*-------------------------------------------------------------.
2273 | yyerrlab1 -- common code for both syntax error and YYERROR. |
2274 `-------------------------------------------------------------*/
2275 yyerrlab1:
2276  yyerrstatus = 3; /* Each real token shifted decrements this. */
2277 
2278  for (;;)
2279  {
2280  yyn = yypact[yystate];
2281  if (!yypact_value_is_default (yyn))
2282  {
2283  yyn += YYTERROR;
2284  if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
2285  {
2286  yyn = yytable[yyn];
2287  if (0 < yyn)
2288  break;
2289  }
2290  }
2291 
2292  /* Pop the current state because it cannot handle the error token. */
2293  if (yyssp == yyss)
2294  YYABORT;
2295 
2296 
2297  yydestruct ("Error: popping",
2298  yystos[yystate], yyvsp);
2299  YYPOPSTACK (1);
2300  yystate = *yyssp;
2302  }
2303 
2305  *++yyvsp = yylval;
2307 
2308 
2309  /* Shift the error token. */
2310  YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
2311 
2312  yystate = yyn;
2313  goto yynewstate;
2314 
2315 
2316 /*-------------------------------------.
2317 | yyacceptlab -- YYACCEPT comes here. |
2318 `-------------------------------------*/
2319 yyacceptlab:
2320  yyresult = 0;
2321  goto yyreturn;
2322 
2323 /*-----------------------------------.
2324 | yyabortlab -- YYABORT comes here. |
2325 `-----------------------------------*/
2326 yyabortlab:
2327  yyresult = 1;
2328  goto yyreturn;
2329 
2330 #if !defined yyoverflow || YYERROR_VERBOSE
2331 /*-------------------------------------------------.
2332 | yyexhaustedlab -- memory exhaustion comes here. |
2333 `-------------------------------------------------*/
2334 yyexhaustedlab:
2335  yyerror (YY_("memory exhausted"));
2336  yyresult = 2;
2337  /* Fall through. */
2338 #endif
2339 
2340 yyreturn:
2341  if (yychar != YYEMPTY)
2342  {
2343  /* Make sure we have latest lookahead translation. See comments at
2344  user semantic actions for why this is necessary. */
2345  yytoken = YYTRANSLATE (yychar);
2346  yydestruct ("Cleanup: discarding lookahead",
2347  yytoken, &yylval);
2348  }
2349  /* Do not reclaim the symbols of the rule whose action triggered
2350  this YYABORT or YYACCEPT. */
2351  YYPOPSTACK (yylen);
2353  while (yyssp != yyss)
2354  {
2355  yydestruct ("Cleanup: popping",
2356  yystos[*yyssp], yyvsp);
2357  YYPOPSTACK (1);
2358  }
2359 #ifndef yyoverflow
2360  if (yyss != yyssa)
2361  YYSTACK_FREE (yyss);
2362 #endif
2363 #if YYERROR_VERBOSE
2364  if (yymsg != yymsgbuf)
2365  YYSTACK_FREE (yymsg);
2366 #endif
2367  return yyresult;
2368 }
2369 #line 642 "d-exp.y" /* yacc.c:1906 */
2370 
2371 
2372 /* Return true if the type is aggregate-like. */
2373 
2374 static int
2376 {
2377  return (TYPE_CODE (type) == TYPE_CODE_STRUCT
2380  || (TYPE_CODE (type) == TYPE_CODE_ENUM
2381  && TYPE_DECLARED_CLASS (type)));
2382 }
2383 
2384 /* Take care of parsing a number (anything that starts with a digit).
2385  Set yylval and return the token type; update lexptr.
2386  LEN is the number of characters in it. */
2387 
2388 /*** Needs some error checking for the float case ***/
2389 
2390 static int
2391 parse_number (struct parser_state *ps, const char *p,
2392  int len, int parsed_float, YYSTYPE *putithere)
2393 {
2394  ULONGEST n = 0;
2395  ULONGEST prevn = 0;
2396  ULONGEST un;
2397 
2398  int i = 0;
2399  int c;
2400  int base = input_radix;
2401  int unsigned_p = 0;
2402  int long_p = 0;
2403 
2404  /* We have found a "L" or "U" suffix. */
2405  int found_suffix = 0;
2406 
2407  ULONGEST high_bit;
2408  struct type *signed_type;
2409  struct type *unsigned_type;
2410 
2411  if (parsed_float)
2412  {
2413  char *s, *sp;
2414 
2415  /* Strip out all embedded '_' before passing to parse_float. */
2416  s = (char *) alloca (len + 1);
2417  sp = s;
2418  while (len-- > 0)
2419  {
2420  if (*p != '_')
2421  *sp++ = *p;
2422  p++;
2423  }
2424  *sp = '\0';
2425  len = strlen (s);
2426 
2427  /* Check suffix for `i' , `fi' or `li' (idouble, ifloat or ireal). */
2428  if (len >= 1 && tolower (s[len - 1]) == 'i')
2429  {
2430  if (len >= 2 && tolower (s[len - 2]) == 'f')
2431  {
2432  putithere->typed_val_float.type
2433  = parse_d_type (ps)->builtin_ifloat;
2434  len -= 2;
2435  }
2436  else if (len >= 2 && tolower (s[len - 2]) == 'l')
2437  {
2438  putithere->typed_val_float.type
2439  = parse_d_type (ps)->builtin_ireal;
2440  len -= 2;
2441  }
2442  else
2443  {
2444  putithere->typed_val_float.type
2445  = parse_d_type (ps)->builtin_idouble;
2446  len -= 1;
2447  }
2448  }
2449  /* Check suffix for `f' or `l'' (float or real). */
2450  else if (len >= 1 && tolower (s[len - 1]) == 'f')
2451  {
2452  putithere->typed_val_float.type
2453  = parse_d_type (ps)->builtin_float;
2454  len -= 1;
2455  }
2456  else if (len >= 1 && tolower (s[len - 1]) == 'l')
2457  {
2458  putithere->typed_val_float.type
2459  = parse_d_type (ps)->builtin_real;
2460  len -= 1;
2461  }
2462  /* Default type if no suffix. */
2463  else
2464  {
2465  putithere->typed_val_float.type
2466  = parse_d_type (ps)->builtin_double;
2467  }
2468 
2469  if (!parse_float (s, len,
2470  putithere->typed_val_float.type,
2471  putithere->typed_val_float.val))
2472  return ERROR;
2473 
2474  return FLOAT_LITERAL;
2475  }
2476 
2477  /* Handle base-switching prefixes 0x, 0b, 0 */
2478  if (p[0] == '0')
2479  switch (p[1])
2480  {
2481  case 'x':
2482  case 'X':
2483  if (len >= 3)
2484  {
2485  p += 2;
2486  base = 16;
2487  len -= 2;
2488  }
2489  break;
2490 
2491  case 'b':
2492  case 'B':
2493  if (len >= 3)
2494  {
2495  p += 2;
2496  base = 2;
2497  len -= 2;
2498  }
2499  break;
2500 
2501  default:
2502  base = 8;
2503  break;
2504  }
2505 
2506  while (len-- > 0)
2507  {
2508  c = *p++;
2509  if (c == '_')
2510  continue; /* Ignore embedded '_'. */
2511  if (c >= 'A' && c <= 'Z')
2512  c += 'a' - 'A';
2513  if (c != 'l' && c != 'u')
2514  n *= base;
2515  if (c >= '0' && c <= '9')
2516  {
2517  if (found_suffix)
2518  return ERROR;
2519  n += i = c - '0';
2520  }
2521  else
2522  {
2523  if (base > 10 && c >= 'a' && c <= 'f')
2524  {
2525  if (found_suffix)
2526  return ERROR;
2527  n += i = c - 'a' + 10;
2528  }
2529  else if (c == 'l' && long_p == 0)
2530  {
2531  long_p = 1;
2532  found_suffix = 1;
2533  }
2534  else if (c == 'u' && unsigned_p == 0)
2535  {
2536  unsigned_p = 1;
2537  found_suffix = 1;
2538  }
2539  else
2540  return ERROR; /* Char not a digit */
2541  }
2542  if (i >= base)
2543  return ERROR; /* Invalid digit in this base. */
2544  /* Portably test for integer overflow. */
2545  if (c != 'l' && c != 'u')
2546  {
2547  ULONGEST n2 = prevn * base;
2548  if ((n2 / base != prevn) || (n2 + i < prevn))
2549  error (_("Numeric constant too large."));
2550  }
2551  prevn = n;
2552  }
2553 
2554  /* An integer constant is an int or a long. An L suffix forces it to
2555  be long, and a U suffix forces it to be unsigned. To figure out
2556  whether it fits, we shift it right and see whether anything remains.
2557  Note that we can't shift sizeof (LONGEST) * HOST_CHAR_BIT bits or
2558  more in one operation, because many compilers will warn about such a
2559  shift (which always produces a zero result). To deal with the case
2560  where it is we just always shift the value more than once, with fewer
2561  bits each time. */
2562  un = (ULONGEST) n >> 2;
2563  if (long_p == 0 && (un >> 30) == 0)
2564  {
2565  high_bit = ((ULONGEST) 1) << 31;
2566  signed_type = parse_d_type (ps)->builtin_int;
2567  /* For decimal notation, keep the sign of the worked out type. */
2568  if (base == 10 && !unsigned_p)
2569  unsigned_type = parse_d_type (ps)->builtin_long;
2570  else
2571  unsigned_type = parse_d_type (ps)->builtin_uint;
2572  }
2573  else
2574  {
2575  int shift;
2576  if (sizeof (ULONGEST) * HOST_CHAR_BIT < 64)
2577  /* A long long does not fit in a LONGEST. */
2578  shift = (sizeof (ULONGEST) * HOST_CHAR_BIT - 1);
2579  else
2580  shift = 63;
2581  high_bit = (ULONGEST) 1 << shift;
2582  signed_type = parse_d_type (ps)->builtin_long;
2583  unsigned_type = parse_d_type (ps)->builtin_ulong;
2584  }
2585 
2586  putithere->typed_val_int.val = n;
2587 
2588  /* If the high bit of the worked out type is set then this number
2589  has to be unsigned_type. */
2590  if (unsigned_p || (n & high_bit))
2591  putithere->typed_val_int.type = unsigned_type;
2592  else
2593  putithere->typed_val_int.type = signed_type;
2594 
2595  return INTEGER_LITERAL;
2596 }
2597 
2598 /* Temporary obstack used for holding strings. */
2599 static struct obstack tempbuf;
2600 static int tempbuf_init;
2601 
2602 /* Parse a string or character literal from TOKPTR. The string or
2603  character may be wide or unicode. *OUTPTR is set to just after the
2604  end of the literal in the input string. The resulting token is
2605  stored in VALUE. This returns a token value, either STRING or
2606  CHAR, depending on what was parsed. *HOST_CHARS is set to the
2607  number of host characters in the literal. */
2608 
2609 static int
2610 parse_string_or_char (const char *tokptr, const char **outptr,
2611  struct typed_stoken *value, int *host_chars)
2612 {
2613  int quote;
2614 
2615  /* Build the gdb internal form of the input string in tempbuf. Note
2616  that the buffer is null byte terminated *only* for the
2617  convenience of debugging gdb itself and printing the buffer
2618  contents when the buffer contains no embedded nulls. Gdb does
2619  not depend upon the buffer being null byte terminated, it uses
2620  the length string instead. This allows gdb to handle C strings
2621  (as well as strings in other languages) with embedded null
2622  bytes */
2623 
2624  if (!tempbuf_init)
2625  tempbuf_init = 1;
2626  else
2627  obstack_free (&tempbuf, NULL);
2628  obstack_init (&tempbuf);
2629 
2630  /* Skip the quote. */
2631  quote = *tokptr;
2632  ++tokptr;
2633 
2634  *host_chars = 0;
2635 
2636  while (*tokptr)
2637  {
2638  char c = *tokptr;
2639  if (c == '\\')
2640  {
2641  ++tokptr;
2642  *host_chars += c_parse_escape (&tokptr, &tempbuf);
2643  }
2644  else if (c == quote)
2645  break;
2646  else
2647  {
2648  obstack_1grow (&tempbuf, c);
2649  ++tokptr;
2650  /* FIXME: this does the wrong thing with multi-byte host
2651  characters. We could use mbrlen here, but that would
2652  make "set host-charset" a bit less useful. */
2653  ++*host_chars;
2654  }
2655  }
2656 
2657  if (*tokptr != quote)
2658  {
2659  if (quote == '"' || quote == '`')
2660  error (_("Unterminated string in expression."));
2661  else
2662  error (_("Unmatched single quote."));
2663  }
2664  ++tokptr;
2665 
2666  /* FIXME: should instead use own language string_type enum
2667  and handle D-specific string suffixes here. */
2668  if (quote == '\'')
2669  value->type = C_CHAR;
2670  else
2671  value->type = C_STRING;
2672 
2673  value->ptr = (char *) obstack_base (&tempbuf);
2674  value->length = obstack_object_size (&tempbuf);
2675 
2676  *outptr = tokptr;
2677 
2678  return quote == '\'' ? CHARACTER_LITERAL : STRING_LITERAL;
2679 }
2680 
2681 struct token
2682 {
2683  const char *oper;
2684  int token;
2685  enum exp_opcode opcode;
2686 };
2687 
2688 static const struct token tokentab3[] =
2689  {
2690  {"^^=", ASSIGN_MODIFY, BINOP_EXP},
2691  {"<<=", ASSIGN_MODIFY, BINOP_LSH},
2692  {">>=", ASSIGN_MODIFY, BINOP_RSH},
2693  };
2694 
2695 static const struct token tokentab2[] =
2696  {
2697  {"+=", ASSIGN_MODIFY, BINOP_ADD},
2698  {"-=", ASSIGN_MODIFY, BINOP_SUB},
2699  {"*=", ASSIGN_MODIFY, BINOP_MUL},
2700  {"/=", ASSIGN_MODIFY, BINOP_DIV},
2701  {"%=", ASSIGN_MODIFY, BINOP_REM},
2702  {"|=", ASSIGN_MODIFY, BINOP_BITWISE_IOR},
2703  {"&=", ASSIGN_MODIFY, BINOP_BITWISE_AND},
2704  {"^=", ASSIGN_MODIFY, BINOP_BITWISE_XOR},
2705  {"++", INCREMENT, BINOP_END},
2706  {"--", DECREMENT, BINOP_END},
2707  {"&&", ANDAND, BINOP_END},
2708  {"||", OROR, BINOP_END},
2709  {"^^", HATHAT, BINOP_END},
2710  {"<<", LSH, BINOP_END},
2711  {">>", RSH, BINOP_END},
2712  {"==", EQUAL, BINOP_END},
2713  {"!=", NOTEQUAL, BINOP_END},
2714  {"<=", LEQ, BINOP_END},
2715  {">=", GEQ, BINOP_END},
2716  {"..", DOTDOT, BINOP_END},
2717  };
2718 
2719 /* Identifier-like tokens. */
2720 static const struct token ident_tokens[] =
2721  {
2722  {"is", IDENTITY, BINOP_END},
2723  {"!is", NOTIDENTITY, BINOP_END},
2724 
2725  {"cast", CAST_KEYWORD, OP_NULL},
2726  {"const", CONST_KEYWORD, OP_NULL},
2727  {"immutable", IMMUTABLE_KEYWORD, OP_NULL},
2728  {"shared", SHARED_KEYWORD, OP_NULL},
2729  {"super", SUPER_KEYWORD, OP_NULL},
2730 
2731  {"null", NULL_KEYWORD, OP_NULL},
2732  {"true", TRUE_KEYWORD, OP_NULL},
2733  {"false", FALSE_KEYWORD, OP_NULL},
2734 
2735  {"init", INIT_KEYWORD, OP_NULL},
2736  {"sizeof", SIZEOF_KEYWORD, OP_NULL},
2737  {"typeof", TYPEOF_KEYWORD, OP_NULL},
2738  {"typeid", TYPEID_KEYWORD, OP_NULL},
2739 
2740  {"delegate", DELEGATE_KEYWORD, OP_NULL},
2741  {"function", FUNCTION_KEYWORD, OP_NULL},
2742  {"struct", STRUCT_KEYWORD, OP_NULL},
2743  {"union", UNION_KEYWORD, OP_NULL},
2744  {"class", CLASS_KEYWORD, OP_NULL},
2745  {"interface", INTERFACE_KEYWORD, OP_NULL},
2746  {"enum", ENUM_KEYWORD, OP_NULL},
2747  {"template", TEMPLATE_KEYWORD, OP_NULL},
2748  };
2749 
2750 /* This is set if a NAME token appeared at the very end of the input
2751  string, with no whitespace separating the name from the EOF. This
2752  is used only when parsing to do field name completion. */
2753 static int saw_name_at_eof;
2754 
2755 /* This is set if the previously-returned token was a structure operator.
2756  This is used only when parsing to do field name completion. */
2758 
2759 /* Read one token, getting characters through lexptr. */
2760 
2761 static int
2762 lex_one_token (struct parser_state *par_state)
2763 {
2764  int c;
2765  int namelen;
2766  unsigned int i;
2767  const char *tokstart;
2768  int saw_structop = last_was_structop;
2769  char *copy;
2770 
2771  last_was_structop = 0;
2772 
2773  retry:
2774 
2775  prev_lexptr = lexptr;
2776 
2777  tokstart = lexptr;
2778  /* See if it is a special token of length 3. */
2779  for (i = 0; i < sizeof tokentab3 / sizeof tokentab3[0]; i++)
2780  if (strncmp (tokstart, tokentab3[i].oper, 3) == 0)
2781  {
2782  lexptr += 3;
2784  return tokentab3[i].token;
2785  }
2786 
2787  /* See if it is a special token of length 2. */
2788  for (i = 0; i < sizeof tokentab2 / sizeof tokentab2[0]; i++)
2789  if (strncmp (tokstart, tokentab2[i].oper, 2) == 0)
2790  {
2791  lexptr += 2;
2793  return tokentab2[i].token;
2794  }
2795 
2796  switch (c = *tokstart)
2797  {
2798  case 0:
2799  /* If we're parsing for field name completion, and the previous
2800  token allows such completion, return a COMPLETE token.
2801  Otherwise, we were already scanning the original text, and
2802  we're really done. */
2803  if (saw_name_at_eof)
2804  {
2805  saw_name_at_eof = 0;
2806  return COMPLETE;
2807  }
2808  else if (saw_structop)
2809  return COMPLETE;
2810  else
2811  return 0;
2812 
2813  case ' ':
2814  case '\t':
2815  case '\n':
2816  lexptr++;
2817  goto retry;
2818 
2819  case '[':
2820  case '(':
2821  paren_depth++;
2822  lexptr++;
2823  return c;
2824 
2825  case ']':
2826  case ')':
2827  if (paren_depth == 0)
2828  return 0;
2829  paren_depth--;
2830  lexptr++;
2831  return c;
2832 
2833  case ',':
2834  if (comma_terminates && paren_depth == 0)
2835  return 0;
2836  lexptr++;
2837  return c;
2838 
2839  case '.':
2840  /* Might be a floating point number. */
2841  if (lexptr[1] < '0' || lexptr[1] > '9')
2842  {
2843  if (parse_completion)
2844  last_was_structop = 1;
2845  goto symbol; /* Nope, must be a symbol. */
2846  }
2847  /* FALL THRU into number case. */
2848 
2849  case '0':
2850  case '1':
2851  case '2':
2852  case '3':
2853  case '4':
2854  case '5':
2855  case '6':
2856  case '7':
2857  case '8':
2858  case '9':
2859  {
2860  /* It's a number. */
2861  int got_dot = 0, got_e = 0, toktype;
2862  const char *p = tokstart;
2863  int hex = input_radix > 10;
2864 
2865  if (c == '0' && (p[1] == 'x' || p[1] == 'X'))
2866  {
2867  p += 2;
2868  hex = 1;
2869  }
2870 
2871  for (;; ++p)
2872  {
2873  /* Hex exponents start with 'p', because 'e' is a valid hex
2874  digit and thus does not indicate a floating point number
2875  when the radix is hex. */
2876  if ((!hex && !got_e && tolower (p[0]) == 'e')
2877  || (hex && !got_e && tolower (p[0] == 'p')))
2878  got_dot = got_e = 1;
2879  /* A '.' always indicates a decimal floating point number
2880  regardless of the radix. If we have a '..' then its the
2881  end of the number and the beginning of a slice. */
2882  else if (!got_dot && (p[0] == '.' && p[1] != '.'))
2883  got_dot = 1;
2884  /* This is the sign of the exponent, not the end of the number. */
2885  else if (got_e && (tolower (p[-1]) == 'e' || tolower (p[-1]) == 'p')
2886  && (*p == '-' || *p == '+'))
2887  continue;
2888  /* We will take any letters or digits, ignoring any embedded '_'.
2889  parse_number will complain if past the radix, or if L or U are
2890  not final. */
2891  else if ((*p < '0' || *p > '9') && (*p != '_')
2892  && ((*p < 'a' || *p > 'z') && (*p < 'A' || *p > 'Z')))
2893  break;
2894  }
2895 
2896  toktype = parse_number (par_state, tokstart, p - tokstart,
2897  got_dot|got_e, &yylval);
2898  if (toktype == ERROR)
2899  {
2900  char *err_copy = (char *) alloca (p - tokstart + 1);
2901 
2902  memcpy (err_copy, tokstart, p - tokstart);
2903  err_copy[p - tokstart] = 0;
2904  error (_("Invalid number \"%s\"."), err_copy);
2905  }
2906  lexptr = p;
2907  return toktype;
2908  }
2909 
2910  case '@':
2911  {
2912  const char *p = &tokstart[1];
2913  size_t len = strlen ("entry");
2914 
2915  while (isspace (*p))
2916  p++;
2917  if (strncmp (p, "entry", len) == 0 && !isalnum (p[len])
2918  && p[len] != '_')
2919  {
2920  lexptr = &p[len];
2921  return ENTRY;
2922  }
2923  }
2924  /* FALLTHRU */
2925  case '+':
2926  case '-':
2927  case '*':
2928  case '/':
2929  case '%':
2930  case '|':
2931  case '&':
2932  case '^':
2933  case '~':
2934  case '!':
2935  case '<':
2936  case '>':
2937  case '?':
2938  case ':':
2939  case '=':
2940  case '{':
2941  case '}':
2942  symbol:
2943  lexptr++;
2944  return c;
2945 
2946  case '\'':
2947  case '"':
2948  case '`':
2949  {
2950  int host_len;
2951  int result = parse_string_or_char (tokstart, &lexptr, &yylval.tsval,
2952  &host_len);
2953  if (result == CHARACTER_LITERAL)
2954  {
2955  if (host_len == 0)
2956  error (_("Empty character constant."));
2957  else if (host_len > 2 && c == '\'')
2958  {
2959  ++tokstart;
2960  namelen = lexptr - tokstart - 1;
2961  goto tryname;
2962  }
2963  else if (host_len > 1)
2964  error (_("Invalid character constant."));
2965  }
2966  return result;
2967  }
2968  }
2969 
2970  if (!(c == '_' || c == '$'
2971  || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')))
2972  /* We must have come across a bad character (e.g. ';'). */
2973  error (_("Invalid character '%c' in expression"), c);
2974 
2975  /* It's a name. See how long it is. */
2976  namelen = 0;
2977  for (c = tokstart[namelen];
2978  (c == '_' || c == '$' || (c >= '0' && c <= '9')
2979  || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'));)
2980  c = tokstart[++namelen];
2981 
2982  /* The token "if" terminates the expression and is NOT
2983  removed from the input stream. */
2984  if (namelen == 2 && tokstart[0] == 'i' && tokstart[1] == 'f')
2985  return 0;
2986 
2987  /* For the same reason (breakpoint conditions), "thread N"
2988  terminates the expression. "thread" could be an identifier, but
2989  an identifier is never followed by a number without intervening
2990  punctuation. "task" is similar. Handle abbreviations of these,
2991  similarly to breakpoint.c:find_condition_and_thread. */
2992  if (namelen >= 1
2993  && (strncmp (tokstart, "thread", namelen) == 0
2994  || strncmp (tokstart, "task", namelen) == 0)
2995  && (tokstart[namelen] == ' ' || tokstart[namelen] == '\t'))
2996  {
2997  const char *p = tokstart + namelen + 1;
2998 
2999  while (*p == ' ' || *p == '\t')
3000  p++;
3001  if (*p >= '0' && *p <= '9')
3002  return 0;
3003  }
3004 
3005  lexptr += namelen;
3006 
3007  tryname:
3008 
3009  yylval.sval.ptr = tokstart;
3010  yylval.sval.length = namelen;
3011 
3012  /* Catch specific keywords. */
3013  copy = copy_name (yylval.sval);
3014  for (i = 0; i < sizeof ident_tokens / sizeof ident_tokens[0]; i++)
3015  if (strcmp (copy, ident_tokens[i].oper) == 0)
3016  {
3017  /* It is ok to always set this, even though we don't always
3018  strictly need to. */
3020  return ident_tokens[i].token;
3021  }
3022 
3023  if (*tokstart == '$')
3024  return DOLLAR_VARIABLE;
3025 
3026  yylval.tsym.type
3028  parse_gdbarch (par_state), copy);
3029  if (yylval.tsym.type != NULL)
3030  return TYPENAME;
3031 
3032  /* Input names that aren't symbols but ARE valid hex numbers,
3033  when the input radix permits them, can be names or numbers
3034  depending on the parse. Note we support radixes > 16 here. */
3035  if ((tokstart[0] >= 'a' && tokstart[0] < 'a' + input_radix - 10)
3036  || (tokstart[0] >= 'A' && tokstart[0] < 'A' + input_radix - 10))
3037  {
3038  YYSTYPE newlval; /* Its value is ignored. */
3039  int hextype = parse_number (par_state, tokstart, namelen, 0, &newlval);
3040  if (hextype == INTEGER_LITERAL)
3041  return NAME_OR_INT;
3042  }
3043 
3044  if (parse_completion && *lexptr == '\0')
3045  saw_name_at_eof = 1;
3046 
3047  return IDENTIFIER;
3048 }
3049 
3050 /* An object of this type is pushed on a FIFO by the "outer" lexer. */
3051 typedef struct
3052 {
3053  int token;
3054  YYSTYPE value;
3055 } token_and_value;
3056 
3058 
3059 /* A FIFO of tokens that have been read but not yet returned to the
3060  parser. */
3061 static VEC (token_and_value) *token_fifo;
3062 
3063 /* Non-zero if the lexer should return tokens from the FIFO. */
3064 static int popping;
3065 
3066 /* Temporary storage for yylex; this holds symbol names as they are
3067  built up. */
3068 static auto_obstack name_obstack;
3069 
3070 /* Classify an IDENTIFIER token. The contents of the token are in `yylval'.
3071  Updates yylval and returns the new token type. BLOCK is the block
3072  in which lookups start; this can be NULL to mean the global scope. */
3073 
3074 static int
3075 classify_name (struct parser_state *par_state, const struct block *block)
3076 {
3077  struct block_symbol sym;
3078  char *copy;
3079  struct field_of_this_result is_a_field_of_this;
3080 
3081  copy = copy_name (yylval.sval);
3082 
3083  sym = lookup_symbol (copy, block, VAR_DOMAIN, &is_a_field_of_this);
3084  if (sym.symbol && SYMBOL_CLASS (sym.symbol) == LOC_TYPEDEF)
3085  {
3086  yylval.tsym.type = SYMBOL_TYPE (sym.symbol);
3087  return TYPENAME;
3088  }
3089  else if (sym.symbol == NULL)
3090  {
3091  /* Look-up first for a module name, then a type. */
3092  sym = lookup_symbol (copy, block, MODULE_DOMAIN, NULL);
3093  if (sym.symbol == NULL)
3094  sym = lookup_symbol (copy, block, STRUCT_DOMAIN, NULL);
3095 
3096  if (sym.symbol != NULL)
3097  {
3098  yylval.tsym.type = SYMBOL_TYPE (sym.symbol);
3099  return TYPENAME;
3100  }
3101 
3102  return UNKNOWN_NAME;
3103  }
3104 
3105  return IDENTIFIER;
3106 }
3107 
3108 /* Like classify_name, but used by the inner loop of the lexer, when a
3109  name might have already been seen. CONTEXT is the context type, or
3110  NULL if this is the first component of a name. */
3111 
3112 static int
3114  const struct block *block, struct type *context)
3115 {
3116  struct type *type;
3117  char *copy;
3118 
3119  if (context == NULL)
3120  return classify_name (par_state, block);
3121 
3122  type = check_typedef (context);
3123  if (!type_aggregate_p (type))
3124  return ERROR;
3125 
3126  copy = copy_name (yylval.ssym.stoken);
3128 
3129  if (yylval.ssym.sym.symbol == NULL)
3130  return ERROR;
3131 
3133  {
3135  return TYPENAME;
3136  }
3137 
3138  return IDENTIFIER;
3139 }
3140 
3141 /* The outer level of a two-level lexer. This calls the inner lexer
3142  to return tokens. It then either returns these tokens, or
3143  aggregates them into a larger token. This lets us work around a
3144  problem in our parsing approach, where the parser could not
3145  distinguish between qualified names and qualified types at the
3146  right point. */
3147 
3148 static int
3149 yylex (void)
3150 {
3151  token_and_value current;
3152  int last_was_dot;
3153  struct type *context_type = NULL;
3154  int last_to_examine, next_to_examine, checkpoint;
3155  const struct block *search_block;
3156 
3157  if (popping && !VEC_empty (token_and_value, token_fifo))
3158  goto do_pop;
3159  popping = 0;
3160 
3161  /* Read the first token and decide what to do. */
3162  current.token = lex_one_token (pstate);
3163  if (current.token != IDENTIFIER && current.token != '.')
3164  return current.token;
3165 
3166  /* Read any sequence of alternating "." and identifier tokens into
3167  the token FIFO. */
3168  current.value = yylval;
3169  VEC_safe_push (token_and_value, token_fifo, &current);
3170  last_was_dot = current.token == '.';
3171 
3172  while (1)
3173  {
3174  current.token = lex_one_token (pstate);
3175  current.value = yylval;
3176  VEC_safe_push (token_and_value, token_fifo, &current);
3177 
3178  if ((last_was_dot && current.token != IDENTIFIER)
3179  || (!last_was_dot && current.token != '.'))
3180  break;
3181 
3182  last_was_dot = !last_was_dot;
3183  }
3184  popping = 1;
3185 
3186  /* We always read one extra token, so compute the number of tokens
3187  to examine accordingly. */
3188  last_to_examine = VEC_length (token_and_value, token_fifo) - 2;
3189  next_to_examine = 0;
3190 
3191  current = *VEC_index (token_and_value, token_fifo, next_to_examine);
3192  ++next_to_examine;
3193 
3194  /* If we are not dealing with a typename, now is the time to find out. */
3195  if (current.token == IDENTIFIER)
3196  {
3197  yylval = current.value;
3199  current.value = yylval;
3200  }
3201 
3202  /* If the IDENTIFIER is not known, it could be a package symbol,
3203  first try building up a name until we find the qualified module. */
3204  if (current.token == UNKNOWN_NAME)
3205  {
3206  name_obstack.clear ();
3207  obstack_grow (&name_obstack, current.value.sval.ptr,
3208  current.value.sval.length);
3209 
3210  last_was_dot = 0;
3211 
3212  while (next_to_examine <= last_to_examine)
3213  {
3214  token_and_value *next;
3215 
3216  next = VEC_index (token_and_value, token_fifo, next_to_examine);
3217  ++next_to_examine;
3218 
3219  if (next->token == IDENTIFIER && last_was_dot)
3220  {
3221  /* Update the partial name we are constructing. */
3222  obstack_grow_str (&name_obstack, ".");
3223  obstack_grow (&name_obstack, next->value.sval.ptr,
3224  next->value.sval.length);
3225 
3226  yylval.sval.ptr = (char *) obstack_base (&name_obstack);
3227  yylval.sval.length = obstack_object_size (&name_obstack);
3228 
3230  current.value = yylval;
3231 
3232  /* We keep going until we find a TYPENAME. */
3233  if (current.token == TYPENAME)
3234  {
3235  /* Install it as the first token in the FIFO. */
3236  VEC_replace (token_and_value, token_fifo, 0, &current);
3237  VEC_block_remove (token_and_value, token_fifo, 1,
3238  next_to_examine - 1);
3239  break;
3240  }
3241  }
3242  else if (next->token == '.' && !last_was_dot)
3243  last_was_dot = 1;
3244  else
3245  {
3246  /* We've reached the end of the name. */
3247  break;
3248  }
3249  }
3250 
3251  /* Reset our current token back to the start, if we found nothing
3252  this means that we will just jump to do pop. */
3253  current = *VEC_index (token_and_value, token_fifo, 0);
3254  next_to_examine = 1;
3255  }
3256  if (current.token != TYPENAME && current.token != '.')
3257  goto do_pop;
3258 
3259  name_obstack.clear ();
3260  checkpoint = 0;
3261  if (current.token == '.')
3262  search_block = NULL;
3263  else
3264  {
3265  gdb_assert (current.token == TYPENAME);
3266  search_block = expression_context_block;
3267  obstack_grow (&name_obstack, current.value.sval.ptr,
3268  current.value.sval.length);
3269  context_type = current.value.tsym.type;
3270  checkpoint = 1;
3271  }
3272 
3273  last_was_dot = current.token == '.';
3274 
3275  while (next_to_examine <= last_to_examine)
3276  {
3277  token_and_value *next;
3278 
3279  next = VEC_index (token_and_value, token_fifo, next_to_examine);
3280  ++next_to_examine;
3281 
3282  if (next->token == IDENTIFIER && last_was_dot)
3283  {
3284  int classification;
3285 
3286  yylval = next->value;
3287  classification = classify_inner_name (pstate, search_block,
3288  context_type);
3289  /* We keep going until we either run out of names, or until
3290  we have a qualified name which is not a type. */
3291  if (classification != TYPENAME && classification != IDENTIFIER)
3292  break;
3293 
3294  /* Accept up to this token. */
3295  checkpoint = next_to_examine;
3296 
3297  /* Update the partial name we are constructing. */
3298  if (context_type != NULL)
3299  {
3300  /* We don't want to put a leading "." into the name. */
3301  obstack_grow_str (&name_obstack, ".");
3302  }
3303  obstack_grow (&name_obstack, next->value.sval.ptr,
3304  next->value.sval.length);
3305 
3306  yylval.sval.ptr = (char *) obstack_base (&name_obstack);
3307  yylval.sval.length = obstack_object_size (&name_obstack);
3308  current.value = yylval;
3309  current.token = classification;
3310 
3311  last_was_dot = 0;
3312 
3313  if (classification == IDENTIFIER)
3314  break;
3315 
3316  context_type = yylval.tsym.type;
3317  }
3318  else if (next->token == '.' && !last_was_dot)
3319  last_was_dot = 1;
3320  else
3321  {
3322  /* We've reached the end of the name. */
3323  break;
3324  }
3325  }
3326 
3327  /* If we have a replacement token, install it as the first token in
3328  the FIFO, and delete the other constituent tokens. */
3329  if (checkpoint > 0)
3330  {
3331  VEC_replace (token_and_value, token_fifo, 0, &current);
3332  if (checkpoint > 1)
3333  VEC_block_remove (token_and_value, token_fifo, 1, checkpoint - 1);
3334  }
3335 
3336  do_pop:
3337  current = *VEC_index (token_and_value, token_fifo, 0);
3338  VEC_ordered_remove (token_and_value, token_fifo, 0);
3339  yylval = current.value;
3340  return current.token;
3341 }
3342 
3343 int
3344 d_parse (struct parser_state *par_state)
3345 {
3346  /* Setting up the parser state. */
3347  scoped_restore pstate_restore = make_scoped_restore (&pstate);
3348  gdb_assert (par_state != NULL);
3349  pstate = par_state;
3350 
3351  scoped_restore restore_yydebug = make_scoped_restore (&yydebug,
3352  parser_debug);
3353 
3354  /* Initialize some state used by the lexer. */
3355  last_was_structop = 0;
3356  saw_name_at_eof = 0;
3357 
3358  VEC_free (token_and_value, token_fifo);
3359  popping = 0;
3360  name_obstack.clear ();
3361 
3362  return yyparse ();
3363 }
3364 
3365 void
3366 yyerror (const char *msg)
3367 {
3368  if (prev_lexptr)
3369  lexptr = prev_lexptr;
3370 
3371  error (_("A %s in expression, near `%s'."), (msg ? msg : "error"), lexptr);
3372 }
3373 
#define YYSTACK_ALLOC_MAXIMUM
Definition: d-exp.c:436
unsigned int length
Definition: gdbtypes.h:803
const char * string
Definition: signals.c:50
#define YYSTACK_RELOCATE(Stack_alloc, Stack)
Definition: d-exp.c:489
struct type * type
Definition: parser-defs.h:115
int yychar
Definition: d-exp.c:1254
#define YYFPRINTF
Definition: yy-remap.h:92
#define yylen
#define FALSE_KEYWORD
Definition: d-exp.c:198
#define YY_SYMBOL_PRINT(Title, Type, Value, Location)
Definition: d-exp.c:884
#define YY_STACK_PRINT(Bottom, Top)
Definition: d-exp.c:946
void write_exp_elt_sym(struct parser_state *ps, struct symbol *expelt)
Definition: parse.c:215
#define parse_language(ps)
Definition: parser-defs.h:36
#define VEC_replace(T, V, I, O)
Definition: vec.h:318
signed char yytype_int8
Definition: ada-exp.c:330
static VEC(token_and_value)
Definition: d-exp.c:3061
struct YYSTYPE::@18 typed_val_int
#define parse_gdbarch(ps)
Definition: parser-defs.h:35
struct type * type
Definition: value.c:266
#define UNKNOWN_NAME
Definition: d-exp.c:187
#define NOTIDENTITY
Definition: d-exp.c:229
bool parse_float(const char *p, int len, const struct type *type, gdb_byte *data)
Definition: parse.c:1331
#define yyvs
struct symbol * sym
Definition: d-exp.c:249
#define yylloc
#define YYTERROR
Definition: d-exp.c:859
const char * ptr
Definition: parser-defs.h:91
#define yypact_value_is_default(Yystate)
Definition: d-exp.c:647
#define yyssp
static int yylex(void)
Definition: d-exp.c:3149
#define TRUE_KEYWORD
Definition: d-exp.c:197
signed char yytype_int8
Definition: d-exp.c:299
int comma_terminates
Definition: parse.c:77
#define FUNCTION_KEYWORD
Definition: d-exp.c:216
Definition: c-lang.h:51
int parse_completion
Definition: parse.c:80
#define STRING_LITERAL
Definition: d-exp.c:194
static const yytype_uint8 yydefact[]
Definition: d-exp.c:681
#define INTEGER_LITERAL
Definition: d-exp.c:191
int yynerrs
Definition: d-exp.c:1259
#define CHARACTER_LITERAL
Definition: d-exp.c:193
#define yyvsp
int yyparse(void)
Definition: d-exp.c:1267
int end_arglist(void)
Definition: parse.c:143
#define SUPER_KEYWORD
Definition: d-exp.c:200
int arglist_len
Definition: parse.c:72
#define SYMBOL_CLASS(symbol)
Definition: symtab.h:1155
#define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
Definition: d-exp.c:387
#define CLASS_KEYWORD
Definition: d-exp.c:211
#define VEC_block_remove(T, V, I, L)
Definition: vec.h:376
DEF_VEC_O(token_and_value)
#define NULL_KEYWORD
Definition: d-exp.c:199
#define INTERFACE_KEYWORD
Definition: d-exp.c:212
struct symtoken ssym
Definition: c-exp.c:287
const struct block * innermost_block
Definition: parse.c:71
#define YY_(Msgid)
Definition: d-exp.c:337
int have_partial_symbols(void)
Definition: objfiles.c:1023
#define COMPLETE
Definition: d-exp.c:189
Definition: c-exp.c:4864
#define VEC_safe_push(T, V, O)
Definition: vec.h:276
#define YY_REDUCE_PRINT(Rule)
Definition: d-exp.c:977
struct block_symbol lookup_symbol(const char *name, const struct block *block, domain_enum domain, struct field_of_this_result *is_a_field_of_this)
Definition: symtab.c:1893
void xfree(void *)
int token
Definition: c-exp.c:4867
void push_type(enum type_pieces tp)
Definition: parse.c:1408
int c_parse_escape(const char **ptr, struct obstack *output)
Definition: c-exp.c:4591
#define _(String)
Definition: gdb_locale.h:35
static void yy_symbol_print(FILE *yyoutput, int yytype, YYSTYPE const *const yyvaluep)
Definition: d-exp.c:920
#define YYPRINT(FILE, TYPE, VALUE)
Definition: c-exp.c:328
#define TYPEOF_KEYWORD
Definition: d-exp.c:203
#define parse_d_type(ps)
Definition: d-exp.c:83
#define XNEW(T)
Definition: poison.h:109
unsigned input_radix
Definition: valprint.c:157
#define HATHAT
Definition: d-exp.c:227
static int saw_name_at_eof
Definition: d-exp.c:2753
#define TEMPLATE_KEYWORD
Definition: d-exp.c:214
int yydebug
Definition: d-exp.c:985
scoped_restore_tmpl< T > make_scoped_restore(T *var)
void push_type_int(int n)
Definition: parse.c:1415
static void yy_stack_print(yytype_int16 *yybottom, yytype_int16 *yytop)
Definition: d-exp.c:935
#define INIT_KEYWORD
Definition: d-exp.c:205
#define YYSTACK_BYTES(N)
Definition: d-exp.c:478
void * xmalloc(YYSIZE_T)
YYSTYPE yylval
Definition: d-exp.c:1257
#define DOLLAR_VARIABLE
Definition: d-exp.c:217
struct typed_stoken tsval
Definition: c-exp.c:285
const char *const name
Definition: aarch64-tdep.c:76
void write_exp_elt_block(struct parser_state *ps, const struct block *b)
Definition: parse.c:235
void write_exp_elt_longcst(struct parser_state *ps, LONGEST expelt)
Definition: parse.c:255
#define YYSTACK_ALLOC
Definition: d-exp.c:433
#define YYSIZE_T
Definition: d-exp.c:321
struct type * check_typedef(struct type *type)
Definition: gdbtypes.c:2421
int contained_in(const struct block *a, const struct block *b)
Definition: block.c:73
static const yytype_uint8 yystos[]
Definition: d-exp.c:775
#define YY_NULLPTRPTR
Definition: d-exp.c:110
#define EQUAL
Definition: d-exp.c:221
unsigned short int yytype_uint16
Definition: d-exp.c:305
struct type * follow_types(struct type *follow_type)
Definition: parse.c:1580
#define NOTEQUAL
Definition: d-exp.c:222
#define YYUSE(E)
Definition: d-exp.c:370
struct block_symbol sym
Definition: parser-defs.h:121
#define yyss
struct stoken_vector svec
Definition: c-exp.c:292
const char * oper
Definition: c-exp.c:4866
#define YYSTACK_FREE
Definition: d-exp.c:434
const struct block * block
Definition: symtab.h:1140
struct YYSTYPE::@2 typed_val_float
int symbol_read_needs_frame(struct symbol *sym)
Definition: findvar.c:392
#define YYINITDEPTH
Definition: d-exp.c:996
#define OROR
Definition: d-exp.c:219
#define VEC_length(T, V)
Definition: vec.h:140
#define YYFINAL
Definition: d-exp.c:523
yytype_int16 yyss_alloc
Definition: ada-exp.c:500
static const yytype_int16 yypact[]
Definition: d-exp.c:657
Definition: gdbtypes.h:749
int d_parse(struct parser_state *par_state)
Definition: d-exp.c:3344
#define VEC_index(T, V, I)
Definition: vec.h:167
struct block_symbol d_lookup_nested_symbol(struct type *, const char *, const struct block *)
Definition: d-namespace.c:303
int voidval
Definition: c-exp.c:288
yytokentype
Definition: ada-exp.c:178
static const yytype_uint16 yytoknum[]
Definition: c-exp.c:699
void write_dollar_variable(struct parser_state *ps, struct stoken str)
Definition: parse.c:594
#define UNION_KEYWORD
Definition: d-exp.c:210
static const char * type
Definition: language.c:113
void mark_struct_expression(struct parser_state *ps)
Definition: parse.c:544
YYSTYPE value
Definition: c-exp.c:5441
static const char *const yytname[]
Definition: d-exp.c:602
YYSTYPE yyvs_alloc
Definition: ada-exp.c:501
static int last_was_structop
Definition: d-exp.c:2757
#define YYABORT
Definition: d-exp.c:835
#define yyrule
unsigned short int yytype_uint16
Definition: ada-exp.c:336
int token
Definition: m2-exp.c:2527
static const struct token tokentab2[]
Definition: d-exp.c:2695
static int classify_name(struct parser_state *par_state, const struct block *block)
Definition: go-exp.c:3017
static const yytype_uint8 yyr2[]
Definition: d-exp.c:813
void yyerror(const char *)
Definition: d-exp.c:3366
#define XRESIZEVEC(T, P, N)
Definition: poison.h:169
static const yytype_int8 yypgoto[]
Definition: d-exp.c:703
int parser_debug
Definition: parse.c:104
#define YYMAXDEPTH
Definition: d-exp.c:1007
#define YYLAST
Definition: d-exp.c:525
void write_exp_msymbol(struct parser_state *ps, struct bound_minimal_symbol bound_msym)
Definition: parse.c:531
int paren_depth
Definition: parse.c:76
struct symbol * symbol
Definition: symtab.h:1136
#define YYTRANSLATE(YYX)
Definition: d-exp.c:541
#define gdb_assert(expr)
Definition: gdb_assert.h:32
Definition: block.h:60
struct type * type
Definition: symtab.h:1535
#define VEC_empty(T, V)
Definition: vec.h:148
Definition: value.c:169
struct block * bval
Definition: d-exp.c:257
LONGEST val
Definition: ada-exp.c:285
void write_exp_elt_opcode(struct parser_state *ps, enum exp_opcode expelt)
Definition: parse.c:205
#define SHARED_KEYWORD
Definition: d-exp.c:208
static const struct token tokentab3[]
Definition: d-exp.c:2688
static const char * lexptr
static int classify_inner_name(struct parser_state *par_state, const struct block *block, struct type *context)
Definition: d-exp.c:3113
#define CONST_KEYWORD
Definition: d-exp.c:207
bfd_byte gdb_byte
Definition: common-types.h:38
#define DELEGATE_KEYWORD
Definition: d-exp.c:215
static int tempbuf_init
Definition: d-exp.c:2600
unsigned char yytype_uint8
Definition: ada-exp.c:324
#define YYEMPTY
Definition: d-exp.c:831
static int parse_number(struct parser_state *, const char *, int, int, YYSTYPE *)
Definition: d-exp.c:2391
#define INCREMENT
Definition: d-exp.c:230
struct ttype tsym
Definition: c-exp.c:286
#define yys
#define TYPE_CODE(thistype)
Definition: gdbtypes.h:1238
static int lex_one_token(struct parser_state *par_state)
Definition: d-exp.c:2762
#define YYNTOKENS
Definition: d-exp.c:528
#define YY_IGNORE_MAYBE_UNINITIALIZED_END
Definition: d-exp.c:388
struct minimal_symbol * minsym
Definition: minsyms.h:34
#define IMMUTABLE_KEYWORD
Definition: d-exp.c:206
#define RSH
Definition: d-exp.c:226
#define NAME_OR_INT
Definition: d-exp.c:190
#define YYDPRINTF(Args)
Definition: d-exp.c:872
static const yytype_int16 yycheck[]
Definition: d-exp.c:748
const char * symbol
Definition: signals.c:48
#define SIZEOF_KEYWORD
Definition: d-exp.c:202
struct type * tval
Definition: ada-exp.c:292
static int type_aggregate_p(struct type *)
Definition: d-exp.c:2375
struct bound_minimal_symbol lookup_bound_minimal_symbol(const char *name)
Definition: minsyms.c:430
#define VEC_free(T, V)
Definition: vec.h:196
#define yystate
exp_opcode
Definition: expression.h:42
enum exp_opcode opcode
Definition: c-exp.c:290
#define obstack_grow_str(OBSTACK, STRING)
Definition: gdb_obstack.h:46
#define STRUCT_KEYWORD
Definition: d-exp.c:209
#define IDENTITY
Definition: d-exp.c:228
std::string string_printf(const char *fmt,...)
Definition: common-utils.c:150
#define ENUM_KEYWORD
Definition: d-exp.c:213
int have_full_symbols(void)
Definition: objfiles.c:1040
#define LSH
Definition: d-exp.c:225
static const yytype_uint8 yytranslate[]
Definition: d-exp.c:546
const struct block * expression_context_block
Definition: parse.c:69
struct type * type
Definition: ada-exp.c:286
unsigned long long ULONGEST
Definition: common-types.h:53
struct typed_stoken * tokens
Definition: parser-defs.h:109
static void yy_symbol_value_print(FILE *yyoutput, int yytype, YYSTYPE const *const yyvaluep)
Definition: d-exp.c:901
unsigned char yytype_uint8
Definition: d-exp.c:293
#define SYMBOL_TYPE(symbol)
Definition: symtab.h:1161
#define yyval
#define YYACCEPT
Definition: d-exp.c:834
int ival
Definition: d-exp.c:255
#define FLOAT_LITERAL
Definition: d-exp.c:192
void start_arglist(void)
Definition: parse.c:133
#define DECREMENT
Definition: d-exp.c:231
#define YYPOPSTACK(N)
static const yytype_uint8 yyr1[]
Definition: d-exp.c:797
#define GEQ
Definition: d-exp.c:224
static const yytype_uint16 yyrline[]
Definition: d-exp.c:583
#define IDENTIFIER
Definition: d-exp.c:186
short int yytype_int16
Definition: ada-exp.c:342
struct type * language_lookup_primitive_type(const struct language_defn *la, struct gdbarch *gdbarch, const char *name)
Definition: language.c:1025
#define HOST_CHAR_BIT
Definition: host-defs.h:40
#define ENTRY
Definition: d-exp.c:195
#define ASSIGN_MODIFY
Definition: d-exp.c:218
static const yytype_int16 yydefgoto[]
Definition: d-exp.c:712
struct stoken sval
Definition: ada-exp.c:293
static int parse_string_or_char(const char *tokptr, const char **outptr, struct typed_stoken *value, int *host_chars)
Definition: d-exp.c:2610
#define ERROR
Definition: d-exp.c:196
#define TYPE_DECLARED_CLASS(t)
Definition: gdbtypes.h:299
#define TYPEID_KEYWORD
Definition: d-exp.c:204
short int yytype_int16
Definition: d-exp.c:311
static const char * prev_lexptr
void write_exp_elt_floatcst(struct parser_state *ps, const gdb_byte expelt[16])
Definition: parse.c:265
static void yy_reduce_print(yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule)
Definition: d-exp.c:958
#define CAST_KEYWORD
Definition: d-exp.c:201
#define YYEOF
Definition: d-exp.c:832
void write_exp_string(struct parser_state *ps, struct stoken str)
Definition: parse.c:318
void write_exp_elt_type(struct parser_state *ps, struct type *expelt)
Definition: parse.c:277
void clear()
Definition: gdb_obstack.h:77
#define yystacksize
#define yytable_value_is_error(Yytable_value)
Definition: d-exp.c:652
void error(const char *fmt,...)
Definition: errors.c:38
#define TYPENAME
Definition: d-exp.c:188
#define ANDAND
Definition: d-exp.c:220
void write_exp_string_vector(struct parser_state *ps, int type, struct stoken_vector *vec)
Definition: parse.c:360
struct type * lookup_pointer_type(struct type *type)
Definition: gdbtypes.c:381
struct stoken stoken
Definition: parser-defs.h:120
long long LONGEST
Definition: common-types.h:52
static struct obstack tempbuf
Definition: d-exp.c:2599
static const yytype_uint8 yytable[]
Definition: d-exp.c:723
static const struct token ident_tokens[]
Definition: d-exp.c:2720
#define TYPE_SAFE_NAME(type)
Definition: gdbtypes.h:1483
int length
Definition: parser-defs.h:93
char * copy_name(struct stoken token)
Definition: parse.c:761
static struct parser_state * pstate
Definition: d-exp.c:93
#define LEQ
Definition: d-exp.c:223
#define DOTDOT
Definition: d-exp.c:232
#define VEC_ordered_remove(T, V, I)
Definition: vec.h:355
enum exp_opcode opcode
Definition: c-exp.c:4868
static void yydestruct(const char *yymsg, int yytype, YYSTYPE *yyvaluep)
Definition: d-exp.c:1238