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