No empty .Rs/.Re
[netbsd-mini2440.git] / gnu / dist / gdb6 / gdb / ada-exp.c
blobb659a1f987a81aff15aab06a7c5e5377fa846ed6
1 /* A Bison parser, made by GNU Bison 1.875c. */
3 /* Skeleton parser for Yacc-like parsing with Bison,
4 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
21 /* As a special exception, when this file is copied by Bison into a
22 Bison output file, you may use that output file without restriction.
23 This special exception was added by the Free Software Foundation
24 in version 1.24 of Bison. */
26 /* Written by Richard Stallman by simplifying the original so called
27 ``semantic'' parser. */
29 /* All symbols defined below should begin with yy or YY, to avoid
30 infringing on user name space. This should be done even for local
31 variables, as they might otherwise be expanded by user macros.
32 There are some unavoidable exceptions within include files to
33 define necessary library symbols; they are noted "INFRINGES ON
34 USER NAME SPACE" below. */
36 /* Identify Bison output. */
37 #define YYBISON 1
39 /* Skeleton name. */
40 #define YYSKELETON_NAME "yacc.c"
42 /* Pure parsers. */
43 #define YYPURE 0
45 /* Using locations. */
46 #define YYLSP_NEEDED 0
50 /* Tokens. */
51 #ifndef YYTOKENTYPE
52 # define YYTOKENTYPE
53 /* Put the tokens into the symbol table, so that GDB and other debuggers
54 know about them. */
55 enum yytokentype {
56 INT = 258,
57 NULL_PTR = 259,
58 CHARLIT = 260,
59 FLOAT = 261,
60 COLONCOLON = 262,
61 STRING = 263,
62 NAME = 264,
63 DOT_ID = 265,
64 DOT_ALL = 266,
65 SPECIAL_VARIABLE = 267,
66 ASSIGN = 268,
67 ELSE = 269,
68 THEN = 270,
69 XOR = 271,
70 OR = 272,
71 _AND_ = 273,
72 DOTDOT = 274,
73 IN = 275,
74 GEQ = 276,
75 LEQ = 277,
76 NOTEQUAL = 278,
77 UNARY = 279,
78 REM = 280,
79 MOD = 281,
80 NOT = 282,
81 ABS = 283,
82 STARSTAR = 284,
83 VAR = 285,
84 ARROW = 286,
85 TICK_LENGTH = 287,
86 TICK_LAST = 288,
87 TICK_FIRST = 289,
88 TICK_ADDRESS = 290,
89 TICK_ACCESS = 291,
90 TICK_MODULUS = 292,
91 TICK_MIN = 293,
92 TICK_MAX = 294,
93 TICK_VAL = 295,
94 TICK_TAG = 296,
95 TICK_SIZE = 297,
96 TICK_RANGE = 298,
97 TICK_POS = 299,
98 NEW = 300,
99 OTHERS = 301
101 #endif
102 #define INT 258
103 #define NULL_PTR 259
104 #define CHARLIT 260
105 #define FLOAT 261
106 #define COLONCOLON 262
107 #define STRING 263
108 #define NAME 264
109 #define DOT_ID 265
110 #define DOT_ALL 266
111 #define SPECIAL_VARIABLE 267
112 #define ASSIGN 268
113 #define ELSE 269
114 #define THEN 270
115 #define XOR 271
116 #define OR 272
117 #define _AND_ 273
118 #define DOTDOT 274
119 #define IN 275
120 #define GEQ 276
121 #define LEQ 277
122 #define NOTEQUAL 278
123 #define UNARY 279
124 #define REM 280
125 #define MOD 281
126 #define NOT 282
127 #define ABS 283
128 #define STARSTAR 284
129 #define VAR 285
130 #define ARROW 286
131 #define TICK_LENGTH 287
132 #define TICK_LAST 288
133 #define TICK_FIRST 289
134 #define TICK_ADDRESS 290
135 #define TICK_ACCESS 291
136 #define TICK_MODULUS 292
137 #define TICK_MIN 293
138 #define TICK_MAX 294
139 #define TICK_VAL 295
140 #define TICK_TAG 296
141 #define TICK_SIZE 297
142 #define TICK_RANGE 298
143 #define TICK_POS 299
144 #define NEW 300
145 #define OTHERS 301
150 /* Copy the first part of user declarations. */
151 #line 39 "ada-exp.y"
154 #include "defs.h"
155 #include "gdb_string.h"
156 #include <ctype.h>
157 #include "expression.h"
158 #include "value.h"
159 #include "parser-defs.h"
160 #include "language.h"
161 #include "ada-lang.h"
162 #include "bfd.h" /* Required by objfiles.h. */
163 #include "symfile.h" /* Required by objfiles.h. */
164 #include "objfiles.h" /* For have_full_symbols and have_partial_symbols */
165 #include "frame.h"
166 #include "block.h"
168 /* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc),
169 as well as gratuitiously global symbol names, so we can have multiple
170 yacc generated parsers in gdb. These are only the variables
171 produced by yacc. If other parser generators (bison, byacc, etc) produce
172 additional global names that conflict at link time, then those parser
173 generators need to be fixed instead of adding those names to this list. */
175 /* NOTE: This is clumsy, especially since BISON and FLEX provide --prefix
176 options. I presume we are maintaining it to accommodate systems
177 without BISON? (PNH) */
179 #define yymaxdepth ada_maxdepth
180 #define yyparse _ada_parse /* ada_parse calls this after initialization */
181 #define yylex ada_lex
182 #define yyerror ada_error
183 #define yylval ada_lval
184 #define yychar ada_char
185 #define yydebug ada_debug
186 #define yypact ada_pact
187 #define yyr1 ada_r1
188 #define yyr2 ada_r2
189 #define yydef ada_def
190 #define yychk ada_chk
191 #define yypgo ada_pgo
192 #define yyact ada_act
193 #define yyexca ada_exca
194 #define yyerrflag ada_errflag
195 #define yynerrs ada_nerrs
196 #define yyps ada_ps
197 #define yypv ada_pv
198 #define yys ada_s
199 #define yy_yys ada_yys
200 #define yystate ada_state
201 #define yytmp ada_tmp
202 #define yyv ada_v
203 #define yy_yyv ada_yyv
204 #define yyval ada_val
205 #define yylloc ada_lloc
206 #define yyreds ada_reds /* With YYDEBUG defined */
207 #define yytoks ada_toks /* With YYDEBUG defined */
208 #define yyname ada_name /* With YYDEBUG defined */
209 #define yyrule ada_rule /* With YYDEBUG defined */
211 #ifndef YYDEBUG
212 #define YYDEBUG 1 /* Default to yydebug support */
213 #endif
215 #define YYFPRINTF parser_fprintf
217 struct name_info {
218 struct symbol *sym;
219 struct minimal_symbol *msym;
220 struct block *block;
221 struct stoken stoken;
224 static struct stoken empty_stoken = { "", 0 };
226 /* If expression is in the context of TYPE'(...), then TYPE, else
227 * NULL. */
228 static struct type *type_qualifier;
230 int yyparse (void);
232 static int yylex (void);
234 void yyerror (char *);
236 static struct stoken string_to_operator (struct stoken);
238 static void write_int (LONGEST, struct type *);
240 static void write_object_renaming (struct block *, struct symbol *, int);
242 static struct type* write_var_or_type (struct block *, struct stoken);
244 static void write_name_assoc (struct stoken);
246 static void write_exp_op_with_string (enum exp_opcode, struct stoken);
248 static struct block *block_lookup (struct block *, char *);
250 static LONGEST convert_char_literal (struct type *, LONGEST);
252 static void write_ambiguous_var (struct block *, char *, int);
254 static struct type *type_int (void);
256 static struct type *type_long (void);
258 static struct type *type_long_long (void);
260 static struct type *type_float (void);
262 static struct type *type_double (void);
264 static struct type *type_long_double (void);
266 static struct type *type_char (void);
268 static struct type *type_system_address (void);
272 /* Enabling traces. */
273 #ifndef YYDEBUG
274 # define YYDEBUG 0
275 #endif
277 /* Enabling verbose error messages. */
278 #ifdef YYERROR_VERBOSE
279 # undef YYERROR_VERBOSE
280 # define YYERROR_VERBOSE 1
281 #else
282 # define YYERROR_VERBOSE 0
283 #endif
285 #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
286 #line 160 "ada-exp.y"
287 typedef union YYSTYPE {
288 LONGEST lval;
289 struct {
290 LONGEST val;
291 struct type *type;
292 } typed_val;
293 struct {
294 DOUBLEST dval;
295 struct type *type;
296 } typed_val_float;
297 struct type *tval;
298 struct stoken sval;
299 struct block *bval;
300 struct internalvar *ivar;
301 } YYSTYPE;
302 /* Line 191 of yacc.c. */
303 #line 304 "ada-exp.c.tmp"
304 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
305 # define YYSTYPE_IS_DECLARED 1
306 # define YYSTYPE_IS_TRIVIAL 1
307 #endif
311 /* Copy the second part of user declarations. */
314 /* Line 214 of yacc.c. */
315 #line 316 "ada-exp.c.tmp"
317 #if ! defined (yyoverflow) || YYERROR_VERBOSE
319 # ifndef YYFREE
320 # define YYFREE free
321 # endif
322 # ifndef YYMALLOC
323 # define YYMALLOC xmalloc
324 # endif
326 /* The parser invokes alloca or xmalloc; define the necessary symbols. */
328 # ifdef YYSTACK_USE_ALLOCA
329 # if YYSTACK_USE_ALLOCA
330 # define YYSTACK_ALLOC alloca
331 # endif
332 # else
333 # if defined (alloca) || defined (_ALLOCA_H)
334 # define YYSTACK_ALLOC alloca
335 # else
336 # ifdef __GNUC__
337 # define YYSTACK_ALLOC __builtin_alloca
338 # endif
339 # endif
340 # endif
342 # ifdef YYSTACK_ALLOC
343 /* Pacify GCC's `empty if-body' warning. */
344 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
345 # else
346 # if defined (__STDC__) || defined (__cplusplus)
347 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
348 # define YYSIZE_T size_t
349 # endif
350 # define YYSTACK_ALLOC YYMALLOC
351 # define YYSTACK_FREE YYFREE
352 # endif
353 #endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
356 #if (! defined (yyoverflow) \
357 && (! defined (__cplusplus) \
358 || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL)))
360 /* A type that is properly aligned for any stack member. */
361 union yyalloc
363 short yyss;
364 YYSTYPE yyvs;
367 /* The size of the maximum gap between one aligned stack and the next. */
368 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
370 /* The size of an array large to enough to hold all stacks, each with
371 N elements. */
372 # define YYSTACK_BYTES(N) \
373 ((N) * (sizeof (short) + sizeof (YYSTYPE)) \
374 + YYSTACK_GAP_MAXIMUM)
376 /* Copy COUNT objects from FROM to TO. The source and destination do
377 not overlap. */
378 # ifndef YYCOPY
379 # if defined (__GNUC__) && 1 < __GNUC__
380 # define YYCOPY(To, From, Count) \
381 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
382 # else
383 # define YYCOPY(To, From, Count) \
384 do \
386 register YYSIZE_T yyi; \
387 for (yyi = 0; yyi < (Count); yyi++) \
388 (To)[yyi] = (From)[yyi]; \
390 while (0)
391 # endif
392 # endif
394 /* Relocate STACK from its old location to the new one. The
395 local variables YYSIZE and YYSTACKSIZE give the old and new number of
396 elements in the stack, and YYPTR gives the new location of the
397 stack. Advance YYPTR to a properly aligned location for the next
398 stack. */
399 # define YYSTACK_RELOCATE(Stack) \
400 do \
402 YYSIZE_T yynewbytes; \
403 YYCOPY (&yyptr->Stack, Stack, yysize); \
404 Stack = &yyptr->Stack; \
405 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
406 yyptr += yynewbytes / sizeof (*yyptr); \
408 while (0)
410 #endif
412 #if defined (__STDC__) || defined (__cplusplus)
413 typedef signed char yysigned_char;
414 #else
415 typedef short yysigned_char;
416 #endif
418 /* YYFINAL -- State number of the termination state. */
419 #define YYFINAL 55
420 /* YYLAST -- Last index in YYTABLE. */
421 #define YYLAST 705
423 /* YYNTOKENS -- Number of terminals. */
424 #define YYNTOKENS 67
425 /* YYNNTS -- Number of nonterminals. */
426 #define YYNNTS 31
427 /* YYNRULES -- Number of rules. */
428 #define YYNRULES 120
429 /* YYNRULES -- Number of states. */
430 #define YYNSTATES 231
432 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
433 #define YYUNDEFTOK 2
434 #define YYMAXUTOK 301
436 #define YYTRANSLATE(YYX) \
437 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
439 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
440 static const unsigned char yytranslate[] =
442 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
443 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
444 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
445 2, 2, 2, 2, 2, 2, 2, 2, 30, 62,
446 56, 61, 32, 28, 63, 29, 55, 33, 2, 2,
447 2, 2, 2, 2, 2, 2, 2, 2, 2, 60,
448 20, 19, 21, 2, 27, 2, 2, 2, 2, 2,
449 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
450 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
451 2, 57, 2, 66, 2, 2, 2, 2, 2, 2,
452 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
453 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
454 2, 2, 2, 64, 40, 65, 2, 2, 2, 2,
455 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
456 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
457 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
458 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
459 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
460 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
461 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
462 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
463 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
464 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
465 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
466 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
467 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
468 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
469 15, 16, 17, 18, 22, 23, 24, 25, 26, 31,
470 34, 35, 36, 37, 38, 39, 41, 42, 43, 44,
471 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
472 58, 59
475 #if YYDEBUG
476 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
477 YYRHS. */
478 static const unsigned short yyprhs[] =
480 0, 0, 3, 5, 7, 11, 15, 18, 21, 26,
481 31, 32, 40, 41, 48, 55, 59, 61, 63, 65,
482 67, 70, 73, 76, 79, 80, 82, 86, 90, 96,
483 101, 105, 109, 113, 117, 121, 125, 129, 133, 137,
484 139, 143, 147, 151, 157, 163, 167, 174, 181, 186,
485 190, 194, 198, 200, 202, 204, 206, 208, 210, 214,
486 218, 223, 228, 232, 236, 241, 246, 250, 254, 257,
487 260, 264, 268, 272, 275, 278, 286, 294, 300, 306,
488 309, 310, 314, 316, 318, 319, 321, 323, 325, 327,
489 329, 332, 334, 337, 340, 344, 347, 351, 355, 357,
490 360, 363, 366, 370, 372, 374, 378, 382, 384, 385,
491 390, 394, 395, 402, 403, 408, 412, 413, 420, 423,
495 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
496 static const yysigned_char yyrhs[] =
498 68, 0, -1, 69, -1, 76, -1, 69, 60, 76,
499 -1, 70, 13, 76, -1, 70, 11, -1, 70, 10,
500 -1, 70, 56, 74, 61, -1, 85, 56, 74, 61,
501 -1, -1, 85, 62, 72, 71, 56, 76, 61, -1,
502 -1, 70, 56, 73, 22, 73, 61, -1, 85, 56,
503 73, 22, 73, 61, -1, 56, 69, 61, -1, 85,
504 -1, 12, -1, 87, -1, 70, -1, 29, 73, -1,
505 28, 73, -1, 36, 73, -1, 37, 73, -1, -1,
506 76, -1, 9, 41, 76, -1, 74, 63, 76, -1,
507 74, 63, 9, 41, 76, -1, 64, 85, 65, 73,
508 -1, 73, 38, 73, -1, 73, 32, 73, -1, 73,
509 33, 73, -1, 73, 34, 73, -1, 73, 35, 73,
510 -1, 73, 27, 73, -1, 73, 28, 73, -1, 73,
511 30, 73, -1, 73, 29, 73, -1, 73, -1, 73,
512 19, 73, -1, 73, 26, 73, -1, 73, 25, 73,
513 -1, 73, 23, 73, 22, 73, -1, 73, 23, 70,
514 53, 82, -1, 73, 23, 85, -1, 73, 36, 23,
515 73, 22, 73, -1, 73, 36, 23, 70, 53, 82,
516 -1, 73, 36, 23, 85, -1, 73, 24, 73, -1,
517 73, 20, 73, -1, 73, 21, 73, -1, 75, -1,
518 77, -1, 78, -1, 79, -1, 80, -1, 81, -1,
519 75, 18, 75, -1, 77, 18, 75, -1, 75, 18,
520 15, 75, -1, 78, 18, 15, 75, -1, 75, 17,
521 75, -1, 79, 17, 75, -1, 75, 17, 14, 75,
522 -1, 80, 17, 14, 75, -1, 75, 16, 75, -1,
523 81, 16, 75, -1, 70, 46, -1, 70, 45, -1,
524 70, 44, 82, -1, 70, 43, 82, -1, 70, 42,
525 82, -1, 70, 52, -1, 70, 51, -1, 84, 48,
526 56, 76, 63, 76, 61, -1, 84, 49, 56, 76,
527 63, 76, 61, -1, 84, 54, 56, 76, 61, -1,
528 83, 50, 56, 76, 61, -1, 83, 47, -1, -1,
529 56, 3, 61, -1, 85, -1, 83, -1, -1, 3,
530 -1, 5, -1, 6, -1, 4, -1, 8, -1, 58,
531 9, -1, 9, -1, 86, 9, -1, 9, 46, -1,
532 86, 9, 46, -1, 9, 7, -1, 86, 9, 7,
533 -1, 56, 88, 61, -1, 90, -1, 89, 76, -1,
534 89, 90, -1, 76, 63, -1, 89, 76, 63, -1,
535 91, -1, 92, -1, 92, 63, 90, -1, 59, 41,
536 76, -1, 93, -1, -1, 9, 41, 94, 76, -1,
537 73, 41, 76, -1, -1, 73, 22, 73, 41, 95,
538 76, -1, -1, 9, 40, 96, 93, -1, 73, 40,
539 93, -1, -1, 73, 22, 73, 40, 97, 93, -1,
540 32, 70, -1, 30, 70, -1, 70, 57, 76, 66,
544 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
545 static const unsigned short yyrline[] =
547 0, 224, 224, 228, 229, 231, 236, 240, 244, 250,
548 269, 269, 281, 285, 287, 295, 306, 316, 320, 323,
549 326, 330, 334, 338, 342, 345, 347, 349, 351, 355,
550 368, 372, 376, 380, 384, 388, 392, 396, 400, 404,
551 407, 411, 415, 419, 421, 426, 434, 438, 444, 455,
552 459, 463, 467, 468, 469, 470, 471, 472, 476, 478,
553 483, 485, 490, 492, 497, 499, 503, 505, 517, 519,
554 525, 528, 531, 534, 536, 538, 540, 542, 544, 546,
555 550, 552, 557, 567, 569, 575, 579, 586, 594, 598,
556 604, 608, 610, 612, 620, 631, 633, 638, 647, 648,
557 654, 659, 665, 674, 675, 676, 680, 685, 700, 699,
558 702, 705, 704, 710, 709, 712, 715, 714, 722, 724,
561 #endif
563 #if YYDEBUG || YYERROR_VERBOSE
564 /* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
565 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
566 static const char *const yytname[] =
568 "$end", "error", "$undefined", "INT", "NULL_PTR", "CHARLIT", "FLOAT",
569 "COLONCOLON", "STRING", "NAME", "DOT_ID", "DOT_ALL", "SPECIAL_VARIABLE",
570 "ASSIGN", "ELSE", "THEN", "XOR", "OR", "_AND_", "'='", "'<'", "'>'",
571 "DOTDOT", "IN", "GEQ", "LEQ", "NOTEQUAL", "'@'", "'+'", "'-'", "'&'",
572 "UNARY", "'*'", "'/'", "REM", "MOD", "NOT", "ABS", "STARSTAR", "VAR",
573 "'|'", "ARROW", "TICK_LENGTH", "TICK_LAST", "TICK_FIRST", "TICK_ADDRESS",
574 "TICK_ACCESS", "TICK_MODULUS", "TICK_MIN", "TICK_MAX", "TICK_VAL",
575 "TICK_TAG", "TICK_SIZE", "TICK_RANGE", "TICK_POS", "'.'", "'('", "'['",
576 "NEW", "OTHERS", "';'", "')'", "'''", "','", "'{'", "'}'", "']'",
577 "$accept", "start", "exp1", "primary", "@1", "save_qualifier",
578 "simple_exp", "arglist", "relation", "exp", "and_exp", "and_then_exp",
579 "or_exp", "or_else_exp", "xor_exp", "tick_arglist", "type_prefix",
580 "opt_type_prefix", "var_or_type", "block", "aggregate",
581 "aggregate_component_list", "positional_list", "component_groups",
582 "others", "component_group", "component_associations", "@2", "@3", "@4",
583 "@5", 0
585 #endif
587 # ifdef YYPRINT
588 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
589 token YYLEX-NUM. */
590 static const unsigned short yytoknum[] =
592 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
593 265, 266, 267, 268, 269, 270, 271, 272, 273, 61,
594 60, 62, 274, 275, 276, 277, 278, 64, 43, 45,
595 38, 279, 42, 47, 280, 281, 282, 283, 284, 285,
596 124, 286, 287, 288, 289, 290, 291, 292, 293, 294,
597 295, 296, 297, 298, 299, 46, 40, 91, 300, 301,
598 59, 41, 39, 44, 123, 125, 93
600 # endif
602 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
603 static const unsigned char yyr1[] =
605 0, 67, 68, 69, 69, 69, 70, 70, 70, 70,
606 71, 70, 72, 70, 70, 70, 70, 70, 70, 73,
607 73, 73, 73, 73, 74, 74, 74, 74, 74, 73,
608 73, 73, 73, 73, 73, 73, 73, 73, 73, 75,
609 75, 75, 75, 75, 75, 75, 75, 75, 75, 75,
610 75, 75, 76, 76, 76, 76, 76, 76, 77, 77,
611 78, 78, 79, 79, 80, 80, 81, 81, 70, 70,
612 70, 70, 70, 70, 70, 70, 70, 70, 70, 70,
613 82, 82, 83, 84, 84, 70, 70, 70, 70, 70,
614 70, 85, 85, 85, 85, 86, 86, 87, 88, 88,
615 88, 89, 89, 90, 90, 90, 91, 92, 94, 93,
616 93, 95, 93, 96, 93, 93, 97, 93, 70, 70,
620 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
621 static const unsigned char yyr2[] =
623 0, 2, 1, 1, 3, 3, 2, 2, 4, 4,
624 0, 7, 0, 6, 6, 3, 1, 1, 1, 1,
625 2, 2, 2, 2, 0, 1, 3, 3, 5, 4,
626 3, 3, 3, 3, 3, 3, 3, 3, 3, 1,
627 3, 3, 3, 5, 5, 3, 6, 6, 4, 3,
628 3, 3, 1, 1, 1, 1, 1, 1, 3, 3,
629 4, 4, 3, 3, 4, 4, 3, 3, 2, 2,
630 3, 3, 3, 2, 2, 7, 7, 5, 5, 2,
631 0, 3, 1, 1, 0, 1, 1, 1, 1, 1,
632 2, 1, 2, 2, 3, 2, 3, 3, 1, 2,
633 2, 2, 3, 1, 1, 3, 3, 1, 0, 4,
634 3, 0, 6, 0, 4, 3, 0, 6, 2, 2,
638 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
639 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
640 means the default is an error. */
641 static const unsigned char yydefact[] =
643 84, 85, 88, 86, 87, 89, 91, 17, 84, 84,
644 84, 84, 84, 84, 84, 0, 0, 0, 2, 19,
645 39, 52, 3, 53, 54, 55, 56, 57, 83, 0,
646 16, 0, 18, 95, 93, 19, 21, 20, 119, 118,
647 22, 23, 91, 0, 0, 39, 3, 0, 84, 98,
648 103, 104, 107, 90, 0, 1, 84, 7, 6, 84,
649 80, 80, 80, 69, 68, 74, 73, 84, 84, 84,
650 84, 84, 84, 84, 84, 84, 84, 84, 84, 84,
651 84, 84, 84, 84, 0, 84, 84, 84, 84, 84,
652 0, 84, 0, 84, 79, 0, 0, 0, 0, 84,
653 12, 92, 113, 108, 84, 15, 84, 84, 84, 101,
654 97, 99, 100, 84, 84, 4, 5, 0, 72, 71,
655 70, 91, 39, 0, 25, 0, 40, 50, 51, 19,
656 0, 16, 49, 42, 41, 35, 36, 38, 37, 31,
657 32, 33, 34, 84, 30, 66, 84, 62, 84, 58,
658 59, 84, 63, 84, 67, 84, 84, 84, 84, 39,
659 0, 10, 96, 94, 84, 84, 106, 0, 0, 115,
660 110, 102, 105, 29, 0, 84, 84, 8, 84, 120,
661 80, 84, 19, 0, 16, 64, 60, 61, 65, 0,
662 0, 0, 0, 84, 9, 0, 114, 109, 116, 111,
663 81, 26, 0, 91, 27, 44, 43, 80, 84, 78,
664 84, 84, 77, 0, 84, 84, 84, 13, 84, 47,
665 46, 0, 0, 14, 0, 117, 112, 28, 75, 76,
669 /* YYDEFGOTO[NTERM-NUM]. */
670 static const short yydefgoto[] =
672 -1, 17, 18, 35, 195, 161, 20, 123, 21, 124,
673 23, 24, 25, 26, 27, 118, 28, 29, 30, 31,
674 32, 47, 48, 49, 50, 51, 52, 165, 216, 164,
678 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
679 STATE-NUM. */
680 #define YYPACT_NINF -104
681 static const short yypact[] =
683 396, -104, -104, -104, -104, -104, 16, -104, 396, 396,
684 121, 121, 396, 396, 282, 2, 6, 9, -28, 150,
685 629, 89, -104, 20, 24, 33, 41, 35, 43, 18,
686 275, 55, -104, -104, -104, 513, -7, -7, -3, -3,
687 -7, -7, 3, 28, -14, 566, 25, 31, 282, -104,
688 -104, 37, -104, -104, 44, -104, 396, -104, -104, 396,
689 42, 42, 42, -104, -104, -104, -104, 272, 396, 396,
690 396, 396, 396, 396, 396, 396, 396, 396, 396, 396,
691 396, 396, 396, 396, 79, 396, 396, 339, 351, 396,
692 50, 396, 99, 396, -104, 58, 59, 60, 63, 272,
693 -104, 17, -104, -104, 396, -104, 396, 408, 396, -104,
694 -104, 57, -104, 282, 396, -104, -104, 119, -104, -104,
695 -104, -1, 589, -41, -104, 65, 656, 656, 656, 476,
696 215, 173, 656, 656, 656, 667, -7, -7, -7, 85,
697 85, 85, 85, 396, 85, -104, 396, -104, 396, -104,
698 -104, 396, -104, 396, -104, 396, 396, 396, 396, 609,
699 34, -104, -104, -104, 408, 396, -104, 641, 466, -104,
700 -104, -104, -104, -104, 71, 396, 396, -104, 453, -104,
701 42, 396, 492, 441, 208, -104, -104, -104, -104, 73,
702 76, 81, 84, 396, -104, 93, -104, -104, -104, -104,
703 -104, -104, 108, 14, -104, -104, 656, 42, 396, -104,
704 396, 396, -104, 544, 396, 408, 396, -104, 396, -104,
705 656, 91, 98, -104, 103, -104, -104, -104, -104, -104,
706 -104
709 /* YYPGOTO[NTERM-NUM]. */
710 static const short yypgoto[] =
712 -104, -104, 136, 19, -104, -104, 4, 67, -52, 0,
713 -104, -104, -104, -104, -104, -59, -104, -104, -15, -104,
714 -104, -104, -104, -43, -104, -104, -103, -104, -104, -104,
715 -104
718 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
719 positive, shift that token. If negative, reduce the rule which
720 number is the opposite. If zero, do what YYDEFACT says.
721 If YYTABLE_NINF, syntax error. */
722 #define YYTABLE_NINF -83
723 static const short yytable[] =
725 22, 54, 119, 120, 169, 112, 33, 57, 58, 55,
726 33, 53, 36, 37, 46, 6, 40, 41, 45, 19,
727 177, 33, 178, 33, 162, 80, 81, 82, 83, 38,
728 39, 85, 56, 19, 145, 147, 149, 150, 89, 152,
729 175, 154, 90, 102, 103, 34, 56, 105, 111, 34,
730 91, 93, 45, 67, 68, 218, 115, 131, 92, 116,
731 34, 196, 34, 163, 101, 151, 96, 97, 125, 104,
732 172, 122, 98, 126, 127, 128, 130, 132, 133, 134,
733 135, 136, 137, 138, 139, 140, 141, 142, 109, 144,
734 94, 129, 110, 95, 185, 194, 186, 178, 117, 187,
735 113, 188, 143, 159, 166, 86, 87, 88, 170, 114,
736 167, 168, 225, 153, 155, 156, 157, 168, 173, 158,
737 171, 205, 174, 85, 1, 2, 3, 4, 184, 5,
738 6, 179, 200, 7, 209, 76, 77, 78, 79, 210,
739 80, 81, 82, 83, 211, 212, 85, 183, 219, 214,
740 44, 10, 228, 11, 0, 189, 190, 191, 192, 229,
741 57, 58, 182, 59, 230, 197, 160, 0, 168, 217,
742 0, 0, 0, -45, 0, 201, 0, 14, 204, 15,
743 202, 0, 0, 0, 0, 206, 0, 0, 0, -45,
744 -45, -45, 60, 61, 62, 63, 64, 213, 0, 0,
745 0, 65, 66, 0, 0, 0, 67, 68, -48, 0,
746 221, 222, 220, 0, 224, 0, 226, 0, 227, 168,
747 -82, -82, -82, -82, -48, -48, -48, -82, 0, 99,
748 0, 0, 0, -45, -45, 100, -45, 181, 0, -45,
749 0, 0, 76, 77, 78, 79, 0, 80, 81, 82,
750 83, 0, 0, 85, 0, -82, -82, -82, -82, 0,
751 0, 0, -82, 0, 99, 0, 0, 0, -48, -48,
752 100, -48, 0, 0, -48, 1, 2, 3, 4, 0,
753 5, 121, 0, 0, 7, 1, 2, 3, 4, 0,
754 5, 42, 0, 0, 7, 0, 0, 0, 0, 0,
755 8, 9, 10, 0, 11, 0, 0, 0, 12, 13,
756 8, 9, 10, 0, 11, 0, 0, 0, 12, 13,
757 0, 0, -82, -82, -82, -82, 0, 0, 14, -82,
758 15, 99, 0, -24, 0, -24, 16, 100, 14, 0,
759 15, 43, 1, 2, 3, 4, 16, 5, 6, 0,
760 0, 7, 0, 146, 1, 2, 3, 4, 0, 5,
761 6, 0, 0, 7, 0, 0, 148, 8, 9, 10,
762 0, 11, 0, 0, 0, 12, 13, 0, 0, 8,
763 9, 10, 0, 11, 0, 0, 0, 12, 13, 0,
764 0, 0, 0, 0, 0, 14, 0, 15, 0, 1,
765 2, 3, 4, 16, 5, 6, 0, 14, 7, 15,
766 0, 1, 2, 3, 4, 16, 5, 42, 0, 0,
767 7, 0, 0, 0, 8, 9, 10, 0, 11, 0,
768 0, 0, 12, 13, 0, 0, 8, 9, 10, 0,
769 11, 0, 0, 0, 12, 13, 0, 0, 0, 0,
770 0, 0, 14, 0, 15, 0, 1, 2, 3, 4,
771 16, 5, 203, 208, 14, 7, 15, 0, 76, 77,
772 78, 79, 16, 80, 81, 82, 83, 0, 0, 85,
773 0, 8, 9, 10, 0, 11, 57, 58, 106, 12,
774 13, 0, 0, 76, 77, 78, 79, 0, 80, 81,
775 82, 83, 57, 58, 85, 0, 107, 108, 0, 14,
776 0, 15, 0, 0, 0, 0, 0, 16, 60, 61,
777 62, 63, 64, 57, 58, 0, 0, 65, 66, 180,
778 0, 0, 67, 68, 60, 61, 62, 63, 64, 0,
779 0, 0, 0, 65, 66, 207, 0, 0, 67, 68,
780 0, 0, 0, 0, 0, 60, 61, 62, 63, 64,
781 0, 0, 0, 0, 65, 66, 0, 0, 0, 67,
782 68, 76, 77, 78, 79, 0, 80, 81, 82, 83,
783 0, 0, 85, 0, 0, 69, 70, 71, 106, 72,
784 73, 74, 75, 76, 77, 78, 79, 0, 80, 81,
785 82, 83, 84, 0, 85, 223, 107, 108, 69, 70,
786 71, 176, 72, 73, 74, 75, 76, 77, 78, 79,
787 0, 80, 81, 82, 83, 84, 0, 85, 69, 70,
788 71, 193, 72, 73, 74, 75, 76, 77, 78, 79,
789 0, 80, 81, 82, 83, 84, 0, 85, 69, 70,
790 71, 0, 72, 73, 74, 75, 76, 77, 78, 79,
791 0, 80, 81, 82, 83, 84, 0, 85, 76, 77,
792 78, 79, 0, 80, 81, 82, 83, 0, 0, 85,
793 0, 198, 199, 76, 77, 78, 79, 0, 80, 81,
794 82, 83, 0, 0, 85, 77, 78, 79, 0, 80,
795 81, 82, 83, 0, 0, 85
798 static const short yycheck[] =
800 0, 16, 61, 62, 107, 48, 7, 10, 11, 0,
801 7, 9, 8, 9, 14, 9, 12, 13, 14, 0,
802 61, 7, 63, 7, 7, 32, 33, 34, 35, 10,
803 11, 38, 60, 14, 86, 87, 88, 89, 18, 91,
804 41, 93, 18, 40, 41, 46, 60, 61, 48, 46,
805 17, 16, 48, 56, 57, 41, 56, 72, 17, 59,
806 46, 164, 46, 46, 9, 15, 48, 49, 68, 41,
807 113, 67, 54, 69, 70, 71, 72, 73, 74, 75,
808 76, 77, 78, 79, 80, 81, 82, 83, 63, 85,
809 47, 72, 61, 50, 146, 61, 148, 63, 56, 151,
810 63, 153, 23, 99, 104, 16, 17, 18, 108, 65,
811 106, 107, 215, 14, 56, 56, 56, 113, 114, 56,
812 63, 180, 3, 38, 3, 4, 5, 6, 143, 8,
813 9, 66, 61, 12, 61, 27, 28, 29, 30, 63,
814 32, 33, 34, 35, 63, 61, 38, 143, 207, 56,
815 14, 30, 61, 32, -1, 155, 156, 157, 158, 61,
816 10, 11, 143, 13, 61, 165, 99, -1, 164, 61,
817 -1, -1, -1, 0, -1, 175, -1, 56, 178, 58,
818 176, -1, -1, -1, -1, 181, -1, -1, -1, 16,
819 17, 18, 42, 43, 44, 45, 46, 193, -1, -1,
820 -1, 51, 52, -1, -1, -1, 56, 57, 0, -1,
821 210, 211, 208, -1, 214, -1, 216, -1, 218, 215,
822 47, 48, 49, 50, 16, 17, 18, 54, -1, 56,
823 -1, -1, -1, 60, 61, 62, 63, 22, -1, 66,
824 -1, -1, 27, 28, 29, 30, -1, 32, 33, 34,
825 35, -1, -1, 38, -1, 47, 48, 49, 50, -1,
826 -1, -1, 54, -1, 56, -1, -1, -1, 60, 61,
827 62, 63, -1, -1, 66, 3, 4, 5, 6, -1,
828 8, 9, -1, -1, 12, 3, 4, 5, 6, -1,
829 8, 9, -1, -1, 12, -1, -1, -1, -1, -1,
830 28, 29, 30, -1, 32, -1, -1, -1, 36, 37,
831 28, 29, 30, -1, 32, -1, -1, -1, 36, 37,
832 -1, -1, 47, 48, 49, 50, -1, -1, 56, 54,
833 58, 56, -1, 61, -1, 63, 64, 62, 56, -1,
834 58, 59, 3, 4, 5, 6, 64, 8, 9, -1,
835 -1, 12, -1, 14, 3, 4, 5, 6, -1, 8,
836 9, -1, -1, 12, -1, -1, 15, 28, 29, 30,
837 -1, 32, -1, -1, -1, 36, 37, -1, -1, 28,
838 29, 30, -1, 32, -1, -1, -1, 36, 37, -1,
839 -1, -1, -1, -1, -1, 56, -1, 58, -1, 3,
840 4, 5, 6, 64, 8, 9, -1, 56, 12, 58,
841 -1, 3, 4, 5, 6, 64, 8, 9, -1, -1,
842 12, -1, -1, -1, 28, 29, 30, -1, 32, -1,
843 -1, -1, 36, 37, -1, -1, 28, 29, 30, -1,
844 32, -1, -1, -1, 36, 37, -1, -1, -1, -1,
845 -1, -1, 56, -1, 58, -1, 3, 4, 5, 6,
846 64, 8, 9, 22, 56, 12, 58, -1, 27, 28,
847 29, 30, 64, 32, 33, 34, 35, -1, -1, 38,
848 -1, 28, 29, 30, -1, 32, 10, 11, 22, 36,
849 37, -1, -1, 27, 28, 29, 30, -1, 32, 33,
850 34, 35, 10, 11, 38, -1, 40, 41, -1, 56,
851 -1, 58, -1, -1, -1, -1, -1, 64, 42, 43,
852 44, 45, 46, 10, 11, -1, -1, 51, 52, 53,
853 -1, -1, 56, 57, 42, 43, 44, 45, 46, -1,
854 -1, -1, -1, 51, 52, 53, -1, -1, 56, 57,
855 -1, -1, -1, -1, -1, 42, 43, 44, 45, 46,
856 -1, -1, -1, -1, 51, 52, -1, -1, -1, 56,
857 57, 27, 28, 29, 30, -1, 32, 33, 34, 35,
858 -1, -1, 38, -1, -1, 19, 20, 21, 22, 23,
859 24, 25, 26, 27, 28, 29, 30, -1, 32, 33,
860 34, 35, 36, -1, 38, 61, 40, 41, 19, 20,
861 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
862 -1, 32, 33, 34, 35, 36, -1, 38, 19, 20,
863 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
864 -1, 32, 33, 34, 35, 36, -1, 38, 19, 20,
865 21, -1, 23, 24, 25, 26, 27, 28, 29, 30,
866 -1, 32, 33, 34, 35, 36, -1, 38, 27, 28,
867 29, 30, -1, 32, 33, 34, 35, -1, -1, 38,
868 -1, 40, 41, 27, 28, 29, 30, -1, 32, 33,
869 34, 35, -1, -1, 38, 28, 29, 30, -1, 32,
870 33, 34, 35, -1, -1, 38
873 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
874 symbol of state STATE-NUM. */
875 static const unsigned char yystos[] =
877 0, 3, 4, 5, 6, 8, 9, 12, 28, 29,
878 30, 32, 36, 37, 56, 58, 64, 68, 69, 70,
879 73, 75, 76, 77, 78, 79, 80, 81, 83, 84,
880 85, 86, 87, 7, 46, 70, 73, 73, 70, 70,
881 73, 73, 9, 59, 69, 73, 76, 88, 89, 90,
882 91, 92, 93, 9, 85, 0, 60, 10, 11, 13,
883 42, 43, 44, 45, 46, 51, 52, 56, 57, 19,
884 20, 21, 23, 24, 25, 26, 27, 28, 29, 30,
885 32, 33, 34, 35, 36, 38, 16, 17, 18, 18,
886 18, 17, 17, 16, 47, 50, 48, 49, 54, 56,
887 62, 9, 40, 41, 41, 61, 22, 40, 41, 63,
888 61, 76, 90, 63, 65, 76, 76, 56, 82, 82,
889 82, 9, 73, 74, 76, 76, 73, 73, 73, 70,
890 73, 85, 73, 73, 73, 73, 73, 73, 73, 73,
891 73, 73, 73, 23, 73, 75, 14, 75, 15, 75,
892 75, 15, 75, 14, 75, 56, 56, 56, 56, 73,
893 74, 72, 7, 46, 96, 94, 76, 73, 73, 93,
894 76, 63, 90, 73, 3, 41, 22, 61, 63, 66,
895 53, 22, 70, 73, 85, 75, 75, 75, 75, 76,
896 76, 76, 76, 22, 61, 71, 93, 76, 40, 41,
897 61, 76, 73, 9, 76, 82, 73, 53, 22, 61,
898 63, 63, 61, 73, 56, 97, 95, 61, 41, 82,
899 73, 76, 76, 61, 76, 93, 76, 76, 61, 61,
903 #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
904 # define YYSIZE_T __SIZE_TYPE__
905 #endif
906 #if ! defined (YYSIZE_T) && defined (size_t)
907 # define YYSIZE_T size_t
908 #endif
909 #if ! defined (YYSIZE_T)
910 # if defined (__STDC__) || defined (__cplusplus)
911 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
912 # define YYSIZE_T size_t
913 # endif
914 #endif
915 #if ! defined (YYSIZE_T)
916 # define YYSIZE_T unsigned int
917 #endif
919 #define yyerrok (yyerrstatus = 0)
920 #define yyclearin (yychar = YYEMPTY)
921 #define YYEMPTY (-2)
922 #define YYEOF 0
924 #define YYACCEPT goto yyacceptlab
925 #define YYABORT goto yyabortlab
926 #define YYERROR goto yyerrorlab
929 /* Like YYERROR except do call yyerror. This remains here temporarily
930 to ease the transition to the new meaning of YYERROR, for GCC.
931 Once GCC version 2 has supplanted version 1, this can go. */
933 #define YYFAIL goto yyerrlab
935 #define YYRECOVERING() (!!yyerrstatus)
937 #define YYBACKUP(Token, Value) \
938 do \
939 if (yychar == YYEMPTY && yylen == 1) \
941 yychar = (Token); \
942 yylval = (Value); \
943 yytoken = YYTRANSLATE (yychar); \
944 YYPOPSTACK; \
945 goto yybackup; \
947 else \
949 yyerror ("syntax error: cannot back up");\
950 YYERROR; \
952 while (0)
954 #define YYTERROR 1
955 #define YYERRCODE 256
957 /* YYLLOC_DEFAULT -- Compute the default location (before the actions
958 are run). */
960 #ifndef YYLLOC_DEFAULT
961 # define YYLLOC_DEFAULT(Current, Rhs, N) \
962 ((Current).first_line = (Rhs)[1].first_line, \
963 (Current).first_column = (Rhs)[1].first_column, \
964 (Current).last_line = (Rhs)[N].last_line, \
965 (Current).last_column = (Rhs)[N].last_column)
966 #endif
968 /* YYLEX -- calling `yylex' with the right arguments. */
970 #ifdef YYLEX_PARAM
971 # define YYLEX yylex (YYLEX_PARAM)
972 #else
973 # define YYLEX yylex ()
974 #endif
976 /* Enable debugging if requested. */
977 #if YYDEBUG
979 # ifndef YYFPRINTF
980 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
981 # define YYFPRINTF fprintf
982 # endif
984 # define YYDPRINTF(Args) \
985 do { \
986 if (yydebug) \
987 YYFPRINTF Args; \
988 } while (0)
990 # define YYDSYMPRINT(Args) \
991 do { \
992 if (yydebug) \
993 yysymprint Args; \
994 } while (0)
996 # define YYDSYMPRINTF(Title, Token, Value, Location) \
997 do { \
998 if (yydebug) \
1000 YYFPRINTF (stderr, "%s ", Title); \
1001 yysymprint (stderr, \
1002 Token, Value); \
1003 YYFPRINTF (stderr, "\n"); \
1005 } while (0)
1007 /*------------------------------------------------------------------.
1008 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
1009 | TOP (included). |
1010 `------------------------------------------------------------------*/
1012 #if defined (__STDC__) || defined (__cplusplus)
1013 static void
1014 yy_stack_print (short *bottom, short *top)
1015 #else
1016 static void
1017 yy_stack_print (bottom, top)
1018 short *bottom;
1019 short *top;
1020 #endif
1022 YYFPRINTF (stderr, "Stack now");
1023 for (/* Nothing. */; bottom <= top; ++bottom)
1024 YYFPRINTF (stderr, " %d", *bottom);
1025 YYFPRINTF (stderr, "\n");
1028 # define YY_STACK_PRINT(Bottom, Top) \
1029 do { \
1030 if (yydebug) \
1031 yy_stack_print ((Bottom), (Top)); \
1032 } while (0)
1035 /*------------------------------------------------.
1036 | Report that the YYRULE is going to be reduced. |
1037 `------------------------------------------------*/
1039 #if defined (__STDC__) || defined (__cplusplus)
1040 static void
1041 yy_reduce_print (int yyrule)
1042 #else
1043 static void
1044 yy_reduce_print (yyrule)
1045 int yyrule;
1046 #endif
1048 int yyi;
1049 unsigned int yylno = yyrline[yyrule];
1050 YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ",
1051 yyrule - 1, yylno);
1052 /* Print the symbols being reduced, and their result. */
1053 for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
1054 YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]);
1055 YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]);
1058 # define YY_REDUCE_PRINT(Rule) \
1059 do { \
1060 if (yydebug) \
1061 yy_reduce_print (Rule); \
1062 } while (0)
1064 /* Nonzero means print parse trace. It is left uninitialized so that
1065 multiple parsers can coexist. */
1066 int yydebug;
1067 #else /* !YYDEBUG */
1068 # define YYDPRINTF(Args)
1069 # define YYDSYMPRINT(Args)
1070 # define YYDSYMPRINTF(Title, Token, Value, Location)
1071 # define YY_STACK_PRINT(Bottom, Top)
1072 # define YY_REDUCE_PRINT(Rule)
1073 #endif /* !YYDEBUG */
1076 /* YYINITDEPTH -- initial size of the parser's stacks. */
1077 #ifndef YYINITDEPTH
1078 # define YYINITDEPTH 200
1079 #endif
1081 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
1082 if the built-in stack extension method is used).
1084 Do not make this value too large; the results are undefined if
1085 SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
1086 evaluated with infinite-precision integer arithmetic. */
1088 #if defined (YYMAXDEPTH) && YYMAXDEPTH == 0
1089 # undef YYMAXDEPTH
1090 #endif
1092 #ifndef YYMAXDEPTH
1093 # define YYMAXDEPTH 10000
1094 #endif
1098 #if YYERROR_VERBOSE
1100 # ifndef yystrlen
1101 # if defined (__GLIBC__) && defined (_STRING_H)
1102 # define yystrlen strlen
1103 # else
1104 /* Return the length of YYSTR. */
1105 static YYSIZE_T
1106 # if defined (__STDC__) || defined (__cplusplus)
1107 yystrlen (const char *yystr)
1108 # else
1109 yystrlen (yystr)
1110 const char *yystr;
1111 # endif
1113 register const char *yys = yystr;
1115 while (*yys++ != '\0')
1116 continue;
1118 return yys - yystr - 1;
1120 # endif
1121 # endif
1123 # ifndef yystpcpy
1124 # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
1125 # define yystpcpy stpcpy
1126 # else
1127 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
1128 YYDEST. */
1129 static char *
1130 # if defined (__STDC__) || defined (__cplusplus)
1131 yystpcpy (char *yydest, const char *yysrc)
1132 # else
1133 yystpcpy (yydest, yysrc)
1134 char *yydest;
1135 const char *yysrc;
1136 # endif
1138 register char *yyd = yydest;
1139 register const char *yys = yysrc;
1141 while ((*yyd++ = *yys++) != '\0')
1142 continue;
1144 return yyd - 1;
1146 # endif
1147 # endif
1149 #endif /* !YYERROR_VERBOSE */
1153 #if YYDEBUG
1154 /*--------------------------------.
1155 | Print this symbol on YYOUTPUT. |
1156 `--------------------------------*/
1158 #if defined (__STDC__) || defined (__cplusplus)
1159 static void
1160 yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep)
1161 #else
1162 static void
1163 yysymprint (yyoutput, yytype, yyvaluep)
1164 FILE *yyoutput;
1165 int yytype;
1166 YYSTYPE *yyvaluep;
1167 #endif
1169 /* Pacify ``unused variable'' warnings. */
1170 (void) yyvaluep;
1172 if (yytype < YYNTOKENS)
1174 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
1175 # ifdef YYPRINT
1176 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
1177 # endif
1179 else
1180 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
1182 switch (yytype)
1184 default:
1185 break;
1187 YYFPRINTF (yyoutput, ")");
1190 #endif /* ! YYDEBUG */
1191 /*-----------------------------------------------.
1192 | Release the memory associated to this symbol. |
1193 `-----------------------------------------------*/
1195 #if defined (__STDC__) || defined (__cplusplus)
1196 static void
1197 yydestruct (int yytype, YYSTYPE *yyvaluep)
1198 #else
1199 static void
1200 yydestruct (yytype, yyvaluep)
1201 int yytype;
1202 YYSTYPE *yyvaluep;
1203 #endif
1205 /* Pacify ``unused variable'' warnings. */
1206 (void) yyvaluep;
1208 switch (yytype)
1211 default:
1212 break;
1217 /* Prevent warnings from -Wmissing-prototypes. */
1219 #ifdef YYPARSE_PARAM
1220 # if defined (__STDC__) || defined (__cplusplus)
1221 int yyparse (void *YYPARSE_PARAM);
1222 # else
1223 int yyparse ();
1224 # endif
1225 #else /* ! YYPARSE_PARAM */
1226 #if defined (__STDC__) || defined (__cplusplus)
1227 int yyparse (void);
1228 #else
1229 int yyparse ();
1230 #endif
1231 #endif /* ! YYPARSE_PARAM */
1235 /* The lookahead symbol. */
1236 int yychar;
1238 /* The semantic value of the lookahead symbol. */
1239 YYSTYPE yylval;
1241 /* Number of syntax errors so far. */
1242 int yynerrs;
1246 /*----------.
1247 | yyparse. |
1248 `----------*/
1250 #ifdef YYPARSE_PARAM
1251 # if defined (__STDC__) || defined (__cplusplus)
1252 int yyparse (void *YYPARSE_PARAM)
1253 # else
1254 int yyparse (YYPARSE_PARAM)
1255 void *YYPARSE_PARAM;
1256 # endif
1257 #else /* ! YYPARSE_PARAM */
1258 #if defined (__STDC__) || defined (__cplusplus)
1260 yyparse (void)
1261 #else
1263 yyparse ()
1265 #endif
1266 #endif
1269 register int yystate;
1270 register int yyn;
1271 int yyresult;
1272 /* Number of tokens to shift before error messages enabled. */
1273 int yyerrstatus;
1274 /* Lookahead token as an internal (translated) token number. */
1275 int yytoken = 0;
1277 /* Three stacks and their tools:
1278 `yyss': related to states,
1279 `yyvs': related to semantic values,
1280 `yyls': related to locations.
1282 Refer to the stacks thru separate pointers, to allow yyoverflow
1283 to xreallocate them elsewhere. */
1285 /* The state stack. */
1286 short yyssa[YYINITDEPTH];
1287 short *yyss = yyssa;
1288 register short *yyssp;
1290 /* The semantic value stack. */
1291 YYSTYPE yyvsa[YYINITDEPTH];
1292 YYSTYPE *yyvs = yyvsa;
1293 register YYSTYPE *yyvsp;
1297 #define YYPOPSTACK (yyvsp--, yyssp--)
1299 YYSIZE_T yystacksize = YYINITDEPTH;
1301 /* The variables used to return semantic value and location from the
1302 action routines. */
1303 YYSTYPE yyval;
1306 /* When reducing, the number of symbols on the RHS of the reduced
1307 rule. */
1308 int yylen;
1310 YYDPRINTF ((stderr, "Starting parse\n"));
1312 yystate = 0;
1313 yyerrstatus = 0;
1314 yynerrs = 0;
1315 yychar = YYEMPTY; /* Cause a token to be read. */
1317 /* Initialize stack pointers.
1318 Waste one element of value and location stack
1319 so that they stay on the same level as the state stack.
1320 The wasted elements are never initialized. */
1322 yyssp = yyss;
1323 yyvsp = yyvs;
1325 goto yysetstate;
1327 /*------------------------------------------------------------.
1328 | yynewstate -- Push a new state, which is found in yystate. |
1329 `------------------------------------------------------------*/
1330 yynewstate:
1331 /* In all cases, when you get here, the value and location stacks
1332 have just been pushed. so pushing a state here evens the stacks.
1334 yyssp++;
1336 yysetstate:
1337 *yyssp = yystate;
1339 if (yyss + yystacksize - 1 <= yyssp)
1341 /* Get the current used size of the three stacks, in elements. */
1342 YYSIZE_T yysize = yyssp - yyss + 1;
1344 #ifdef yyoverflow
1346 /* Give user a chance to xreallocate the stack. Use copies of
1347 these so that the &'s don't force the real ones into
1348 memory. */
1349 YYSTYPE *yyvs1 = yyvs;
1350 short *yyss1 = yyss;
1353 /* Each stack pointer address is followed by the size of the
1354 data in use in that stack, in bytes. This used to be a
1355 conditional around just the two extra args, but that might
1356 be undefined if yyoverflow is a macro. */
1357 yyoverflow ("parser stack overflow",
1358 &yyss1, yysize * sizeof (*yyssp),
1359 &yyvs1, yysize * sizeof (*yyvsp),
1361 &yystacksize);
1363 yyss = yyss1;
1364 yyvs = yyvs1;
1366 #else /* no yyoverflow */
1367 # ifndef YYSTACK_RELOCATE
1368 goto yyoverflowlab;
1369 # else
1370 /* Extend the stack our own way. */
1371 if (YYMAXDEPTH <= yystacksize)
1372 goto yyoverflowlab;
1373 yystacksize *= 2;
1374 if (YYMAXDEPTH < yystacksize)
1375 yystacksize = YYMAXDEPTH;
1378 short *yyss1 = yyss;
1379 union yyalloc *yyptr =
1380 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1381 if (! yyptr)
1382 goto yyoverflowlab;
1383 YYSTACK_RELOCATE (yyss);
1384 YYSTACK_RELOCATE (yyvs);
1386 # undef YYSTACK_RELOCATE
1387 if (yyss1 != yyssa)
1388 YYSTACK_FREE (yyss1);
1390 # endif
1391 #endif /* no yyoverflow */
1393 yyssp = yyss + yysize - 1;
1394 yyvsp = yyvs + yysize - 1;
1397 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1398 (unsigned long int) yystacksize));
1400 if (yyss + yystacksize - 1 <= yyssp)
1401 YYABORT;
1404 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1406 goto yybackup;
1408 /*-----------.
1409 | yybackup. |
1410 `-----------*/
1411 yybackup:
1413 /* Do appropriate processing given the current state. */
1414 /* Read a lookahead token if we need one and don't already have one. */
1415 /* yyresume: */
1417 /* First try to decide what to do without reference to lookahead token. */
1419 yyn = yypact[yystate];
1420 if (yyn == YYPACT_NINF)
1421 goto yydefault;
1423 /* Not known => get a lookahead token if don't already have one. */
1425 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1426 if (yychar == YYEMPTY)
1428 YYDPRINTF ((stderr, "Reading a token: "));
1429 yychar = YYLEX;
1432 if (yychar <= YYEOF)
1434 yychar = yytoken = YYEOF;
1435 YYDPRINTF ((stderr, "Now at end of input.\n"));
1437 else
1439 yytoken = YYTRANSLATE (yychar);
1440 YYDSYMPRINTF ("Next token is", yytoken, &yylval, &yylloc);
1443 /* If the proper action on seeing token YYTOKEN is to reduce or to
1444 detect an error, take that action. */
1445 yyn += yytoken;
1446 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1447 goto yydefault;
1448 yyn = yytable[yyn];
1449 if (yyn <= 0)
1451 if (yyn == 0 || yyn == YYTABLE_NINF)
1452 goto yyerrlab;
1453 yyn = -yyn;
1454 goto yyreduce;
1457 if (yyn == YYFINAL)
1458 YYACCEPT;
1460 /* Shift the lookahead token. */
1461 YYDPRINTF ((stderr, "Shifting token %s, ", yytname[yytoken]));
1463 /* Discard the token being shifted unless it is eof. */
1464 if (yychar != YYEOF)
1465 yychar = YYEMPTY;
1467 *++yyvsp = yylval;
1470 /* Count tokens shifted since error; after three, turn off error
1471 status. */
1472 if (yyerrstatus)
1473 yyerrstatus--;
1475 yystate = yyn;
1476 goto yynewstate;
1479 /*-----------------------------------------------------------.
1480 | yydefault -- do the default action for the current state. |
1481 `-----------------------------------------------------------*/
1482 yydefault:
1483 yyn = yydefact[yystate];
1484 if (yyn == 0)
1485 goto yyerrlab;
1486 goto yyreduce;
1489 /*-----------------------------.
1490 | yyreduce -- Do a reduction. |
1491 `-----------------------------*/
1492 yyreduce:
1493 /* yyn is the number of a rule to reduce with. */
1494 yylen = yyr2[yyn];
1496 /* If YYLEN is nonzero, implement the default value of the action:
1497 `$$ = $1'.
1499 Otherwise, the following line sets YYVAL to garbage.
1500 This behavior is undocumented and Bison
1501 users should not rely upon it. Assigning to YYVAL
1502 unconditionally makes the parser a bit smaller, and it avoids a
1503 GCC warning that YYVAL may be used uninitialized. */
1504 yyval = yyvsp[1-yylen];
1507 YY_REDUCE_PRINT (yyn);
1508 switch (yyn)
1510 case 4:
1511 #line 230 "ada-exp.y"
1512 { write_exp_elt_opcode (BINOP_COMMA); }
1513 break;
1515 case 5:
1516 #line 232 "ada-exp.y"
1517 { write_exp_elt_opcode (BINOP_ASSIGN); }
1518 break;
1520 case 6:
1521 #line 237 "ada-exp.y"
1522 { write_exp_elt_opcode (UNOP_IND); }
1523 break;
1525 case 7:
1526 #line 241 "ada-exp.y"
1527 { write_exp_op_with_string (STRUCTOP_STRUCT, yyvsp[0].sval); }
1528 break;
1530 case 8:
1531 #line 245 "ada-exp.y"
1533 write_exp_elt_opcode (OP_FUNCALL);
1534 write_exp_elt_longcst (yyvsp[-1].lval);
1535 write_exp_elt_opcode (OP_FUNCALL);
1537 break;
1539 case 9:
1540 #line 251 "ada-exp.y"
1542 if (yyvsp[-3].tval != NULL)
1544 if (yyvsp[-1].lval != 1)
1545 error (_("Invalid conversion"));
1546 write_exp_elt_opcode (UNOP_CAST);
1547 write_exp_elt_type (yyvsp[-3].tval);
1548 write_exp_elt_opcode (UNOP_CAST);
1550 else
1552 write_exp_elt_opcode (OP_FUNCALL);
1553 write_exp_elt_longcst (yyvsp[-1].lval);
1554 write_exp_elt_opcode (OP_FUNCALL);
1557 break;
1559 case 10:
1560 #line 269 "ada-exp.y"
1561 { type_qualifier = yyvsp[-2].tval; }
1562 break;
1564 case 11:
1565 #line 271 "ada-exp.y"
1567 if (yyvsp[-6].tval == NULL)
1568 error (_("Type required for qualification"));
1569 write_exp_elt_opcode (UNOP_QUAL);
1570 write_exp_elt_type (yyvsp[-6].tval);
1571 write_exp_elt_opcode (UNOP_QUAL);
1572 type_qualifier = yyvsp[-4].tval;
1574 break;
1576 case 12:
1577 #line 281 "ada-exp.y"
1578 { yyval.tval = type_qualifier; }
1579 break;
1581 case 13:
1582 #line 286 "ada-exp.y"
1583 { write_exp_elt_opcode (TERNOP_SLICE); }
1584 break;
1586 case 14:
1587 #line 288 "ada-exp.y"
1588 { if (yyvsp[-5].tval == NULL)
1589 write_exp_elt_opcode (TERNOP_SLICE);
1590 else
1591 error (_("Cannot slice a type"));
1593 break;
1595 case 15:
1596 #line 295 "ada-exp.y"
1598 break;
1600 case 16:
1601 #line 307 "ada-exp.y"
1602 { if (yyvsp[0].tval != NULL)
1604 write_exp_elt_opcode (OP_TYPE);
1605 write_exp_elt_type (yyvsp[0].tval);
1606 write_exp_elt_opcode (OP_TYPE);
1609 break;
1611 case 17:
1612 #line 317 "ada-exp.y"
1613 { write_dollar_variable (yyvsp[0].sval); }
1614 break;
1616 case 20:
1617 #line 327 "ada-exp.y"
1618 { write_exp_elt_opcode (UNOP_NEG); }
1619 break;
1621 case 21:
1622 #line 331 "ada-exp.y"
1623 { write_exp_elt_opcode (UNOP_PLUS); }
1624 break;
1626 case 22:
1627 #line 335 "ada-exp.y"
1628 { write_exp_elt_opcode (UNOP_LOGICAL_NOT); }
1629 break;
1631 case 23:
1632 #line 339 "ada-exp.y"
1633 { write_exp_elt_opcode (UNOP_ABS); }
1634 break;
1636 case 24:
1637 #line 342 "ada-exp.y"
1638 { yyval.lval = 0; }
1639 break;
1641 case 25:
1642 #line 346 "ada-exp.y"
1643 { yyval.lval = 1; }
1644 break;
1646 case 26:
1647 #line 348 "ada-exp.y"
1648 { yyval.lval = 1; }
1649 break;
1651 case 27:
1652 #line 350 "ada-exp.y"
1653 { yyval.lval = yyvsp[-2].lval + 1; }
1654 break;
1656 case 28:
1657 #line 352 "ada-exp.y"
1658 { yyval.lval = yyvsp[-4].lval + 1; }
1659 break;
1661 case 29:
1662 #line 357 "ada-exp.y"
1664 if (yyvsp[-2].tval == NULL)
1665 error (_("Type required within braces in coercion"));
1666 write_exp_elt_opcode (UNOP_MEMVAL);
1667 write_exp_elt_type (yyvsp[-2].tval);
1668 write_exp_elt_opcode (UNOP_MEMVAL);
1670 break;
1672 case 30:
1673 #line 369 "ada-exp.y"
1674 { write_exp_elt_opcode (BINOP_EXP); }
1675 break;
1677 case 31:
1678 #line 373 "ada-exp.y"
1679 { write_exp_elt_opcode (BINOP_MUL); }
1680 break;
1682 case 32:
1683 #line 377 "ada-exp.y"
1684 { write_exp_elt_opcode (BINOP_DIV); }
1685 break;
1687 case 33:
1688 #line 381 "ada-exp.y"
1689 { write_exp_elt_opcode (BINOP_REM); }
1690 break;
1692 case 34:
1693 #line 385 "ada-exp.y"
1694 { write_exp_elt_opcode (BINOP_MOD); }
1695 break;
1697 case 35:
1698 #line 389 "ada-exp.y"
1699 { write_exp_elt_opcode (BINOP_REPEAT); }
1700 break;
1702 case 36:
1703 #line 393 "ada-exp.y"
1704 { write_exp_elt_opcode (BINOP_ADD); }
1705 break;
1707 case 37:
1708 #line 397 "ada-exp.y"
1709 { write_exp_elt_opcode (BINOP_CONCAT); }
1710 break;
1712 case 38:
1713 #line 401 "ada-exp.y"
1714 { write_exp_elt_opcode (BINOP_SUB); }
1715 break;
1717 case 40:
1718 #line 408 "ada-exp.y"
1719 { write_exp_elt_opcode (BINOP_EQUAL); }
1720 break;
1722 case 41:
1723 #line 412 "ada-exp.y"
1724 { write_exp_elt_opcode (BINOP_NOTEQUAL); }
1725 break;
1727 case 42:
1728 #line 416 "ada-exp.y"
1729 { write_exp_elt_opcode (BINOP_LEQ); }
1730 break;
1732 case 43:
1733 #line 420 "ada-exp.y"
1734 { write_exp_elt_opcode (TERNOP_IN_RANGE); }
1735 break;
1737 case 44:
1738 #line 422 "ada-exp.y"
1739 { write_exp_elt_opcode (BINOP_IN_BOUNDS);
1740 write_exp_elt_longcst ((LONGEST) yyvsp[0].lval);
1741 write_exp_elt_opcode (BINOP_IN_BOUNDS);
1743 break;
1745 case 45:
1746 #line 427 "ada-exp.y"
1748 if (yyvsp[0].tval == NULL)
1749 error (_("Right operand of 'in' must be type"));
1750 write_exp_elt_opcode (UNOP_IN_RANGE);
1751 write_exp_elt_type (yyvsp[0].tval);
1752 write_exp_elt_opcode (UNOP_IN_RANGE);
1754 break;
1756 case 46:
1757 #line 435 "ada-exp.y"
1758 { write_exp_elt_opcode (TERNOP_IN_RANGE);
1759 write_exp_elt_opcode (UNOP_LOGICAL_NOT);
1761 break;
1763 case 47:
1764 #line 439 "ada-exp.y"
1765 { write_exp_elt_opcode (BINOP_IN_BOUNDS);
1766 write_exp_elt_longcst ((LONGEST) yyvsp[0].lval);
1767 write_exp_elt_opcode (BINOP_IN_BOUNDS);
1768 write_exp_elt_opcode (UNOP_LOGICAL_NOT);
1770 break;
1772 case 48:
1773 #line 445 "ada-exp.y"
1775 if (yyvsp[0].tval == NULL)
1776 error (_("Right operand of 'in' must be type"));
1777 write_exp_elt_opcode (UNOP_IN_RANGE);
1778 write_exp_elt_type (yyvsp[0].tval);
1779 write_exp_elt_opcode (UNOP_IN_RANGE);
1780 write_exp_elt_opcode (UNOP_LOGICAL_NOT);
1782 break;
1784 case 49:
1785 #line 456 "ada-exp.y"
1786 { write_exp_elt_opcode (BINOP_GEQ); }
1787 break;
1789 case 50:
1790 #line 460 "ada-exp.y"
1791 { write_exp_elt_opcode (BINOP_LESS); }
1792 break;
1794 case 51:
1795 #line 464 "ada-exp.y"
1796 { write_exp_elt_opcode (BINOP_GTR); }
1797 break;
1799 case 58:
1800 #line 477 "ada-exp.y"
1801 { write_exp_elt_opcode (BINOP_BITWISE_AND); }
1802 break;
1804 case 59:
1805 #line 479 "ada-exp.y"
1806 { write_exp_elt_opcode (BINOP_BITWISE_AND); }
1807 break;
1809 case 60:
1810 #line 484 "ada-exp.y"
1811 { write_exp_elt_opcode (BINOP_LOGICAL_AND); }
1812 break;
1814 case 61:
1815 #line 486 "ada-exp.y"
1816 { write_exp_elt_opcode (BINOP_LOGICAL_AND); }
1817 break;
1819 case 62:
1820 #line 491 "ada-exp.y"
1821 { write_exp_elt_opcode (BINOP_BITWISE_IOR); }
1822 break;
1824 case 63:
1825 #line 493 "ada-exp.y"
1826 { write_exp_elt_opcode (BINOP_BITWISE_IOR); }
1827 break;
1829 case 64:
1830 #line 498 "ada-exp.y"
1831 { write_exp_elt_opcode (BINOP_LOGICAL_OR); }
1832 break;
1834 case 65:
1835 #line 500 "ada-exp.y"
1836 { write_exp_elt_opcode (BINOP_LOGICAL_OR); }
1837 break;
1839 case 66:
1840 #line 504 "ada-exp.y"
1841 { write_exp_elt_opcode (BINOP_BITWISE_XOR); }
1842 break;
1844 case 67:
1845 #line 506 "ada-exp.y"
1846 { write_exp_elt_opcode (BINOP_BITWISE_XOR); }
1847 break;
1849 case 68:
1850 #line 518 "ada-exp.y"
1851 { write_exp_elt_opcode (UNOP_ADDR); }
1852 break;
1854 case 69:
1855 #line 520 "ada-exp.y"
1856 { write_exp_elt_opcode (UNOP_ADDR);
1857 write_exp_elt_opcode (UNOP_CAST);
1858 write_exp_elt_type (type_system_address ());
1859 write_exp_elt_opcode (UNOP_CAST);
1861 break;
1863 case 70:
1864 #line 526 "ada-exp.y"
1865 { write_int (yyvsp[0].lval, type_int ());
1866 write_exp_elt_opcode (OP_ATR_FIRST); }
1867 break;
1869 case 71:
1870 #line 529 "ada-exp.y"
1871 { write_int (yyvsp[0].lval, type_int ());
1872 write_exp_elt_opcode (OP_ATR_LAST); }
1873 break;
1875 case 72:
1876 #line 532 "ada-exp.y"
1877 { write_int (yyvsp[0].lval, type_int ());
1878 write_exp_elt_opcode (OP_ATR_LENGTH); }
1879 break;
1881 case 73:
1882 #line 535 "ada-exp.y"
1883 { write_exp_elt_opcode (OP_ATR_SIZE); }
1884 break;
1886 case 74:
1887 #line 537 "ada-exp.y"
1888 { write_exp_elt_opcode (OP_ATR_TAG); }
1889 break;
1891 case 75:
1892 #line 539 "ada-exp.y"
1893 { write_exp_elt_opcode (OP_ATR_MIN); }
1894 break;
1896 case 76:
1897 #line 541 "ada-exp.y"
1898 { write_exp_elt_opcode (OP_ATR_MAX); }
1899 break;
1901 case 77:
1902 #line 543 "ada-exp.y"
1903 { write_exp_elt_opcode (OP_ATR_POS); }
1904 break;
1906 case 78:
1907 #line 545 "ada-exp.y"
1908 { write_exp_elt_opcode (OP_ATR_VAL); }
1909 break;
1911 case 79:
1912 #line 547 "ada-exp.y"
1913 { write_exp_elt_opcode (OP_ATR_MODULUS); }
1914 break;
1916 case 80:
1917 #line 551 "ada-exp.y"
1918 { yyval.lval = 1; }
1919 break;
1921 case 81:
1922 #line 553 "ada-exp.y"
1923 { yyval.lval = yyvsp[-1].typed_val.val; }
1924 break;
1926 case 82:
1927 #line 558 "ada-exp.y"
1929 if (yyvsp[0].tval == NULL)
1930 error (_("Prefix must be type"));
1931 write_exp_elt_opcode (OP_TYPE);
1932 write_exp_elt_type (yyvsp[0].tval);
1933 write_exp_elt_opcode (OP_TYPE); }
1934 break;
1936 case 84:
1937 #line 569 "ada-exp.y"
1938 { write_exp_elt_opcode (OP_TYPE);
1939 write_exp_elt_type (builtin_type_void);
1940 write_exp_elt_opcode (OP_TYPE); }
1941 break;
1943 case 85:
1944 #line 576 "ada-exp.y"
1945 { write_int ((LONGEST) yyvsp[0].typed_val.val, yyvsp[0].typed_val.type); }
1946 break;
1948 case 86:
1949 #line 580 "ada-exp.y"
1950 { write_int (convert_char_literal (type_qualifier, yyvsp[0].typed_val.val),
1951 (type_qualifier == NULL)
1952 ? yyvsp[0].typed_val.type : type_qualifier);
1954 break;
1956 case 87:
1957 #line 587 "ada-exp.y"
1958 { write_exp_elt_opcode (OP_DOUBLE);
1959 write_exp_elt_type (yyvsp[0].typed_val_float.type);
1960 write_exp_elt_dblcst (yyvsp[0].typed_val_float.dval);
1961 write_exp_elt_opcode (OP_DOUBLE);
1963 break;
1965 case 88:
1966 #line 595 "ada-exp.y"
1967 { write_int (0, type_int ()); }
1968 break;
1970 case 89:
1971 #line 599 "ada-exp.y"
1973 write_exp_op_with_string (OP_STRING, yyvsp[0].sval);
1975 break;
1977 case 90:
1978 #line 605 "ada-exp.y"
1979 { error (_("NEW not implemented.")); }
1980 break;
1982 case 91:
1983 #line 609 "ada-exp.y"
1984 { yyval.tval = write_var_or_type (NULL, yyvsp[0].sval); }
1985 break;
1987 case 92:
1988 #line 611 "ada-exp.y"
1989 { yyval.tval = write_var_or_type (yyvsp[-1].bval, yyvsp[0].sval); }
1990 break;
1992 case 93:
1993 #line 613 "ada-exp.y"
1995 yyval.tval = write_var_or_type (NULL, yyvsp[-1].sval);
1996 if (yyval.tval == NULL)
1997 write_exp_elt_opcode (UNOP_ADDR);
1998 else
1999 yyval.tval = lookup_pointer_type (yyval.tval);
2001 break;
2003 case 94:
2004 #line 621 "ada-exp.y"
2006 yyval.tval = write_var_or_type (yyvsp[-2].bval, yyvsp[-1].sval);
2007 if (yyval.tval == NULL)
2008 write_exp_elt_opcode (UNOP_ADDR);
2009 else
2010 yyval.tval = lookup_pointer_type (yyval.tval);
2012 break;
2014 case 95:
2015 #line 632 "ada-exp.y"
2016 { yyval.bval = block_lookup (NULL, yyvsp[-1].sval.ptr); }
2017 break;
2019 case 96:
2020 #line 634 "ada-exp.y"
2021 { yyval.bval = block_lookup (yyvsp[-2].bval, yyvsp[-1].sval.ptr); }
2022 break;
2024 case 97:
2025 #line 639 "ada-exp.y"
2027 write_exp_elt_opcode (OP_AGGREGATE);
2028 write_exp_elt_longcst (yyvsp[-1].lval);
2029 write_exp_elt_opcode (OP_AGGREGATE);
2031 break;
2033 case 98:
2034 #line 647 "ada-exp.y"
2035 { yyval.lval = yyvsp[0].lval; }
2036 break;
2038 case 99:
2039 #line 649 "ada-exp.y"
2040 { write_exp_elt_opcode (OP_POSITIONAL);
2041 write_exp_elt_longcst (yyvsp[-1].lval);
2042 write_exp_elt_opcode (OP_POSITIONAL);
2043 yyval.lval = yyvsp[-1].lval + 1;
2045 break;
2047 case 100:
2048 #line 655 "ada-exp.y"
2049 { yyval.lval = yyvsp[-1].lval + yyvsp[0].lval; }
2050 break;
2052 case 101:
2053 #line 660 "ada-exp.y"
2054 { write_exp_elt_opcode (OP_POSITIONAL);
2055 write_exp_elt_longcst (0);
2056 write_exp_elt_opcode (OP_POSITIONAL);
2057 yyval.lval = 1;
2059 break;
2061 case 102:
2062 #line 666 "ada-exp.y"
2063 { write_exp_elt_opcode (OP_POSITIONAL);
2064 write_exp_elt_longcst (yyvsp[-2].lval);
2065 write_exp_elt_opcode (OP_POSITIONAL);
2066 yyval.lval = yyvsp[-2].lval + 1;
2068 break;
2070 case 103:
2071 #line 674 "ada-exp.y"
2072 { yyval.lval = 1; }
2073 break;
2075 case 104:
2076 #line 675 "ada-exp.y"
2077 { yyval.lval = 1; }
2078 break;
2080 case 105:
2081 #line 677 "ada-exp.y"
2082 { yyval.lval = yyvsp[0].lval + 1; }
2083 break;
2085 case 106:
2086 #line 681 "ada-exp.y"
2087 { write_exp_elt_opcode (OP_OTHERS); }
2088 break;
2090 case 107:
2091 #line 686 "ada-exp.y"
2093 write_exp_elt_opcode (OP_CHOICES);
2094 write_exp_elt_longcst (yyvsp[0].lval);
2095 write_exp_elt_opcode (OP_CHOICES);
2097 break;
2099 case 108:
2100 #line 700 "ada-exp.y"
2101 { write_name_assoc (yyvsp[-1].sval); }
2102 break;
2104 case 109:
2105 #line 701 "ada-exp.y"
2106 { yyval.lval = 1; }
2107 break;
2109 case 110:
2110 #line 703 "ada-exp.y"
2111 { yyval.lval = 1; }
2112 break;
2114 case 111:
2115 #line 705 "ada-exp.y"
2116 { write_exp_elt_opcode (OP_DISCRETE_RANGE);
2117 write_exp_op_with_string (OP_NAME, empty_stoken);
2119 break;
2121 case 112:
2122 #line 708 "ada-exp.y"
2123 { yyval.lval = 1; }
2124 break;
2126 case 113:
2127 #line 710 "ada-exp.y"
2128 { write_name_assoc (yyvsp[-1].sval); }
2129 break;
2131 case 114:
2132 #line 711 "ada-exp.y"
2133 { yyval.lval = yyvsp[0].lval + 1; }
2134 break;
2136 case 115:
2137 #line 713 "ada-exp.y"
2138 { yyval.lval = yyvsp[0].lval + 1; }
2139 break;
2141 case 116:
2142 #line 715 "ada-exp.y"
2143 { write_exp_elt_opcode (OP_DISCRETE_RANGE); }
2144 break;
2146 case 117:
2147 #line 716 "ada-exp.y"
2148 { yyval.lval = yyvsp[0].lval + 1; }
2149 break;
2151 case 118:
2152 #line 723 "ada-exp.y"
2153 { write_exp_elt_opcode (UNOP_IND); }
2154 break;
2156 case 119:
2157 #line 725 "ada-exp.y"
2158 { write_exp_elt_opcode (UNOP_ADDR); }
2159 break;
2161 case 120:
2162 #line 727 "ada-exp.y"
2163 { write_exp_elt_opcode (BINOP_SUBSCRIPT); }
2164 break;
2169 /* Line 1000 of yacc.c. */
2170 #line 2171 "ada-exp.c.tmp"
2172 yyvsp -= yylen;
2173 yyssp -= yylen;
2176 YY_STACK_PRINT (yyss, yyssp);
2178 *++yyvsp = yyval;
2181 /* Now `shift' the result of the reduction. Determine what state
2182 that goes to, based on the state we popped back to and the rule
2183 number reduced by. */
2185 yyn = yyr1[yyn];
2187 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
2188 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
2189 yystate = yytable[yystate];
2190 else
2191 yystate = yydefgoto[yyn - YYNTOKENS];
2193 goto yynewstate;
2196 /*------------------------------------.
2197 | yyerrlab -- here on detecting error |
2198 `------------------------------------*/
2199 yyerrlab:
2200 /* If not already recovering from an error, report this error. */
2201 if (!yyerrstatus)
2203 ++yynerrs;
2204 #if YYERROR_VERBOSE
2205 yyn = yypact[yystate];
2207 if (YYPACT_NINF < yyn && yyn < YYLAST)
2209 YYSIZE_T yysize = 0;
2210 int yytype = YYTRANSLATE (yychar);
2211 const char* yyprefix;
2212 char *yymsg;
2213 int yyx;
2215 /* Start YYX at -YYN if negative to avoid negative indexes in
2216 YYCHECK. */
2217 int yyxbegin = yyn < 0 ? -yyn : 0;
2219 /* Stay within bounds of both yycheck and yytname. */
2220 int yychecklim = YYLAST - yyn;
2221 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
2222 int yycount = 0;
2224 yyprefix = ", expecting ";
2225 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
2226 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
2228 yysize += yystrlen (yyprefix) + yystrlen (yytname [yyx]);
2229 yycount += 1;
2230 if (yycount == 5)
2232 yysize = 0;
2233 break;
2236 yysize += (sizeof ("syntax error, unexpected ")
2237 + yystrlen (yytname[yytype]));
2238 yymsg = (char *) YYSTACK_ALLOC (yysize);
2239 if (yymsg != 0)
2241 char *yyp = yystpcpy (yymsg, "syntax error, unexpected ");
2242 yyp = yystpcpy (yyp, yytname[yytype]);
2244 if (yycount < 5)
2246 yyprefix = ", expecting ";
2247 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
2248 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
2250 yyp = yystpcpy (yyp, yyprefix);
2251 yyp = yystpcpy (yyp, yytname[yyx]);
2252 yyprefix = " or ";
2255 yyerror (yymsg);
2256 YYSTACK_FREE (yymsg);
2258 else
2259 yyerror ("syntax error; also virtual memory exhausted");
2261 else
2262 #endif /* YYERROR_VERBOSE */
2263 yyerror ("syntax error");
2268 if (yyerrstatus == 3)
2270 /* If just tried and failed to reuse lookahead token after an
2271 error, discard it. */
2273 if (yychar <= YYEOF)
2275 /* If at end of input, pop the error token,
2276 then the rest of the stack, then return failure. */
2277 if (yychar == YYEOF)
2278 for (;;)
2280 YYPOPSTACK;
2281 if (yyssp == yyss)
2282 YYABORT;
2283 YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
2284 yydestruct (yystos[*yyssp], yyvsp);
2287 else
2289 YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc);
2290 yydestruct (yytoken, &yylval);
2291 yychar = YYEMPTY;
2296 /* Else will try to reuse lookahead token after shifting the error
2297 token. */
2298 goto yyerrlab1;
2301 /*---------------------------------------------------.
2302 | yyerrorlab -- error raised explicitly by YYERROR. |
2303 `---------------------------------------------------*/
2304 yyerrorlab:
2306 #ifdef __GNUC__
2307 /* Pacify GCC when the user code never invokes YYERROR and the label
2308 yyerrorlab therefore never appears in user code. */
2309 if (0)
2310 goto yyerrorlab;
2311 #endif
2313 yyvsp -= yylen;
2314 yyssp -= yylen;
2315 yystate = *yyssp;
2316 goto yyerrlab1;
2319 /*-------------------------------------------------------------.
2320 | yyerrlab1 -- common code for both syntax error and YYERROR. |
2321 `-------------------------------------------------------------*/
2322 yyerrlab1:
2323 yyerrstatus = 3; /* Each real token shifted decrements this. */
2325 for (;;)
2327 yyn = yypact[yystate];
2328 if (yyn != YYPACT_NINF)
2330 yyn += YYTERROR;
2331 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
2333 yyn = yytable[yyn];
2334 if (0 < yyn)
2335 break;
2339 /* Pop the current state because it cannot handle the error token. */
2340 if (yyssp == yyss)
2341 YYABORT;
2343 YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
2344 yydestruct (yystos[yystate], yyvsp);
2345 YYPOPSTACK;
2346 yystate = *yyssp;
2347 YY_STACK_PRINT (yyss, yyssp);
2350 if (yyn == YYFINAL)
2351 YYACCEPT;
2353 YYDPRINTF ((stderr, "Shifting error token, "));
2355 *++yyvsp = yylval;
2358 yystate = yyn;
2359 goto yynewstate;
2362 /*-------------------------------------.
2363 | yyacceptlab -- YYACCEPT comes here. |
2364 `-------------------------------------*/
2365 yyacceptlab:
2366 yyresult = 0;
2367 goto yyreturn;
2369 /*-----------------------------------.
2370 | yyabortlab -- YYABORT comes here. |
2371 `-----------------------------------*/
2372 yyabortlab:
2373 yyresult = 1;
2374 goto yyreturn;
2376 #ifndef yyoverflow
2377 /*----------------------------------------------.
2378 | yyoverflowlab -- parser overflow comes here. |
2379 `----------------------------------------------*/
2380 yyoverflowlab:
2381 yyerror ("parser stack overflow");
2382 yyresult = 2;
2383 /* Fall through. */
2384 #endif
2386 yyreturn:
2387 #ifndef yyoverflow
2388 if (yyss != yyssa)
2389 YYSTACK_FREE (yyss);
2390 #endif
2391 return yyresult;
2395 #line 730 "ada-exp.y"
2398 /* yylex defined in ada-lex.c: Reads one token, getting characters */
2399 /* through lexptr. */
2401 /* Remap normal flex interface names (yylex) as well as gratuitiously */
2402 /* global symbol names, so we can have multiple flex-generated parsers */
2403 /* in gdb. */
2405 /* (See note above on previous definitions for YACC.) */
2407 #define yy_create_buffer ada_yy_create_buffer
2408 #define yy_delete_buffer ada_yy_delete_buffer
2409 #define yy_init_buffer ada_yy_init_buffer
2410 #define yy_load_buffer_state ada_yy_load_buffer_state
2411 #define yy_switch_to_buffer ada_yy_switch_to_buffer
2412 #define yyrestart ada_yyrestart
2413 #define yytext ada_yytext
2414 #define yywrap ada_yywrap
2416 static struct obstack temp_parse_space;
2418 /* The following kludge was found necessary to prevent conflicts between */
2419 /* defs.h and non-standard stdlib.h files. */
2420 #define qsort __qsort__dummy
2421 #include "ada-lex.c"
2424 ada_parse (void)
2426 lexer_init (yyin); /* (Re-)initialize lexer. */
2427 type_qualifier = NULL;
2428 obstack_free (&temp_parse_space, NULL);
2429 obstack_init (&temp_parse_space);
2431 return _ada_parse ();
2434 void
2435 yyerror (char *msg)
2437 error (_("Error in expression, near `%s'."), lexptr);
2440 /* The operator name corresponding to operator symbol STRING (adds
2441 quotes and maps to lower-case). Destroys the previous contents of
2442 the array pointed to by STRING.ptr. Error if STRING does not match
2443 a valid Ada operator. Assumes that STRING.ptr points to a
2444 null-terminated string and that, if STRING is a valid operator
2445 symbol, the array pointed to by STRING.ptr contains at least
2446 STRING.length+3 characters. */
2448 static struct stoken
2449 string_to_operator (struct stoken string)
2451 int i;
2453 for (i = 0; ada_opname_table[i].encoded != NULL; i += 1)
2455 if (string.length == strlen (ada_opname_table[i].decoded)-2
2456 && strncasecmp (string.ptr, ada_opname_table[i].decoded+1,
2457 string.length) == 0)
2459 strncpy (string.ptr, ada_opname_table[i].decoded,
2460 string.length+2);
2461 string.length += 2;
2462 return string;
2465 error (_("Invalid operator symbol `%s'"), string.ptr);
2468 /* Emit expression to access an instance of SYM, in block BLOCK (if
2469 * non-NULL), and with :: qualification ORIG_LEFT_CONTEXT. */
2470 static void
2471 write_var_from_sym (struct block *orig_left_context,
2472 struct block *block,
2473 struct symbol *sym)
2475 if (orig_left_context == NULL && symbol_read_needs_frame (sym))
2477 if (innermost_block == 0
2478 || contained_in (block, innermost_block))
2479 innermost_block = block;
2482 write_exp_elt_opcode (OP_VAR_VALUE);
2483 write_exp_elt_block (block);
2484 write_exp_elt_sym (sym);
2485 write_exp_elt_opcode (OP_VAR_VALUE);
2488 /* Write integer constant ARG of type TYPE. */
2490 static void
2491 write_int (LONGEST arg, struct type *type)
2493 write_exp_elt_opcode (OP_LONG);
2494 write_exp_elt_type (type);
2495 write_exp_elt_longcst (arg);
2496 write_exp_elt_opcode (OP_LONG);
2499 /* Write an OPCODE, string, OPCODE sequence to the current expression. */
2500 static void
2501 write_exp_op_with_string (enum exp_opcode opcode, struct stoken token)
2503 write_exp_elt_opcode (opcode);
2504 write_exp_string (token);
2505 write_exp_elt_opcode (opcode);
2508 /* Emit expression corresponding to the renamed object designated by
2509 * the type RENAMING, which must be the referent of an object renaming
2510 * type, in the context of ORIG_LEFT_CONTEXT. MAX_DEPTH is the maximum
2511 * number of cascaded renamings to allow. */
2512 static void
2513 write_object_renaming (struct block *orig_left_context,
2514 struct symbol *renaming, int max_depth)
2516 const char *qualification = SYMBOL_LINKAGE_NAME (renaming);
2517 const char *simple_tail;
2518 const char *expr = TYPE_FIELD_NAME (SYMBOL_TYPE (renaming), 0);
2519 const char *suffix;
2520 char *name;
2521 struct symbol *sym;
2522 enum { SIMPLE_INDEX, LOWER_BOUND, UPPER_BOUND } slice_state;
2524 if (max_depth <= 0)
2525 error (_("Could not find renamed symbol"));
2527 /* if orig_left_context is null, then use the currently selected
2528 block; otherwise we might fail our symbol lookup below. */
2529 if (orig_left_context == NULL)
2530 orig_left_context = get_selected_block (NULL);
2532 for (simple_tail = qualification + strlen (qualification);
2533 simple_tail != qualification; simple_tail -= 1)
2535 if (*simple_tail == '.')
2537 simple_tail += 1;
2538 break;
2540 else if (strncmp (simple_tail, "__", 2) == 0)
2542 simple_tail += 2;
2543 break;
2547 suffix = strstr (expr, "___XE");
2548 if (suffix == NULL)
2549 goto BadEncoding;
2551 name = (char *) obstack_alloc (&temp_parse_space, suffix - expr + 1);
2552 strncpy (name, expr, suffix-expr);
2553 name[suffix-expr] = '\000';
2554 sym = lookup_symbol (name, orig_left_context, VAR_DOMAIN, 0, NULL);
2555 if (sym == NULL)
2556 error (_("Could not find renamed variable: %s"), ada_decode (name));
2557 if (ada_is_object_renaming (sym))
2558 write_object_renaming (orig_left_context, sym, max_depth-1);
2559 else
2560 write_var_from_sym (orig_left_context, block_found, sym);
2562 suffix += 5;
2563 slice_state = SIMPLE_INDEX;
2564 while (*suffix == 'X')
2566 suffix += 1;
2568 switch (*suffix) {
2569 case 'A':
2570 suffix += 1;
2571 write_exp_elt_opcode (UNOP_IND);
2572 break;
2573 case 'L':
2574 slice_state = LOWER_BOUND;
2575 case 'S':
2576 suffix += 1;
2577 if (isdigit (*suffix))
2579 char *next;
2580 long val = strtol (suffix, &next, 10);
2581 if (next == suffix)
2582 goto BadEncoding;
2583 suffix = next;
2584 write_exp_elt_opcode (OP_LONG);
2585 write_exp_elt_type (type_int ());
2586 write_exp_elt_longcst ((LONGEST) val);
2587 write_exp_elt_opcode (OP_LONG);
2589 else
2591 const char *end;
2592 char *index_name;
2593 int index_len;
2594 struct symbol *index_sym;
2596 end = strchr (suffix, 'X');
2597 if (end == NULL)
2598 end = suffix + strlen (suffix);
2600 index_len = simple_tail - qualification + 2 + (suffix - end) + 1;
2601 index_name
2602 = (char *) obstack_alloc (&temp_parse_space, index_len);
2603 memset (index_name, '\000', index_len);
2604 strncpy (index_name, qualification, simple_tail - qualification);
2605 index_name[simple_tail - qualification] = '\000';
2606 strncat (index_name, suffix, suffix-end);
2607 suffix = end;
2609 index_sym =
2610 lookup_symbol (index_name, NULL, VAR_DOMAIN, 0, NULL);
2611 if (index_sym == NULL)
2612 error (_("Could not find %s"), index_name);
2613 write_var_from_sym (NULL, block_found, sym);
2615 if (slice_state == SIMPLE_INDEX)
2617 write_exp_elt_opcode (OP_FUNCALL);
2618 write_exp_elt_longcst ((LONGEST) 1);
2619 write_exp_elt_opcode (OP_FUNCALL);
2621 else if (slice_state == LOWER_BOUND)
2622 slice_state = UPPER_BOUND;
2623 else if (slice_state == UPPER_BOUND)
2625 write_exp_elt_opcode (TERNOP_SLICE);
2626 slice_state = SIMPLE_INDEX;
2628 break;
2630 case 'R':
2632 struct stoken field_name;
2633 const char *end;
2634 suffix += 1;
2636 if (slice_state != SIMPLE_INDEX)
2637 goto BadEncoding;
2638 end = strchr (suffix, 'X');
2639 if (end == NULL)
2640 end = suffix + strlen (suffix);
2641 field_name.length = end - suffix;
2642 field_name.ptr = xmalloc (end - suffix + 1);
2643 strncpy (field_name.ptr, suffix, end - suffix);
2644 field_name.ptr[end - suffix] = '\000';
2645 suffix = end;
2646 write_exp_op_with_string (STRUCTOP_STRUCT, field_name);
2647 break;
2650 default:
2651 goto BadEncoding;
2654 if (slice_state == SIMPLE_INDEX)
2655 return;
2657 BadEncoding:
2658 error (_("Internal error in encoding of renaming declaration: %s"),
2659 SYMBOL_LINKAGE_NAME (renaming));
2662 static struct block*
2663 block_lookup (struct block *context, char *raw_name)
2665 char *name;
2666 struct ada_symbol_info *syms;
2667 int nsyms;
2668 struct symtab *symtab;
2670 if (raw_name[0] == '\'')
2672 raw_name += 1;
2673 name = raw_name;
2675 else
2676 name = ada_encode (raw_name);
2678 nsyms = ada_lookup_symbol_list (name, context, VAR_DOMAIN, &syms);
2679 if (context == NULL &&
2680 (nsyms == 0 || SYMBOL_CLASS (syms[0].sym) != LOC_BLOCK))
2681 symtab = lookup_symtab (name);
2682 else
2683 symtab = NULL;
2685 if (symtab != NULL)
2686 return BLOCKVECTOR_BLOCK (BLOCKVECTOR (symtab), STATIC_BLOCK);
2687 else if (nsyms == 0 || SYMBOL_CLASS (syms[0].sym) != LOC_BLOCK)
2689 if (context == NULL)
2690 error (_("No file or function \"%s\"."), raw_name);
2691 else
2692 error (_("No function \"%s\" in specified context."), raw_name);
2694 else
2696 if (nsyms > 1)
2697 warning (_("Function name \"%s\" ambiguous here"), raw_name);
2698 return SYMBOL_BLOCK_VALUE (syms[0].sym);
2702 static struct symbol*
2703 select_possible_type_sym (struct ada_symbol_info *syms, int nsyms)
2705 int i;
2706 int preferred_index;
2707 struct type *preferred_type;
2709 preferred_index = -1; preferred_type = NULL;
2710 for (i = 0; i < nsyms; i += 1)
2711 switch (SYMBOL_CLASS (syms[i].sym))
2713 case LOC_TYPEDEF:
2714 if (ada_prefer_type (SYMBOL_TYPE (syms[i].sym), preferred_type))
2716 preferred_index = i;
2717 preferred_type = SYMBOL_TYPE (syms[i].sym);
2719 break;
2720 case LOC_REGISTER:
2721 case LOC_ARG:
2722 case LOC_REF_ARG:
2723 case LOC_REGPARM:
2724 case LOC_REGPARM_ADDR:
2725 case LOC_LOCAL:
2726 case LOC_LOCAL_ARG:
2727 case LOC_BASEREG:
2728 case LOC_BASEREG_ARG:
2729 case LOC_COMPUTED:
2730 case LOC_COMPUTED_ARG:
2731 return NULL;
2732 default:
2733 break;
2735 if (preferred_type == NULL)
2736 return NULL;
2737 return syms[preferred_index].sym;
2740 static struct type*
2741 find_primitive_type (char *name)
2743 struct type *type;
2744 type = language_lookup_primitive_type_by_name (current_language,
2745 current_gdbarch,
2746 name);
2747 if (type == NULL && strcmp ("system__address", name) == 0)
2748 type = type_system_address ();
2750 if (type != NULL)
2752 /* Check to see if we have a regular definition of this
2753 type that just didn't happen to have been read yet. */
2754 int ntypes;
2755 struct symbol *sym;
2756 char *expanded_name =
2757 (char *) alloca (strlen (name) + sizeof ("standard__"));
2758 strcpy (expanded_name, "standard__");
2759 strcat (expanded_name, name);
2760 sym = ada_lookup_symbol (expanded_name, NULL, VAR_DOMAIN, NULL, NULL);
2761 if (sym != NULL && SYMBOL_CLASS (sym) == LOC_TYPEDEF)
2762 type = SYMBOL_TYPE (sym);
2765 return type;
2768 static int
2769 chop_selector (char *name, int end)
2771 int i;
2772 for (i = end - 1; i > 0; i -= 1)
2773 if (name[i] == '.' || (name[i] == '_' && name[i+1] == '_'))
2774 return i;
2775 return -1;
2778 /* Given that SELS is a string of the form (<sep><identifier>)*, where
2779 <sep> is '__' or '.', write the indicated sequence of
2780 STRUCTOP_STRUCT expression operators. */
2781 static void
2782 write_selectors (char *sels)
2784 while (*sels != '\0')
2786 struct stoken field_name;
2787 char *p;
2788 while (*sels == '_' || *sels == '.')
2789 sels += 1;
2790 p = sels;
2791 while (*sels != '\0' && *sels != '.'
2792 && (sels[0] != '_' || sels[1] != '_'))
2793 sels += 1;
2794 field_name.length = sels - p;
2795 field_name.ptr = p;
2796 write_exp_op_with_string (STRUCTOP_STRUCT, field_name);
2800 /* Write a variable access (OP_VAR_VALUE) to ambiguous encoded name
2801 NAME[0..LEN-1], in block context BLOCK, to be resolved later. Writes
2802 a temporary symbol that is valid until the next call to ada_parse.
2804 static void
2805 write_ambiguous_var (struct block *block, char *name, int len)
2807 struct symbol *sym =
2808 obstack_alloc (&temp_parse_space, sizeof (struct symbol));
2809 memset (sym, 0, sizeof (struct symbol));
2810 SYMBOL_DOMAIN (sym) = UNDEF_DOMAIN;
2811 SYMBOL_LINKAGE_NAME (sym) = obsavestring (name, len, &temp_parse_space);
2812 SYMBOL_LANGUAGE (sym) = language_ada;
2814 write_exp_elt_opcode (OP_VAR_VALUE);
2815 write_exp_elt_block (block);
2816 write_exp_elt_sym (sym);
2817 write_exp_elt_opcode (OP_VAR_VALUE);
2821 /* Look up NAME0 (an unencoded identifier or dotted name) in BLOCK (or
2822 expression_block_context if NULL). If it denotes a type, return
2823 that type. Otherwise, write expression code to evaluate it as an
2824 object and return NULL. In this second case, NAME0 will, in general,
2825 have the form <name>(.<selector_name>)*, where <name> is an object
2826 or renaming encoded in the debugging data. Calls error if no
2827 prefix <name> matches a name in the debugging data (i.e., matches
2828 either a complete name or, as a wild-card match, the final
2829 identifier). */
2831 static struct type*
2832 write_var_or_type (struct block *block, struct stoken name0)
2834 int depth;
2835 char *encoded_name;
2836 int name_len;
2838 if (block == NULL)
2839 block = expression_context_block;
2841 encoded_name = ada_encode (name0.ptr);
2842 name_len = strlen (encoded_name);
2843 encoded_name = obsavestring (encoded_name, name_len, &temp_parse_space);
2844 for (depth = 0; depth < MAX_RENAMING_CHAIN_LENGTH; depth += 1)
2846 int tail_index;
2848 tail_index = name_len;
2849 while (tail_index > 0)
2851 int nsyms;
2852 struct ada_symbol_info *syms;
2853 struct symbol *type_sym;
2854 int terminator = encoded_name[tail_index];
2856 encoded_name[tail_index] = '\0';
2857 nsyms = ada_lookup_symbol_list (encoded_name, block,
2858 VAR_DOMAIN, &syms);
2859 encoded_name[tail_index] = terminator;
2861 /* A single symbol may rename a package or object. */
2863 if (nsyms == 1 && !ada_is_object_renaming (syms[0].sym))
2865 struct symbol *renaming_sym =
2866 ada_find_renaming_symbol (SYMBOL_LINKAGE_NAME (syms[0].sym),
2867 syms[0].block);
2869 if (renaming_sym != NULL)
2870 syms[0].sym = renaming_sym;
2873 type_sym = select_possible_type_sym (syms, nsyms);
2874 if (type_sym != NULL)
2876 struct type *type = SYMBOL_TYPE (type_sym);
2878 if (TYPE_CODE (type) == TYPE_CODE_VOID)
2879 error (_("`%s' matches only void type name(s)"), name0.ptr);
2880 else if (ada_is_object_renaming (type_sym))
2882 write_object_renaming (block, type_sym,
2883 MAX_RENAMING_CHAIN_LENGTH);
2884 write_selectors (encoded_name + tail_index);
2885 return NULL;
2887 else if (ada_renaming_type (SYMBOL_TYPE (type_sym)) != NULL)
2889 int result;
2890 char *renaming = ada_simple_renamed_entity (type_sym);
2891 int renaming_len = strlen (renaming);
2893 char *new_name
2894 = obstack_alloc (&temp_parse_space,
2895 renaming_len + name_len - tail_index
2896 + 1);
2897 strcpy (new_name, renaming);
2898 xfree (renaming);
2899 strcpy (new_name + renaming_len, encoded_name + tail_index);
2900 encoded_name = new_name;
2901 name_len = renaming_len + name_len - tail_index;
2902 goto TryAfterRenaming;
2904 else if (tail_index == name_len)
2905 return type;
2906 else
2907 error (_("Invalid attempt to select from type: \"%s\"."), name0.ptr);
2909 else if (tail_index == name_len && nsyms == 0)
2911 struct type *type = find_primitive_type (encoded_name);
2913 if (type != NULL)
2914 return type;
2917 if (nsyms == 1)
2919 write_var_from_sym (block, syms[0].block, syms[0].sym);
2920 write_selectors (encoded_name + tail_index);
2921 return NULL;
2923 else if (nsyms == 0)
2925 int i;
2926 struct minimal_symbol *msym
2927 = ada_lookup_simple_minsym (encoded_name);
2928 if (msym != NULL)
2930 write_exp_msymbol (msym, lookup_function_type (type_int ()),
2931 type_int ());
2932 /* Maybe cause error here rather than later? FIXME? */
2933 write_selectors (encoded_name + tail_index);
2934 return NULL;
2937 if (tail_index == name_len
2938 && strncmp (encoded_name, "standard__",
2939 sizeof ("standard__") - 1) == 0)
2940 error (_("No definition of \"%s\" found."), name0.ptr);
2942 tail_index = chop_selector (encoded_name, tail_index);
2944 else
2946 write_ambiguous_var (block, encoded_name, tail_index);
2947 write_selectors (encoded_name + tail_index);
2948 return NULL;
2952 if (!have_full_symbols () && !have_partial_symbols () && block == NULL)
2953 error (_("No symbol table is loaded. Use the \"file\" command."));
2954 if (block == expression_context_block)
2955 error (_("No definition of \"%s\" in current context."), name0.ptr);
2956 else
2957 error (_("No definition of \"%s\" in specified context."), name0.ptr);
2959 TryAfterRenaming: ;
2962 error (_("Could not find renamed symbol \"%s\""), name0.ptr);
2966 /* Write a left side of a component association (e.g., NAME in NAME =>
2967 exp). If NAME has the form of a selected component, write it as an
2968 ordinary expression. If it is a simple variable that unambiguously
2969 corresponds to exactly one symbol that does not denote a type or an
2970 object renaming, also write it normally as an OP_VAR_VALUE.
2971 Otherwise, write it as an OP_NAME.
2973 Unfortunately, we don't know at this point whether NAME is supposed
2974 to denote a record component name or the value of an array index.
2975 Therefore, it is not appropriate to disambiguate an ambiguous name
2976 as we normally would, nor to replace a renaming with its referent.
2977 As a result, in the (one hopes) rare case that one writes an
2978 aggregate such as (R => 42) where R renames an object or is an
2979 ambiguous name, one must write instead ((R) => 42). */
2981 static void
2982 write_name_assoc (struct stoken name)
2984 if (strchr (name.ptr, '.') == NULL)
2986 struct ada_symbol_info *syms;
2987 int nsyms = ada_lookup_symbol_list (name.ptr, expression_context_block,
2988 VAR_DOMAIN, &syms);
2989 if (nsyms != 1 || SYMBOL_CLASS (syms[0].sym) == LOC_TYPEDEF)
2990 write_exp_op_with_string (OP_NAME, name);
2991 else
2992 write_var_from_sym (NULL, syms[0].block, syms[0].sym);
2994 else
2995 if (write_var_or_type (NULL, name) != NULL)
2996 error (_("Invalid use of type."));
2999 /* Convert the character literal whose ASCII value would be VAL to the
3000 appropriate value of type TYPE, if there is a translation.
3001 Otherwise return VAL. Hence, in an enumeration type ('A', 'B'),
3002 the literal 'A' (VAL == 65), returns 0. */
3004 static LONGEST
3005 convert_char_literal (struct type *type, LONGEST val)
3007 char name[7];
3008 int f;
3010 if (type == NULL || TYPE_CODE (type) != TYPE_CODE_ENUM)
3011 return val;
3012 sprintf (name, "QU%02x", (int) val);
3013 for (f = 0; f < TYPE_NFIELDS (type); f += 1)
3015 if (strcmp (name, TYPE_FIELD_NAME (type, f)) == 0)
3016 return TYPE_FIELD_BITPOS (type, f);
3018 return val;
3021 static struct type *
3022 type_int (void)
3024 return builtin_type (current_gdbarch)->builtin_int;
3027 static struct type *
3028 type_long (void)
3030 return builtin_type (current_gdbarch)->builtin_long;
3033 static struct type *
3034 type_long_long (void)
3036 return builtin_type (current_gdbarch)->builtin_long_long;
3039 static struct type *
3040 type_float (void)
3042 return builtin_type (current_gdbarch)->builtin_float;
3045 static struct type *
3046 type_double (void)
3048 return builtin_type (current_gdbarch)->builtin_double;
3051 static struct type *
3052 type_long_double (void)
3054 return builtin_type (current_gdbarch)->builtin_long_double;
3057 static struct type *
3058 type_char (void)
3060 return language_string_char_type (current_language, current_gdbarch);
3063 static struct type *
3064 type_system_address (void)
3066 struct type *type
3067 = language_lookup_primitive_type_by_name (current_language,
3068 current_gdbarch,
3069 "system__address");
3070 return type != NULL ? type : lookup_pointer_type (builtin_type_void);
3073 void
3074 _initialize_ada_exp (void)
3076 obstack_init (&temp_parse_space);
3079 /* FIXME: hilfingr/2004-10-05: Hack to remove warning. The function
3080 string_to_operator is supposed to be used for cases where one
3081 calls an operator function with prefix notation, as in
3082 "+" (a, b), but at some point, this code seems to have gone
3083 missing. */
3085 struct stoken (*dummy_string_to_ada_operator) (struct stoken)
3086 = string_to_operator;