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