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