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