Fix up mix of man(7)/mdoc(7).
[netbsd-mini2440.git] / gnu / dist / gdb6 / gdb / p-exp.c
blobb0c201c2c421e8a19bbf200cf7f598a9205cffe0
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 FLOAT = 259,
58 STRING = 260,
59 FIELDNAME = 261,
60 NAME = 262,
61 TYPENAME = 263,
62 NAME_OR_INT = 264,
63 STRUCT = 265,
64 CLASS = 266,
65 SIZEOF = 267,
66 COLONCOLON = 268,
67 ERROR = 269,
68 VARIABLE = 270,
69 THIS = 271,
70 TRUEKEYWORD = 272,
71 FALSEKEYWORD = 273,
72 ABOVE_COMMA = 274,
73 ASSIGN = 275,
74 NOT = 276,
75 OR = 277,
76 XOR = 278,
77 ANDAND = 279,
78 NOTEQUAL = 280,
79 GEQ = 281,
80 LEQ = 282,
81 MOD = 283,
82 DIV = 284,
83 RSH = 285,
84 LSH = 286,
85 DECREMENT = 287,
86 INCREMENT = 288,
87 UNARY = 289,
88 ARROW = 290,
89 BLOCKNAME = 291
91 #endif
92 #define INT 258
93 #define FLOAT 259
94 #define STRING 260
95 #define FIELDNAME 261
96 #define NAME 262
97 #define TYPENAME 263
98 #define NAME_OR_INT 264
99 #define STRUCT 265
100 #define CLASS 266
101 #define SIZEOF 267
102 #define COLONCOLON 268
103 #define ERROR 269
104 #define VARIABLE 270
105 #define THIS 271
106 #define TRUEKEYWORD 272
107 #define FALSEKEYWORD 273
108 #define ABOVE_COMMA 274
109 #define ASSIGN 275
110 #define NOT 276
111 #define OR 277
112 #define XOR 278
113 #define ANDAND 279
114 #define NOTEQUAL 280
115 #define GEQ 281
116 #define LEQ 282
117 #define MOD 283
118 #define DIV 284
119 #define RSH 285
120 #define LSH 286
121 #define DECREMENT 287
122 #define INCREMENT 288
123 #define UNARY 289
124 #define ARROW 290
125 #define BLOCKNAME 291
130 /* Copy the first part of user declarations. */
131 #line 47 "p-exp.y"
134 #include "defs.h"
135 #include "gdb_string.h"
136 #include <ctype.h>
137 #include "expression.h"
138 #include "value.h"
139 #include "parser-defs.h"
140 #include "language.h"
141 #include "p-lang.h"
142 #include "bfd.h" /* Required by objfiles.h. */
143 #include "symfile.h" /* Required by objfiles.h. */
144 #include "objfiles.h" /* For have_full_symbols and have_partial_symbols */
145 #include "block.h"
147 /* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc),
148 as well as gratuitiously global symbol names, so we can have multiple
149 yacc generated parsers in gdb. Note that these are only the variables
150 produced by yacc. If other parser generators (bison, byacc, etc) produce
151 additional global names that conflict at link time, then those parser
152 generators need to be fixed instead of adding those names to this list. */
154 #define yymaxdepth pascal_maxdepth
155 #define yyparse pascal_parse
156 #define yylex pascal_lex
157 #define yyerror pascal_error
158 #define yylval pascal_lval
159 #define yychar pascal_char
160 #define yydebug pascal_debug
161 #define yypact pascal_pact
162 #define yyr1 pascal_r1
163 #define yyr2 pascal_r2
164 #define yydef pascal_def
165 #define yychk pascal_chk
166 #define yypgo pascal_pgo
167 #define yyact pascal_act
168 #define yyexca pascal_exca
169 #define yyerrflag pascal_errflag
170 #define yynerrs pascal_nerrs
171 #define yyps pascal_ps
172 #define yypv pascal_pv
173 #define yys pascal_s
174 #define yy_yys pascal_yys
175 #define yystate pascal_state
176 #define yytmp pascal_tmp
177 #define yyv pascal_v
178 #define yy_yyv pascal_yyv
179 #define yyval pascal_val
180 #define yylloc pascal_lloc
181 #define yyreds pascal_reds /* With YYDEBUG defined */
182 #define yytoks pascal_toks /* With YYDEBUG defined */
183 #define yyname pascal_name /* With YYDEBUG defined */
184 #define yyrule pascal_rule /* With YYDEBUG defined */
185 #define yylhs pascal_yylhs
186 #define yylen pascal_yylen
187 #define yydefred pascal_yydefred
188 #define yydgoto pascal_yydgoto
189 #define yysindex pascal_yysindex
190 #define yyrindex pascal_yyrindex
191 #define yygindex pascal_yygindex
192 #define yytable pascal_yytable
193 #define yycheck pascal_yycheck
195 #ifndef YYDEBUG
196 #define YYDEBUG 1 /* Default to yydebug support */
197 #endif
199 #define YYFPRINTF parser_fprintf
201 int yyparse (void);
203 static int yylex (void);
205 void
206 yyerror (char *);
208 static char * uptok (char *, int);
211 /* Enabling traces. */
212 #ifndef YYDEBUG
213 # define YYDEBUG 0
214 #endif
216 /* Enabling verbose error messages. */
217 #ifdef YYERROR_VERBOSE
218 # undef YYERROR_VERBOSE
219 # define YYERROR_VERBOSE 1
220 #else
221 # define YYERROR_VERBOSE 0
222 #endif
224 #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
225 #line 131 "p-exp.y"
226 typedef union YYSTYPE {
227 LONGEST lval;
228 struct {
229 LONGEST val;
230 struct type *type;
231 } typed_val_int;
232 struct {
233 DOUBLEST dval;
234 struct type *type;
235 } typed_val_float;
236 struct symbol *sym;
237 struct type *tval;
238 struct stoken sval;
239 struct ttype tsym;
240 struct symtoken ssym;
241 int voidval;
242 struct block *bval;
243 enum exp_opcode opcode;
244 struct internalvar *ivar;
246 struct type **tvec;
247 int *ivec;
248 } YYSTYPE;
249 /* Line 191 of yacc.c. */
250 #line 251 "p-exp.c.tmp"
251 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
252 # define YYSTYPE_IS_DECLARED 1
253 # define YYSTYPE_IS_TRIVIAL 1
254 #endif
258 /* Copy the second part of user declarations. */
259 #line 155 "p-exp.y"
261 /* YYSTYPE gets defined by %union */
262 static int
263 parse_number (char *, int, int, YYSTYPE *);
265 static struct type *current_type;
267 static void push_current_type (void);
268 static void pop_current_type (void);
269 static int search_field;
272 /* Line 214 of yacc.c. */
273 #line 274 "p-exp.c.tmp"
275 #if ! defined (yyoverflow) || YYERROR_VERBOSE
277 # ifndef YYFREE
278 # define YYFREE free
279 # endif
280 # ifndef YYMALLOC
281 # define YYMALLOC xmalloc
282 # endif
284 /* The parser invokes alloca or xmalloc; define the necessary symbols. */
286 # ifdef YYSTACK_USE_ALLOCA
287 # if YYSTACK_USE_ALLOCA
288 # define YYSTACK_ALLOC alloca
289 # endif
290 # else
291 # if defined (alloca) || defined (_ALLOCA_H)
292 # define YYSTACK_ALLOC alloca
293 # else
294 # ifdef __GNUC__
295 # define YYSTACK_ALLOC __builtin_alloca
296 # endif
297 # endif
298 # endif
300 # ifdef YYSTACK_ALLOC
301 /* Pacify GCC's `empty if-body' warning. */
302 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
303 # else
304 # if defined (__STDC__) || defined (__cplusplus)
305 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
306 # define YYSIZE_T size_t
307 # endif
308 # define YYSTACK_ALLOC YYMALLOC
309 # define YYSTACK_FREE YYFREE
310 # endif
311 #endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
314 #if (! defined (yyoverflow) \
315 && (! defined (__cplusplus) \
316 || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL)))
318 /* A type that is properly aligned for any stack member. */
319 union yyalloc
321 short yyss;
322 YYSTYPE yyvs;
325 /* The size of the maximum gap between one aligned stack and the next. */
326 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
328 /* The size of an array large to enough to hold all stacks, each with
329 N elements. */
330 # define YYSTACK_BYTES(N) \
331 ((N) * (sizeof (short) + sizeof (YYSTYPE)) \
332 + YYSTACK_GAP_MAXIMUM)
334 /* Copy COUNT objects from FROM to TO. The source and destination do
335 not overlap. */
336 # ifndef YYCOPY
337 # if defined (__GNUC__) && 1 < __GNUC__
338 # define YYCOPY(To, From, Count) \
339 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
340 # else
341 # define YYCOPY(To, From, Count) \
342 do \
344 register YYSIZE_T yyi; \
345 for (yyi = 0; yyi < (Count); yyi++) \
346 (To)[yyi] = (From)[yyi]; \
348 while (0)
349 # endif
350 # endif
352 /* Relocate STACK from its old location to the new one. The
353 local variables YYSIZE and YYSTACKSIZE give the old and new number of
354 elements in the stack, and YYPTR gives the new location of the
355 stack. Advance YYPTR to a properly aligned location for the next
356 stack. */
357 # define YYSTACK_RELOCATE(Stack) \
358 do \
360 YYSIZE_T yynewbytes; \
361 YYCOPY (&yyptr->Stack, Stack, yysize); \
362 Stack = &yyptr->Stack; \
363 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
364 yyptr += yynewbytes / sizeof (*yyptr); \
366 while (0)
368 #endif
370 #if defined (__STDC__) || defined (__cplusplus)
371 typedef signed char yysigned_char;
372 #else
373 typedef short yysigned_char;
374 #endif
376 /* YYFINAL -- State number of the termination state. */
377 #define YYFINAL 3
378 /* YYLAST -- Last index in YYTABLE. */
379 #define YYLAST 359
381 /* YYNTOKENS -- Number of terminals. */
382 #define YYNTOKENS 52
383 /* YYNNTS -- Number of nonterminals. */
384 #define YYNNTS 19
385 /* YYNRULES -- Number of rules. */
386 #define YYNRULES 73
387 /* YYNRULES -- Number of states. */
388 #define YYNSTATES 123
390 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
391 #define YYUNDEFTOK 2
392 #define YYMAXUTOK 291
394 #define YYTRANSLATE(YYX) \
395 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
397 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
398 static const unsigned char yytranslate[] =
400 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
401 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
402 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
403 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
404 46, 50, 39, 37, 19, 38, 44, 40, 2, 2,
405 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
406 28, 26, 29, 2, 36, 2, 2, 2, 2, 2,
407 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
408 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
409 2, 45, 2, 51, 48, 2, 2, 2, 2, 2,
410 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
411 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
412 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
413 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
414 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
415 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
416 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
417 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
418 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
419 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
420 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
421 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
422 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
423 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
424 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
425 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
426 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
427 15, 16, 17, 18, 20, 21, 22, 23, 24, 25,
428 27, 30, 31, 32, 33, 34, 35, 41, 42, 43,
429 47, 49
432 #if YYDEBUG
433 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
434 YYRHS. */
435 static const unsigned char yyprhs[] =
437 0, 0, 3, 4, 7, 9, 11, 13, 15, 19,
438 22, 25, 28, 31, 36, 41, 42, 47, 48, 54,
439 55, 61, 62, 64, 68, 73, 77, 81, 85, 89,
440 93, 97, 101, 105, 109, 113, 117, 121, 125, 129,
441 133, 137, 141, 145, 149, 151, 153, 155, 157, 159,
442 161, 163, 168, 170, 172, 174, 178, 182, 186, 188,
443 191, 193, 195, 197, 201, 204, 206, 209, 212, 214,
444 216, 218, 220, 222
447 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
448 static const yysigned_char yyrhs[] =
450 53, 0, -1, -1, 54, 55, -1, 57, -1, 56,
451 -1, 67, -1, 58, -1, 57, 19, 58, -1, 58,
452 48, -1, 36, 58, -1, 38, 58, -1, 22, 58,
453 -1, 42, 46, 58, 50, -1, 41, 46, 58, 50,
454 -1, -1, 58, 44, 59, 6, -1, -1, 58, 45,
455 60, 57, 51, -1, -1, 58, 46, 61, 62, 50,
456 -1, -1, 58, -1, 62, 19, 58, -1, 67, 46,
457 58, 50, -1, 46, 57, 50, -1, 58, 39, 58,
458 -1, 58, 40, 58, -1, 58, 33, 58, -1, 58,
459 32, 58, -1, 58, 37, 58, -1, 58, 38, 58,
460 -1, 58, 35, 58, -1, 58, 34, 58, -1, 58,
461 26, 58, -1, 58, 27, 58, -1, 58, 31, 58,
462 -1, 58, 30, 58, -1, 58, 28, 58, -1, 58,
463 29, 58, -1, 58, 25, 58, -1, 58, 24, 58,
464 -1, 58, 23, 58, -1, 58, 21, 58, -1, 17,
465 -1, 18, -1, 3, -1, 9, -1, 4, -1, 64,
466 -1, 15, -1, 12, 46, 67, 50, -1, 5, -1,
467 16, -1, 49, -1, 63, 13, 69, -1, 63, 13,
468 69, -1, 68, 13, 69, -1, 65, -1, 13, 69,
469 -1, 70, -1, 68, -1, 66, -1, 68, 13, 39,
470 -1, 48, 68, -1, 8, -1, 10, 69, -1, 11,
471 69, -1, 7, -1, 49, -1, 8, -1, 9, -1,
472 7, -1, 49, -1
475 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
476 static const unsigned short yyrline[] =
478 0, 235, 235, 235, 242, 243, 246, 253, 254, 259,
479 265, 271, 275, 279, 283, 287, 287, 302, 300, 330,
480 327, 339, 340, 342, 346, 361, 367, 371, 375, 379,
481 383, 387, 391, 395, 399, 403, 407, 411, 415, 419,
482 423, 427, 431, 435, 439, 445, 451, 458, 469, 476,
483 479, 483, 491, 516, 543, 560, 571, 587, 602, 603,
484 637, 709, 720, 721, 726, 728, 730, 733, 741, 742,
485 743, 744, 747, 748
487 #endif
489 #if YYDEBUG || YYERROR_VERBOSE
490 /* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
491 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
492 static const char *const yytname[] =
494 "$end", "error", "$undefined", "INT", "FLOAT", "STRING", "FIELDNAME",
495 "NAME", "TYPENAME", "NAME_OR_INT", "STRUCT", "CLASS", "SIZEOF",
496 "COLONCOLON", "ERROR", "VARIABLE", "THIS", "TRUEKEYWORD", "FALSEKEYWORD",
497 "','", "ABOVE_COMMA", "ASSIGN", "NOT", "OR", "XOR", "ANDAND", "'='",
498 "NOTEQUAL", "'<'", "'>'", "GEQ", "LEQ", "MOD", "DIV", "RSH", "LSH",
499 "'@'", "'+'", "'-'", "'*'", "'/'", "DECREMENT", "INCREMENT", "UNARY",
500 "'.'", "'['", "'('", "ARROW", "'^'", "BLOCKNAME", "')'", "']'",
501 "$accept", "start", "@1", "normal_start", "type_exp", "exp1", "exp",
502 "@2", "@3", "@4", "arglist", "block", "variable", "qualified_name",
503 "ptype", "type", "typebase", "name", "name_not_typename", 0
505 #endif
507 # ifdef YYPRINT
508 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
509 token YYLEX-NUM. */
510 static const unsigned short yytoknum[] =
512 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
513 265, 266, 267, 268, 269, 270, 271, 272, 273, 44,
514 274, 275, 276, 277, 278, 279, 61, 280, 60, 62,
515 281, 282, 283, 284, 285, 286, 64, 43, 45, 42,
516 47, 287, 288, 289, 46, 91, 40, 290, 94, 291,
517 41, 93
519 # endif
521 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
522 static const unsigned char yyr1[] =
524 0, 52, 54, 53, 55, 55, 56, 57, 57, 58,
525 58, 58, 58, 58, 58, 59, 58, 60, 58, 61,
526 58, 62, 62, 62, 58, 58, 58, 58, 58, 58,
527 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
528 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
529 58, 58, 58, 58, 63, 63, 64, 65, 64, 64,
530 64, 66, 67, 67, 68, 68, 68, 68, 69, 69,
531 69, 69, 70, 70
534 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
535 static const unsigned char yyr2[] =
537 0, 2, 0, 2, 1, 1, 1, 1, 3, 2,
538 2, 2, 2, 4, 4, 0, 4, 0, 5, 0,
539 5, 0, 1, 3, 4, 3, 3, 3, 3, 3,
540 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
541 3, 3, 3, 3, 1, 1, 1, 1, 1, 1,
542 1, 4, 1, 1, 1, 3, 3, 3, 1, 2,
543 1, 1, 1, 3, 2, 1, 2, 2, 1, 1,
544 1, 1, 1, 1
547 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
548 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
549 means the default is an error. */
550 static const unsigned char yydefact[] =
552 2, 0, 0, 1, 46, 48, 52, 72, 65, 47,
553 0, 0, 0, 0, 50, 53, 44, 45, 0, 0,
554 0, 0, 0, 0, 0, 73, 3, 5, 4, 7,
555 0, 49, 58, 62, 6, 61, 60, 68, 70, 71,
556 69, 66, 67, 0, 59, 12, 0, 10, 11, 0,
557 0, 0, 64, 0, 0, 0, 0, 0, 0, 0,
558 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
559 0, 0, 15, 17, 19, 9, 0, 0, 0, 0,
560 61, 0, 0, 25, 8, 43, 42, 41, 40, 34,
561 35, 38, 39, 37, 36, 29, 28, 33, 32, 30,
562 31, 26, 27, 0, 0, 21, 56, 0, 63, 57,
563 51, 0, 14, 13, 16, 0, 22, 0, 24, 18,
564 0, 20, 23
567 /* YYDEFGOTO[NTERM-NUM]. */
568 static const yysigned_char yydefgoto[] =
570 -1, 1, 2, 26, 27, 28, 29, 103, 104, 105,
571 117, 30, 31, 32, 33, 46, 35, 41, 36
574 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
575 STATE-NUM. */
576 #define YYPACT_NINF -37
577 static const short yypact[] =
579 -37, 5, 88, -37, -37, -37, -37, -37, -37, -37,
580 6, 6, -35, 6, -37, -37, -37, -37, 88, 88,
581 88, -29, -27, 88, 10, 12, -37, -37, 8, 201,
582 16, -37, -37, -37, -13, 21, -37, -37, -37, -37,
583 -37, -37, -37, 10, -37, -36, -13, -36, -36, 88,
584 88, 11, -37, 88, 88, 88, 88, 88, 88, 88,
585 88, 88, 88, 88, 88, 88, 88, 88, 88, 88,
586 88, 88, -37, -37, -37, -37, 6, 88, 15, 20,
587 43, 117, 145, -37, 201, 201, 226, 250, 273, 294,
588 294, 311, 311, 311, 311, 28, 28, 28, 28, 68,
589 68, -36, -36, 56, 88, 88, 62, 173, -37, -37,
590 -37, 38, -37, -37, -37, 9, 201, 44, -37, -37,
591 88, -37, 201
594 /* YYPGOTO[NTERM-NUM]. */
595 static const yysigned_char yypgoto[] =
597 -37, -37, -37, -37, -37, -20, -18, -37, -37, -37,
598 -37, -37, -37, -37, -37, 14, -17, -7, -37
601 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
602 positive, shift that token. If negative, reduce the rule which
603 number is the opposite. If zero, do what YYDEFACT says.
604 If YYTABLE_NINF, syntax error. */
605 #define YYTABLE_NINF -56
606 static const yysigned_char yytable[] =
608 45, 47, 48, 51, 42, 3, 44, 52, 72, 73,
609 74, 43, 75, 37, 38, 39, 34, 49, 8, 50,
610 10, 11, 37, 38, 39, -54, 80, 53, 53, 76,
611 53, 81, 82, 77, 78, 84, 85, 86, 87, 88,
612 89, 90, 91, 92, 93, 94, 95, 96, 97, 98,
613 99, 100, 101, 102, 108, 40, 111, 79, 24, 107,
614 119, 83, 114, 120, 40, 68, 69, 70, 71, 106,
615 110, 109, 72, 73, 74, -55, 75, 108, 0, 0,
616 0, 0, 0, 0, 115, 0, 0, 116, 0, 0,
617 0, 4, 5, 6, 121, 7, 8, 9, 10, 11,
618 12, 13, 122, 14, 15, 16, 17, 70, 71, 0,
619 18, 0, 72, 73, 74, 0, 75, 0, 0, 0,
620 0, 0, 0, 0, 19, 0, 20, 0, 0, 21,
621 22, 0, 0, 0, 23, 0, 24, 25, 54, 0,
622 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
623 65, 66, 67, 0, 68, 69, 70, 71, 0, 0,
624 0, 72, 73, 74, 0, 75, 54, 112, 55, 56,
625 57, 58, 59, 60, 61, 62, 63, 64, 65, 66,
626 67, 0, 68, 69, 70, 71, 0, 0, 0, 72,
627 73, 74, 0, 75, 54, 113, 55, 56, 57, 58,
628 59, 60, 61, 62, 63, 64, 65, 66, 67, 0,
629 68, 69, 70, 71, 0, 0, 0, 72, 73, 74,
630 0, 75, 54, 118, 55, 56, 57, 58, 59, 60,
631 61, 62, 63, 64, 65, 66, 67, 0, 68, 69,
632 70, 71, 0, 0, 0, 72, 73, 74, 0, 75,
633 56, 57, 58, 59, 60, 61, 62, 63, 64, 65,
634 66, 67, 0, 68, 69, 70, 71, 0, 0, 0,
635 72, 73, 74, 0, 75, 57, 58, 59, 60, 61,
636 62, 63, 64, 65, 66, 67, 0, 68, 69, 70,
637 71, 0, 0, 0, 72, 73, 74, 0, 75, 58,
638 59, 60, 61, 62, 63, 64, 65, 66, 67, 0,
639 68, 69, 70, 71, 0, 0, 0, 72, 73, 74,
640 0, 75, 60, 61, 62, 63, 64, 65, 66, 67,
641 0, 68, 69, 70, 71, 0, 0, 0, 72, 73,
642 74, 0, 75, 64, 65, 66, 67, 0, 68, 69,
643 70, 71, 0, 0, 0, 72, 73, 74, 0, 75
646 static const yysigned_char yycheck[] =
648 18, 19, 20, 23, 11, 0, 13, 24, 44, 45,
649 46, 46, 48, 7, 8, 9, 2, 46, 8, 46,
650 10, 11, 7, 8, 9, 13, 43, 19, 19, 13,
651 19, 49, 50, 46, 13, 53, 54, 55, 56, 57,
652 58, 59, 60, 61, 62, 63, 64, 65, 66, 67,
653 68, 69, 70, 71, 39, 49, 13, 43, 48, 77,
654 51, 50, 6, 19, 49, 37, 38, 39, 40, 76,
655 50, 78, 44, 45, 46, 13, 48, 39, -1, -1,
656 -1, -1, -1, -1, 104, -1, -1, 105, -1, -1,
657 -1, 3, 4, 5, 50, 7, 8, 9, 10, 11,
658 12, 13, 120, 15, 16, 17, 18, 39, 40, -1,
659 22, -1, 44, 45, 46, -1, 48, -1, -1, -1,
660 -1, -1, -1, -1, 36, -1, 38, -1, -1, 41,
661 42, -1, -1, -1, 46, -1, 48, 49, 21, -1,
662 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
663 33, 34, 35, -1, 37, 38, 39, 40, -1, -1,
664 -1, 44, 45, 46, -1, 48, 21, 50, 23, 24,
665 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
666 35, -1, 37, 38, 39, 40, -1, -1, -1, 44,
667 45, 46, -1, 48, 21, 50, 23, 24, 25, 26,
668 27, 28, 29, 30, 31, 32, 33, 34, 35, -1,
669 37, 38, 39, 40, -1, -1, -1, 44, 45, 46,
670 -1, 48, 21, 50, 23, 24, 25, 26, 27, 28,
671 29, 30, 31, 32, 33, 34, 35, -1, 37, 38,
672 39, 40, -1, -1, -1, 44, 45, 46, -1, 48,
673 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
674 34, 35, -1, 37, 38, 39, 40, -1, -1, -1,
675 44, 45, 46, -1, 48, 25, 26, 27, 28, 29,
676 30, 31, 32, 33, 34, 35, -1, 37, 38, 39,
677 40, -1, -1, -1, 44, 45, 46, -1, 48, 26,
678 27, 28, 29, 30, 31, 32, 33, 34, 35, -1,
679 37, 38, 39, 40, -1, -1, -1, 44, 45, 46,
680 -1, 48, 28, 29, 30, 31, 32, 33, 34, 35,
681 -1, 37, 38, 39, 40, -1, -1, -1, 44, 45,
682 46, -1, 48, 32, 33, 34, 35, -1, 37, 38,
683 39, 40, -1, -1, -1, 44, 45, 46, -1, 48
686 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
687 symbol of state STATE-NUM. */
688 static const unsigned char yystos[] =
690 0, 53, 54, 0, 3, 4, 5, 7, 8, 9,
691 10, 11, 12, 13, 15, 16, 17, 18, 22, 36,
692 38, 41, 42, 46, 48, 49, 55, 56, 57, 58,
693 63, 64, 65, 66, 67, 68, 70, 7, 8, 9,
694 49, 69, 69, 46, 69, 58, 67, 58, 58, 46,
695 46, 57, 68, 19, 21, 23, 24, 25, 26, 27,
696 28, 29, 30, 31, 32, 33, 34, 35, 37, 38,
697 39, 40, 44, 45, 46, 48, 13, 46, 13, 67,
698 68, 58, 58, 50, 58, 58, 58, 58, 58, 58,
699 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
700 58, 58, 58, 59, 60, 61, 69, 58, 39, 69,
701 50, 13, 50, 50, 6, 57, 58, 62, 50, 51,
702 19, 50, 58
705 #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
706 # define YYSIZE_T __SIZE_TYPE__
707 #endif
708 #if ! defined (YYSIZE_T) && defined (size_t)
709 # define YYSIZE_T size_t
710 #endif
711 #if ! defined (YYSIZE_T)
712 # if defined (__STDC__) || defined (__cplusplus)
713 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
714 # define YYSIZE_T size_t
715 # endif
716 #endif
717 #if ! defined (YYSIZE_T)
718 # define YYSIZE_T unsigned int
719 #endif
721 #define yyerrok (yyerrstatus = 0)
722 #define yyclearin (yychar = YYEMPTY)
723 #define YYEMPTY (-2)
724 #define YYEOF 0
726 #define YYACCEPT goto yyacceptlab
727 #define YYABORT goto yyabortlab
728 #define YYERROR goto yyerrorlab
731 /* Like YYERROR except do call yyerror. This remains here temporarily
732 to ease the transition to the new meaning of YYERROR, for GCC.
733 Once GCC version 2 has supplanted version 1, this can go. */
735 #define YYFAIL goto yyerrlab
737 #define YYRECOVERING() (!!yyerrstatus)
739 #define YYBACKUP(Token, Value) \
740 do \
741 if (yychar == YYEMPTY && yylen == 1) \
743 yychar = (Token); \
744 yylval = (Value); \
745 yytoken = YYTRANSLATE (yychar); \
746 YYPOPSTACK; \
747 goto yybackup; \
749 else \
751 yyerror ("syntax error: cannot back up");\
752 YYERROR; \
754 while (0)
756 #define YYTERROR 1
757 #define YYERRCODE 256
759 /* YYLLOC_DEFAULT -- Compute the default location (before the actions
760 are run). */
762 #ifndef YYLLOC_DEFAULT
763 # define YYLLOC_DEFAULT(Current, Rhs, N) \
764 ((Current).first_line = (Rhs)[1].first_line, \
765 (Current).first_column = (Rhs)[1].first_column, \
766 (Current).last_line = (Rhs)[N].last_line, \
767 (Current).last_column = (Rhs)[N].last_column)
768 #endif
770 /* YYLEX -- calling `yylex' with the right arguments. */
772 #ifdef YYLEX_PARAM
773 # define YYLEX yylex (YYLEX_PARAM)
774 #else
775 # define YYLEX yylex ()
776 #endif
778 /* Enable debugging if requested. */
779 #if YYDEBUG
781 # ifndef YYFPRINTF
782 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
783 # define YYFPRINTF fprintf
784 # endif
786 # define YYDPRINTF(Args) \
787 do { \
788 if (yydebug) \
789 YYFPRINTF Args; \
790 } while (0)
792 # define YYDSYMPRINT(Args) \
793 do { \
794 if (yydebug) \
795 yysymprint Args; \
796 } while (0)
798 # define YYDSYMPRINTF(Title, Token, Value, Location) \
799 do { \
800 if (yydebug) \
802 YYFPRINTF (stderr, "%s ", Title); \
803 yysymprint (stderr, \
804 Token, Value); \
805 YYFPRINTF (stderr, "\n"); \
807 } while (0)
809 /*------------------------------------------------------------------.
810 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
811 | TOP (included). |
812 `------------------------------------------------------------------*/
814 #if defined (__STDC__) || defined (__cplusplus)
815 static void
816 yy_stack_print (short *bottom, short *top)
817 #else
818 static void
819 yy_stack_print (bottom, top)
820 short *bottom;
821 short *top;
822 #endif
824 YYFPRINTF (stderr, "Stack now");
825 for (/* Nothing. */; bottom <= top; ++bottom)
826 YYFPRINTF (stderr, " %d", *bottom);
827 YYFPRINTF (stderr, "\n");
830 # define YY_STACK_PRINT(Bottom, Top) \
831 do { \
832 if (yydebug) \
833 yy_stack_print ((Bottom), (Top)); \
834 } while (0)
837 /*------------------------------------------------.
838 | Report that the YYRULE is going to be reduced. |
839 `------------------------------------------------*/
841 #if defined (__STDC__) || defined (__cplusplus)
842 static void
843 yy_reduce_print (int yyrule)
844 #else
845 static void
846 yy_reduce_print (yyrule)
847 int yyrule;
848 #endif
850 int yyi;
851 unsigned int yylno = yyrline[yyrule];
852 YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ",
853 yyrule - 1, yylno);
854 /* Print the symbols being reduced, and their result. */
855 for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
856 YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]);
857 YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]);
860 # define YY_REDUCE_PRINT(Rule) \
861 do { \
862 if (yydebug) \
863 yy_reduce_print (Rule); \
864 } while (0)
866 /* Nonzero means print parse trace. It is left uninitialized so that
867 multiple parsers can coexist. */
868 int yydebug;
869 #else /* !YYDEBUG */
870 # define YYDPRINTF(Args)
871 # define YYDSYMPRINT(Args)
872 # define YYDSYMPRINTF(Title, Token, Value, Location)
873 # define YY_STACK_PRINT(Bottom, Top)
874 # define YY_REDUCE_PRINT(Rule)
875 #endif /* !YYDEBUG */
878 /* YYINITDEPTH -- initial size of the parser's stacks. */
879 #ifndef YYINITDEPTH
880 # define YYINITDEPTH 200
881 #endif
883 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
884 if the built-in stack extension method is used).
886 Do not make this value too large; the results are undefined if
887 SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
888 evaluated with infinite-precision integer arithmetic. */
890 #if defined (YYMAXDEPTH) && YYMAXDEPTH == 0
891 # undef YYMAXDEPTH
892 #endif
894 #ifndef YYMAXDEPTH
895 # define YYMAXDEPTH 10000
896 #endif
900 #if YYERROR_VERBOSE
902 # ifndef yystrlen
903 # if defined (__GLIBC__) && defined (_STRING_H)
904 # define yystrlen strlen
905 # else
906 /* Return the length of YYSTR. */
907 static YYSIZE_T
908 # if defined (__STDC__) || defined (__cplusplus)
909 yystrlen (const char *yystr)
910 # else
911 yystrlen (yystr)
912 const char *yystr;
913 # endif
915 register const char *yys = yystr;
917 while (*yys++ != '\0')
918 continue;
920 return yys - yystr - 1;
922 # endif
923 # endif
925 # ifndef yystpcpy
926 # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
927 # define yystpcpy stpcpy
928 # else
929 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
930 YYDEST. */
931 static char *
932 # if defined (__STDC__) || defined (__cplusplus)
933 yystpcpy (char *yydest, const char *yysrc)
934 # else
935 yystpcpy (yydest, yysrc)
936 char *yydest;
937 const char *yysrc;
938 # endif
940 register char *yyd = yydest;
941 register const char *yys = yysrc;
943 while ((*yyd++ = *yys++) != '\0')
944 continue;
946 return yyd - 1;
948 # endif
949 # endif
951 #endif /* !YYERROR_VERBOSE */
955 #if YYDEBUG
956 /*--------------------------------.
957 | Print this symbol on YYOUTPUT. |
958 `--------------------------------*/
960 #if defined (__STDC__) || defined (__cplusplus)
961 static void
962 yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep)
963 #else
964 static void
965 yysymprint (yyoutput, yytype, yyvaluep)
966 FILE *yyoutput;
967 int yytype;
968 YYSTYPE *yyvaluep;
969 #endif
971 /* Pacify ``unused variable'' warnings. */
972 (void) yyvaluep;
974 if (yytype < YYNTOKENS)
976 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
977 # ifdef YYPRINT
978 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
979 # endif
981 else
982 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
984 switch (yytype)
986 default:
987 break;
989 YYFPRINTF (yyoutput, ")");
992 #endif /* ! YYDEBUG */
993 /*-----------------------------------------------.
994 | Release the memory associated to this symbol. |
995 `-----------------------------------------------*/
997 #if defined (__STDC__) || defined (__cplusplus)
998 static void
999 yydestruct (int yytype, YYSTYPE *yyvaluep)
1000 #else
1001 static void
1002 yydestruct (yytype, yyvaluep)
1003 int yytype;
1004 YYSTYPE *yyvaluep;
1005 #endif
1007 /* Pacify ``unused variable'' warnings. */
1008 (void) yyvaluep;
1010 switch (yytype)
1013 default:
1014 break;
1019 /* Prevent warnings from -Wmissing-prototypes. */
1021 #ifdef YYPARSE_PARAM
1022 # if defined (__STDC__) || defined (__cplusplus)
1023 int yyparse (void *YYPARSE_PARAM);
1024 # else
1025 int yyparse ();
1026 # endif
1027 #else /* ! YYPARSE_PARAM */
1028 #if defined (__STDC__) || defined (__cplusplus)
1029 int yyparse (void);
1030 #else
1031 int yyparse ();
1032 #endif
1033 #endif /* ! YYPARSE_PARAM */
1037 /* The lookahead symbol. */
1038 int yychar;
1040 /* The semantic value of the lookahead symbol. */
1041 YYSTYPE yylval;
1043 /* Number of syntax errors so far. */
1044 int yynerrs;
1048 /*----------.
1049 | yyparse. |
1050 `----------*/
1052 #ifdef YYPARSE_PARAM
1053 # if defined (__STDC__) || defined (__cplusplus)
1054 int yyparse (void *YYPARSE_PARAM)
1055 # else
1056 int yyparse (YYPARSE_PARAM)
1057 void *YYPARSE_PARAM;
1058 # endif
1059 #else /* ! YYPARSE_PARAM */
1060 #if defined (__STDC__) || defined (__cplusplus)
1062 yyparse (void)
1063 #else
1065 yyparse ()
1067 #endif
1068 #endif
1071 register int yystate;
1072 register int yyn;
1073 int yyresult;
1074 /* Number of tokens to shift before error messages enabled. */
1075 int yyerrstatus;
1076 /* Lookahead token as an internal (translated) token number. */
1077 int yytoken = 0;
1079 /* Three stacks and their tools:
1080 `yyss': related to states,
1081 `yyvs': related to semantic values,
1082 `yyls': related to locations.
1084 Refer to the stacks thru separate pointers, to allow yyoverflow
1085 to xreallocate them elsewhere. */
1087 /* The state stack. */
1088 short yyssa[YYINITDEPTH];
1089 short *yyss = yyssa;
1090 register short *yyssp;
1092 /* The semantic value stack. */
1093 YYSTYPE yyvsa[YYINITDEPTH];
1094 YYSTYPE *yyvs = yyvsa;
1095 register YYSTYPE *yyvsp;
1099 #define YYPOPSTACK (yyvsp--, yyssp--)
1101 YYSIZE_T yystacksize = YYINITDEPTH;
1103 /* The variables used to return semantic value and location from the
1104 action routines. */
1105 YYSTYPE yyval;
1108 /* When reducing, the number of symbols on the RHS of the reduced
1109 rule. */
1110 int yylen;
1112 YYDPRINTF ((stderr, "Starting parse\n"));
1114 yystate = 0;
1115 yyerrstatus = 0;
1116 yynerrs = 0;
1117 yychar = YYEMPTY; /* Cause a token to be read. */
1119 /* Initialize stack pointers.
1120 Waste one element of value and location stack
1121 so that they stay on the same level as the state stack.
1122 The wasted elements are never initialized. */
1124 yyssp = yyss;
1125 yyvsp = yyvs;
1127 goto yysetstate;
1129 /*------------------------------------------------------------.
1130 | yynewstate -- Push a new state, which is found in yystate. |
1131 `------------------------------------------------------------*/
1132 yynewstate:
1133 /* In all cases, when you get here, the value and location stacks
1134 have just been pushed. so pushing a state here evens the stacks.
1136 yyssp++;
1138 yysetstate:
1139 *yyssp = yystate;
1141 if (yyss + yystacksize - 1 <= yyssp)
1143 /* Get the current used size of the three stacks, in elements. */
1144 YYSIZE_T yysize = yyssp - yyss + 1;
1146 #ifdef yyoverflow
1148 /* Give user a chance to xreallocate the stack. Use copies of
1149 these so that the &'s don't force the real ones into
1150 memory. */
1151 YYSTYPE *yyvs1 = yyvs;
1152 short *yyss1 = yyss;
1155 /* Each stack pointer address is followed by the size of the
1156 data in use in that stack, in bytes. This used to be a
1157 conditional around just the two extra args, but that might
1158 be undefined if yyoverflow is a macro. */
1159 yyoverflow ("parser stack overflow",
1160 &yyss1, yysize * sizeof (*yyssp),
1161 &yyvs1, yysize * sizeof (*yyvsp),
1163 &yystacksize);
1165 yyss = yyss1;
1166 yyvs = yyvs1;
1168 #else /* no yyoverflow */
1169 # ifndef YYSTACK_RELOCATE
1170 goto yyoverflowlab;
1171 # else
1172 /* Extend the stack our own way. */
1173 if (YYMAXDEPTH <= yystacksize)
1174 goto yyoverflowlab;
1175 yystacksize *= 2;
1176 if (YYMAXDEPTH < yystacksize)
1177 yystacksize = YYMAXDEPTH;
1180 short *yyss1 = yyss;
1181 union yyalloc *yyptr =
1182 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1183 if (! yyptr)
1184 goto yyoverflowlab;
1185 YYSTACK_RELOCATE (yyss);
1186 YYSTACK_RELOCATE (yyvs);
1188 # undef YYSTACK_RELOCATE
1189 if (yyss1 != yyssa)
1190 YYSTACK_FREE (yyss1);
1192 # endif
1193 #endif /* no yyoverflow */
1195 yyssp = yyss + yysize - 1;
1196 yyvsp = yyvs + yysize - 1;
1199 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1200 (unsigned long int) yystacksize));
1202 if (yyss + yystacksize - 1 <= yyssp)
1203 YYABORT;
1206 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1208 goto yybackup;
1210 /*-----------.
1211 | yybackup. |
1212 `-----------*/
1213 yybackup:
1215 /* Do appropriate processing given the current state. */
1216 /* Read a lookahead token if we need one and don't already have one. */
1217 /* yyresume: */
1219 /* First try to decide what to do without reference to lookahead token. */
1221 yyn = yypact[yystate];
1222 if (yyn == YYPACT_NINF)
1223 goto yydefault;
1225 /* Not known => get a lookahead token if don't already have one. */
1227 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1228 if (yychar == YYEMPTY)
1230 YYDPRINTF ((stderr, "Reading a token: "));
1231 yychar = YYLEX;
1234 if (yychar <= YYEOF)
1236 yychar = yytoken = YYEOF;
1237 YYDPRINTF ((stderr, "Now at end of input.\n"));
1239 else
1241 yytoken = YYTRANSLATE (yychar);
1242 YYDSYMPRINTF ("Next token is", yytoken, &yylval, &yylloc);
1245 /* If the proper action on seeing token YYTOKEN is to reduce or to
1246 detect an error, take that action. */
1247 yyn += yytoken;
1248 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1249 goto yydefault;
1250 yyn = yytable[yyn];
1251 if (yyn <= 0)
1253 if (yyn == 0 || yyn == YYTABLE_NINF)
1254 goto yyerrlab;
1255 yyn = -yyn;
1256 goto yyreduce;
1259 if (yyn == YYFINAL)
1260 YYACCEPT;
1262 /* Shift the lookahead token. */
1263 YYDPRINTF ((stderr, "Shifting token %s, ", yytname[yytoken]));
1265 /* Discard the token being shifted unless it is eof. */
1266 if (yychar != YYEOF)
1267 yychar = YYEMPTY;
1269 *++yyvsp = yylval;
1272 /* Count tokens shifted since error; after three, turn off error
1273 status. */
1274 if (yyerrstatus)
1275 yyerrstatus--;
1277 yystate = yyn;
1278 goto yynewstate;
1281 /*-----------------------------------------------------------.
1282 | yydefault -- do the default action for the current state. |
1283 `-----------------------------------------------------------*/
1284 yydefault:
1285 yyn = yydefact[yystate];
1286 if (yyn == 0)
1287 goto yyerrlab;
1288 goto yyreduce;
1291 /*-----------------------------.
1292 | yyreduce -- Do a reduction. |
1293 `-----------------------------*/
1294 yyreduce:
1295 /* yyn is the number of a rule to reduce with. */
1296 yylen = yyr2[yyn];
1298 /* If YYLEN is nonzero, implement the default value of the action:
1299 `$$ = $1'.
1301 Otherwise, the following line sets YYVAL to garbage.
1302 This behavior is undocumented and Bison
1303 users should not rely upon it. Assigning to YYVAL
1304 unconditionally makes the parser a bit smaller, and it avoids a
1305 GCC warning that YYVAL may be used uninitialized. */
1306 yyval = yyvsp[1-yylen];
1309 YY_REDUCE_PRINT (yyn);
1310 switch (yyn)
1312 case 2:
1313 #line 235 "p-exp.y"
1314 { current_type = NULL;
1315 search_field = 0;
1317 break;
1319 case 3:
1320 #line 238 "p-exp.y"
1322 break;
1324 case 6:
1325 #line 247 "p-exp.y"
1326 { write_exp_elt_opcode(OP_TYPE);
1327 write_exp_elt_type(yyvsp[0].tval);
1328 write_exp_elt_opcode(OP_TYPE);
1329 current_type = yyvsp[0].tval; }
1330 break;
1332 case 8:
1333 #line 255 "p-exp.y"
1334 { write_exp_elt_opcode (BINOP_COMMA); }
1335 break;
1337 case 9:
1338 #line 260 "p-exp.y"
1339 { write_exp_elt_opcode (UNOP_IND);
1340 if (current_type)
1341 current_type = TYPE_TARGET_TYPE (current_type); }
1342 break;
1344 case 10:
1345 #line 266 "p-exp.y"
1346 { write_exp_elt_opcode (UNOP_ADDR);
1347 if (current_type)
1348 current_type = TYPE_POINTER_TYPE (current_type); }
1349 break;
1351 case 11:
1352 #line 272 "p-exp.y"
1353 { write_exp_elt_opcode (UNOP_NEG); }
1354 break;
1356 case 12:
1357 #line 276 "p-exp.y"
1358 { write_exp_elt_opcode (UNOP_LOGICAL_NOT); }
1359 break;
1361 case 13:
1362 #line 280 "p-exp.y"
1363 { write_exp_elt_opcode (UNOP_PREINCREMENT); }
1364 break;
1366 case 14:
1367 #line 284 "p-exp.y"
1368 { write_exp_elt_opcode (UNOP_PREDECREMENT); }
1369 break;
1371 case 15:
1372 #line 287 "p-exp.y"
1373 { search_field = 1; }
1374 break;
1376 case 16:
1377 #line 290 "p-exp.y"
1378 { write_exp_elt_opcode (STRUCTOP_STRUCT);
1379 write_exp_string (yyvsp[0].sval);
1380 write_exp_elt_opcode (STRUCTOP_STRUCT);
1381 search_field = 0;
1382 if (current_type)
1383 { while (TYPE_CODE (current_type) == TYPE_CODE_PTR)
1384 current_type = TYPE_TARGET_TYPE (current_type);
1385 current_type = lookup_struct_elt_type (
1386 current_type, yyvsp[0].sval.ptr, 0); };
1388 break;
1390 case 17:
1391 #line 302 "p-exp.y"
1392 { char *arrayname;
1393 int arrayfieldindex;
1394 arrayfieldindex = is_pascal_string_type (
1395 current_type, NULL, NULL,
1396 NULL, NULL, &arrayname);
1397 if (arrayfieldindex)
1399 struct stoken stringsval;
1400 stringsval.ptr = alloca (strlen (arrayname) + 1);
1401 stringsval.length = strlen (arrayname);
1402 strcpy (stringsval.ptr, arrayname);
1403 current_type = TYPE_FIELD_TYPE (current_type,
1404 arrayfieldindex - 1);
1405 write_exp_elt_opcode (STRUCTOP_STRUCT);
1406 write_exp_string (stringsval);
1407 write_exp_elt_opcode (STRUCTOP_STRUCT);
1409 push_current_type (); }
1410 break;
1412 case 18:
1413 #line 321 "p-exp.y"
1414 { pop_current_type ();
1415 write_exp_elt_opcode (BINOP_SUBSCRIPT);
1416 if (current_type)
1417 current_type = TYPE_TARGET_TYPE (current_type); }
1418 break;
1420 case 19:
1421 #line 330 "p-exp.y"
1422 { push_current_type ();
1423 start_arglist (); }
1424 break;
1426 case 20:
1427 #line 333 "p-exp.y"
1428 { write_exp_elt_opcode (OP_FUNCALL);
1429 write_exp_elt_longcst ((LONGEST) end_arglist ());
1430 write_exp_elt_opcode (OP_FUNCALL);
1431 pop_current_type (); }
1432 break;
1434 case 22:
1435 #line 341 "p-exp.y"
1436 { arglist_len = 1; }
1437 break;
1439 case 23:
1440 #line 343 "p-exp.y"
1441 { arglist_len++; }
1442 break;
1444 case 24:
1445 #line 347 "p-exp.y"
1446 { if (current_type)
1448 /* Allow automatic dereference of classes. */
1449 if ((TYPE_CODE (current_type) == TYPE_CODE_PTR)
1450 && (TYPE_CODE (TYPE_TARGET_TYPE (current_type)) == TYPE_CODE_CLASS)
1451 && (TYPE_CODE (yyvsp[-3].tval) == TYPE_CODE_CLASS))
1452 write_exp_elt_opcode (UNOP_IND);
1454 write_exp_elt_opcode (UNOP_CAST);
1455 write_exp_elt_type (yyvsp[-3].tval);
1456 write_exp_elt_opcode (UNOP_CAST);
1457 current_type = yyvsp[-3].tval; }
1458 break;
1460 case 25:
1461 #line 362 "p-exp.y"
1463 break;
1465 case 26:
1466 #line 368 "p-exp.y"
1467 { write_exp_elt_opcode (BINOP_MUL); }
1468 break;
1470 case 27:
1471 #line 372 "p-exp.y"
1472 { write_exp_elt_opcode (BINOP_DIV); }
1473 break;
1475 case 28:
1476 #line 376 "p-exp.y"
1477 { write_exp_elt_opcode (BINOP_INTDIV); }
1478 break;
1480 case 29:
1481 #line 380 "p-exp.y"
1482 { write_exp_elt_opcode (BINOP_REM); }
1483 break;
1485 case 30:
1486 #line 384 "p-exp.y"
1487 { write_exp_elt_opcode (BINOP_ADD); }
1488 break;
1490 case 31:
1491 #line 388 "p-exp.y"
1492 { write_exp_elt_opcode (BINOP_SUB); }
1493 break;
1495 case 32:
1496 #line 392 "p-exp.y"
1497 { write_exp_elt_opcode (BINOP_LSH); }
1498 break;
1500 case 33:
1501 #line 396 "p-exp.y"
1502 { write_exp_elt_opcode (BINOP_RSH); }
1503 break;
1505 case 34:
1506 #line 400 "p-exp.y"
1507 { write_exp_elt_opcode (BINOP_EQUAL); }
1508 break;
1510 case 35:
1511 #line 404 "p-exp.y"
1512 { write_exp_elt_opcode (BINOP_NOTEQUAL); }
1513 break;
1515 case 36:
1516 #line 408 "p-exp.y"
1517 { write_exp_elt_opcode (BINOP_LEQ); }
1518 break;
1520 case 37:
1521 #line 412 "p-exp.y"
1522 { write_exp_elt_opcode (BINOP_GEQ); }
1523 break;
1525 case 38:
1526 #line 416 "p-exp.y"
1527 { write_exp_elt_opcode (BINOP_LESS); }
1528 break;
1530 case 39:
1531 #line 420 "p-exp.y"
1532 { write_exp_elt_opcode (BINOP_GTR); }
1533 break;
1535 case 40:
1536 #line 424 "p-exp.y"
1537 { write_exp_elt_opcode (BINOP_BITWISE_AND); }
1538 break;
1540 case 41:
1541 #line 428 "p-exp.y"
1542 { write_exp_elt_opcode (BINOP_BITWISE_XOR); }
1543 break;
1545 case 42:
1546 #line 432 "p-exp.y"
1547 { write_exp_elt_opcode (BINOP_BITWISE_IOR); }
1548 break;
1550 case 43:
1551 #line 436 "p-exp.y"
1552 { write_exp_elt_opcode (BINOP_ASSIGN); }
1553 break;
1555 case 44:
1556 #line 440 "p-exp.y"
1557 { write_exp_elt_opcode (OP_BOOL);
1558 write_exp_elt_longcst ((LONGEST) yyvsp[0].lval);
1559 write_exp_elt_opcode (OP_BOOL); }
1560 break;
1562 case 45:
1563 #line 446 "p-exp.y"
1564 { write_exp_elt_opcode (OP_BOOL);
1565 write_exp_elt_longcst ((LONGEST) yyvsp[0].lval);
1566 write_exp_elt_opcode (OP_BOOL); }
1567 break;
1569 case 46:
1570 #line 452 "p-exp.y"
1571 { write_exp_elt_opcode (OP_LONG);
1572 write_exp_elt_type (yyvsp[0].typed_val_int.type);
1573 write_exp_elt_longcst ((LONGEST)(yyvsp[0].typed_val_int.val));
1574 write_exp_elt_opcode (OP_LONG); }
1575 break;
1577 case 47:
1578 #line 459 "p-exp.y"
1579 { YYSTYPE val;
1580 parse_number (yyvsp[0].ssym.stoken.ptr, yyvsp[0].ssym.stoken.length, 0, &val);
1581 write_exp_elt_opcode (OP_LONG);
1582 write_exp_elt_type (val.typed_val_int.type);
1583 write_exp_elt_longcst ((LONGEST)val.typed_val_int.val);
1584 write_exp_elt_opcode (OP_LONG);
1586 break;
1588 case 48:
1589 #line 470 "p-exp.y"
1590 { write_exp_elt_opcode (OP_DOUBLE);
1591 write_exp_elt_type (yyvsp[0].typed_val_float.type);
1592 write_exp_elt_dblcst (yyvsp[0].typed_val_float.dval);
1593 write_exp_elt_opcode (OP_DOUBLE); }
1594 break;
1596 case 51:
1597 #line 484 "p-exp.y"
1598 { write_exp_elt_opcode (OP_LONG);
1599 write_exp_elt_type (builtin_type_int);
1600 CHECK_TYPEDEF (yyvsp[-1].tval);
1601 write_exp_elt_longcst ((LONGEST) TYPE_LENGTH (yyvsp[-1].tval));
1602 write_exp_elt_opcode (OP_LONG); }
1603 break;
1605 case 52:
1606 #line 492 "p-exp.y"
1607 { /* C strings are converted into array constants with
1608 an explicit null byte added at the end. Thus
1609 the array upper bound is the string length.
1610 There is no such thing in C as a completely empty
1611 string. */
1612 char *sp = yyvsp[0].sval.ptr; int count = yyvsp[0].sval.length;
1613 while (count-- > 0)
1615 write_exp_elt_opcode (OP_LONG);
1616 write_exp_elt_type (builtin_type_char);
1617 write_exp_elt_longcst ((LONGEST)(*sp++));
1618 write_exp_elt_opcode (OP_LONG);
1620 write_exp_elt_opcode (OP_LONG);
1621 write_exp_elt_type (builtin_type_char);
1622 write_exp_elt_longcst ((LONGEST)'\0');
1623 write_exp_elt_opcode (OP_LONG);
1624 write_exp_elt_opcode (OP_ARRAY);
1625 write_exp_elt_longcst ((LONGEST) 0);
1626 write_exp_elt_longcst ((LONGEST) (yyvsp[0].sval.length));
1627 write_exp_elt_opcode (OP_ARRAY); }
1628 break;
1630 case 53:
1631 #line 517 "p-exp.y"
1633 struct value * this_val;
1634 struct type * this_type;
1635 write_exp_elt_opcode (OP_THIS);
1636 write_exp_elt_opcode (OP_THIS);
1637 /* we need type of this */
1638 this_val = value_of_this (0);
1639 if (this_val)
1640 this_type = value_type (this_val);
1641 else
1642 this_type = NULL;
1643 if (this_type)
1645 if (TYPE_CODE (this_type) == TYPE_CODE_PTR)
1647 this_type = TYPE_TARGET_TYPE (this_type);
1648 write_exp_elt_opcode (UNOP_IND);
1652 current_type = this_type;
1654 break;
1656 case 54:
1657 #line 544 "p-exp.y"
1659 if (yyvsp[0].ssym.sym != 0)
1660 yyval.bval = SYMBOL_BLOCK_VALUE (yyvsp[0].ssym.sym);
1661 else
1663 struct symtab *tem =
1664 lookup_symtab (copy_name (yyvsp[0].ssym.stoken));
1665 if (tem)
1666 yyval.bval = BLOCKVECTOR_BLOCK (BLOCKVECTOR (tem), STATIC_BLOCK);
1667 else
1668 error ("No file or function \"%s\".",
1669 copy_name (yyvsp[0].ssym.stoken));
1672 break;
1674 case 55:
1675 #line 561 "p-exp.y"
1676 { struct symbol *tem
1677 = lookup_symbol (copy_name (yyvsp[0].sval), yyvsp[-2].bval,
1678 VAR_DOMAIN, (int *) NULL,
1679 (struct symtab **) NULL);
1680 if (!tem || SYMBOL_CLASS (tem) != LOC_BLOCK)
1681 error ("No function \"%s\" in specified context.",
1682 copy_name (yyvsp[0].sval));
1683 yyval.bval = SYMBOL_BLOCK_VALUE (tem); }
1684 break;
1686 case 56:
1687 #line 572 "p-exp.y"
1688 { struct symbol *sym;
1689 sym = lookup_symbol (copy_name (yyvsp[0].sval), yyvsp[-2].bval,
1690 VAR_DOMAIN, (int *) NULL,
1691 (struct symtab **) NULL);
1692 if (sym == 0)
1693 error ("No symbol \"%s\" in specified context.",
1694 copy_name (yyvsp[0].sval));
1696 write_exp_elt_opcode (OP_VAR_VALUE);
1697 /* block_found is set by lookup_symbol. */
1698 write_exp_elt_block (block_found);
1699 write_exp_elt_sym (sym);
1700 write_exp_elt_opcode (OP_VAR_VALUE); }
1701 break;
1703 case 57:
1704 #line 588 "p-exp.y"
1706 struct type *type = yyvsp[-2].tval;
1707 if (TYPE_CODE (type) != TYPE_CODE_STRUCT
1708 && TYPE_CODE (type) != TYPE_CODE_UNION)
1709 error ("`%s' is not defined as an aggregate type.",
1710 TYPE_NAME (type));
1712 write_exp_elt_opcode (OP_SCOPE);
1713 write_exp_elt_type (type);
1714 write_exp_string (yyvsp[0].sval);
1715 write_exp_elt_opcode (OP_SCOPE);
1717 break;
1719 case 59:
1720 #line 604 "p-exp.y"
1722 char *name = copy_name (yyvsp[0].sval);
1723 struct symbol *sym;
1724 struct minimal_symbol *msymbol;
1726 sym =
1727 lookup_symbol (name, (const struct block *) NULL,
1728 VAR_DOMAIN, (int *) NULL,
1729 (struct symtab **) NULL);
1730 if (sym)
1732 write_exp_elt_opcode (OP_VAR_VALUE);
1733 write_exp_elt_block (NULL);
1734 write_exp_elt_sym (sym);
1735 write_exp_elt_opcode (OP_VAR_VALUE);
1736 break;
1739 msymbol = lookup_minimal_symbol (name, NULL, NULL);
1740 if (msymbol != NULL)
1742 write_exp_msymbol (msymbol,
1743 lookup_function_type (builtin_type_int),
1744 builtin_type_int);
1746 else
1747 if (!have_full_symbols () && !have_partial_symbols ())
1748 error ("No symbol table is loaded. Use the \"file\" command.");
1749 else
1750 error ("No symbol \"%s\" in current context.", name);
1752 break;
1754 case 60:
1755 #line 638 "p-exp.y"
1756 { struct symbol *sym = yyvsp[0].ssym.sym;
1758 if (sym)
1760 if (symbol_read_needs_frame (sym))
1762 if (innermost_block == 0 ||
1763 contained_in (block_found,
1764 innermost_block))
1765 innermost_block = block_found;
1768 write_exp_elt_opcode (OP_VAR_VALUE);
1769 /* We want to use the selected frame, not
1770 another more inner frame which happens to
1771 be in the same block. */
1772 write_exp_elt_block (NULL);
1773 write_exp_elt_sym (sym);
1774 write_exp_elt_opcode (OP_VAR_VALUE);
1775 current_type = sym->type; }
1776 else if (yyvsp[0].ssym.is_a_field_of_this)
1778 struct value * this_val;
1779 struct type * this_type;
1780 /* Object pascal: it hangs off of `this'. Must
1781 not inadvertently convert from a method call
1782 to data ref. */
1783 if (innermost_block == 0 ||
1784 contained_in (block_found, innermost_block))
1785 innermost_block = block_found;
1786 write_exp_elt_opcode (OP_THIS);
1787 write_exp_elt_opcode (OP_THIS);
1788 write_exp_elt_opcode (STRUCTOP_PTR);
1789 write_exp_string (yyvsp[0].ssym.stoken);
1790 write_exp_elt_opcode (STRUCTOP_PTR);
1791 /* we need type of this */
1792 this_val = value_of_this (0);
1793 if (this_val)
1794 this_type = value_type (this_val);
1795 else
1796 this_type = NULL;
1797 if (this_type)
1798 current_type = lookup_struct_elt_type (
1799 this_type,
1800 copy_name (yyvsp[0].ssym.stoken), 0);
1801 else
1802 current_type = NULL;
1804 else
1806 struct minimal_symbol *msymbol;
1807 char *arg = copy_name (yyvsp[0].ssym.stoken);
1809 msymbol =
1810 lookup_minimal_symbol (arg, NULL, NULL);
1811 if (msymbol != NULL)
1813 write_exp_msymbol (msymbol,
1814 lookup_function_type (builtin_type_int),
1815 builtin_type_int);
1817 else if (!have_full_symbols () && !have_partial_symbols ())
1818 error ("No symbol table is loaded. Use the \"file\" command.");
1819 else
1820 error ("No symbol \"%s\" in current context.",
1821 copy_name (yyvsp[0].ssym.stoken));
1824 break;
1826 case 63:
1827 #line 722 "p-exp.y"
1828 { yyval.tval = lookup_member_type (builtin_type_int, yyvsp[-2].tval); }
1829 break;
1831 case 64:
1832 #line 727 "p-exp.y"
1833 { yyval.tval = lookup_pointer_type (yyvsp[0].tval); }
1834 break;
1836 case 65:
1837 #line 729 "p-exp.y"
1838 { yyval.tval = yyvsp[0].tsym.type; }
1839 break;
1841 case 66:
1842 #line 731 "p-exp.y"
1843 { yyval.tval = lookup_struct (copy_name (yyvsp[0].sval),
1844 expression_context_block); }
1845 break;
1847 case 67:
1848 #line 734 "p-exp.y"
1849 { yyval.tval = lookup_struct (copy_name (yyvsp[0].sval),
1850 expression_context_block); }
1851 break;
1853 case 68:
1854 #line 741 "p-exp.y"
1855 { yyval.sval = yyvsp[0].ssym.stoken; }
1856 break;
1858 case 69:
1859 #line 742 "p-exp.y"
1860 { yyval.sval = yyvsp[0].ssym.stoken; }
1861 break;
1863 case 70:
1864 #line 743 "p-exp.y"
1865 { yyval.sval = yyvsp[0].tsym.stoken; }
1866 break;
1868 case 71:
1869 #line 744 "p-exp.y"
1870 { yyval.sval = yyvsp[0].ssym.stoken; }
1871 break;
1876 /* Line 1000 of yacc.c. */
1877 #line 1878 "p-exp.c.tmp"
1879 yyvsp -= yylen;
1880 yyssp -= yylen;
1883 YY_STACK_PRINT (yyss, yyssp);
1885 *++yyvsp = yyval;
1888 /* Now `shift' the result of the reduction. Determine what state
1889 that goes to, based on the state we popped back to and the rule
1890 number reduced by. */
1892 yyn = yyr1[yyn];
1894 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1895 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1896 yystate = yytable[yystate];
1897 else
1898 yystate = yydefgoto[yyn - YYNTOKENS];
1900 goto yynewstate;
1903 /*------------------------------------.
1904 | yyerrlab -- here on detecting error |
1905 `------------------------------------*/
1906 yyerrlab:
1907 /* If not already recovering from an error, report this error. */
1908 if (!yyerrstatus)
1910 ++yynerrs;
1911 #if YYERROR_VERBOSE
1912 yyn = yypact[yystate];
1914 if (YYPACT_NINF < yyn && yyn < YYLAST)
1916 YYSIZE_T yysize = 0;
1917 int yytype = YYTRANSLATE (yychar);
1918 const char* yyprefix;
1919 char *yymsg;
1920 int yyx;
1922 /* Start YYX at -YYN if negative to avoid negative indexes in
1923 YYCHECK. */
1924 int yyxbegin = yyn < 0 ? -yyn : 0;
1926 /* Stay within bounds of both yycheck and yytname. */
1927 int yychecklim = YYLAST - yyn;
1928 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1929 int yycount = 0;
1931 yyprefix = ", expecting ";
1932 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1933 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1935 yysize += yystrlen (yyprefix) + yystrlen (yytname [yyx]);
1936 yycount += 1;
1937 if (yycount == 5)
1939 yysize = 0;
1940 break;
1943 yysize += (sizeof ("syntax error, unexpected ")
1944 + yystrlen (yytname[yytype]));
1945 yymsg = (char *) YYSTACK_ALLOC (yysize);
1946 if (yymsg != 0)
1948 char *yyp = yystpcpy (yymsg, "syntax error, unexpected ");
1949 yyp = yystpcpy (yyp, yytname[yytype]);
1951 if (yycount < 5)
1953 yyprefix = ", expecting ";
1954 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1955 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1957 yyp = yystpcpy (yyp, yyprefix);
1958 yyp = yystpcpy (yyp, yytname[yyx]);
1959 yyprefix = " or ";
1962 yyerror (yymsg);
1963 YYSTACK_FREE (yymsg);
1965 else
1966 yyerror ("syntax error; also virtual memory exhausted");
1968 else
1969 #endif /* YYERROR_VERBOSE */
1970 yyerror ("syntax error");
1975 if (yyerrstatus == 3)
1977 /* If just tried and failed to reuse lookahead token after an
1978 error, discard it. */
1980 if (yychar <= YYEOF)
1982 /* If at end of input, pop the error token,
1983 then the rest of the stack, then return failure. */
1984 if (yychar == YYEOF)
1985 for (;;)
1987 YYPOPSTACK;
1988 if (yyssp == yyss)
1989 YYABORT;
1990 YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
1991 yydestruct (yystos[*yyssp], yyvsp);
1994 else
1996 YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc);
1997 yydestruct (yytoken, &yylval);
1998 yychar = YYEMPTY;
2003 /* Else will try to reuse lookahead token after shifting the error
2004 token. */
2005 goto yyerrlab1;
2008 /*---------------------------------------------------.
2009 | yyerrorlab -- error raised explicitly by YYERROR. |
2010 `---------------------------------------------------*/
2011 yyerrorlab:
2013 #ifdef __GNUC__
2014 /* Pacify GCC when the user code never invokes YYERROR and the label
2015 yyerrorlab therefore never appears in user code. */
2016 if (0)
2017 goto yyerrorlab;
2018 #endif
2020 yyvsp -= yylen;
2021 yyssp -= yylen;
2022 yystate = *yyssp;
2023 goto yyerrlab1;
2026 /*-------------------------------------------------------------.
2027 | yyerrlab1 -- common code for both syntax error and YYERROR. |
2028 `-------------------------------------------------------------*/
2029 yyerrlab1:
2030 yyerrstatus = 3; /* Each real token shifted decrements this. */
2032 for (;;)
2034 yyn = yypact[yystate];
2035 if (yyn != YYPACT_NINF)
2037 yyn += YYTERROR;
2038 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
2040 yyn = yytable[yyn];
2041 if (0 < yyn)
2042 break;
2046 /* Pop the current state because it cannot handle the error token. */
2047 if (yyssp == yyss)
2048 YYABORT;
2050 YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
2051 yydestruct (yystos[yystate], yyvsp);
2052 YYPOPSTACK;
2053 yystate = *yyssp;
2054 YY_STACK_PRINT (yyss, yyssp);
2057 if (yyn == YYFINAL)
2058 YYACCEPT;
2060 YYDPRINTF ((stderr, "Shifting error token, "));
2062 *++yyvsp = yylval;
2065 yystate = yyn;
2066 goto yynewstate;
2069 /*-------------------------------------.
2070 | yyacceptlab -- YYACCEPT comes here. |
2071 `-------------------------------------*/
2072 yyacceptlab:
2073 yyresult = 0;
2074 goto yyreturn;
2076 /*-----------------------------------.
2077 | yyabortlab -- YYABORT comes here. |
2078 `-----------------------------------*/
2079 yyabortlab:
2080 yyresult = 1;
2081 goto yyreturn;
2083 #ifndef yyoverflow
2084 /*----------------------------------------------.
2085 | yyoverflowlab -- parser overflow comes here. |
2086 `----------------------------------------------*/
2087 yyoverflowlab:
2088 yyerror ("parser stack overflow");
2089 yyresult = 2;
2090 /* Fall through. */
2091 #endif
2093 yyreturn:
2094 #ifndef yyoverflow
2095 if (yyss != yyssa)
2096 YYSTACK_FREE (yyss);
2097 #endif
2098 return yyresult;
2102 #line 758 "p-exp.y"
2105 /* Take care of parsing a number (anything that starts with a digit).
2106 Set yylval and return the token type; update lexptr.
2107 LEN is the number of characters in it. */
2109 /*** Needs some error checking for the float case ***/
2111 static int
2112 parse_number (p, len, parsed_float, putithere)
2113 char *p;
2114 int len;
2115 int parsed_float;
2116 YYSTYPE *putithere;
2118 /* FIXME: Shouldn't these be unsigned? We don't deal with negative values
2119 here, and we do kind of silly things like cast to unsigned. */
2120 LONGEST n = 0;
2121 LONGEST prevn = 0;
2122 ULONGEST un;
2124 int i = 0;
2125 int c;
2126 int base = input_radix;
2127 int unsigned_p = 0;
2129 /* Number of "L" suffixes encountered. */
2130 int long_p = 0;
2132 /* We have found a "L" or "U" suffix. */
2133 int found_suffix = 0;
2135 ULONGEST high_bit;
2136 struct type *signed_type;
2137 struct type *unsigned_type;
2139 if (parsed_float)
2141 /* It's a float since it contains a point or an exponent. */
2142 char c;
2143 int num = 0; /* number of tokens scanned by scanf */
2144 char saved_char = p[len];
2146 p[len] = 0; /* null-terminate the token */
2147 num = sscanf (p, DOUBLEST_SCAN_FORMAT "%c",
2148 &putithere->typed_val_float.dval, &c);
2149 p[len] = saved_char; /* restore the input stream */
2150 if (num != 1) /* check scanf found ONLY a float ... */
2151 return ERROR;
2152 /* See if it has `f' or `l' suffix (float or long double). */
2154 c = tolower (p[len - 1]);
2156 if (c == 'f')
2157 putithere->typed_val_float.type = builtin_type_float;
2158 else if (c == 'l')
2159 putithere->typed_val_float.type = builtin_type_long_double;
2160 else if (isdigit (c) || c == '.')
2161 putithere->typed_val_float.type = builtin_type_double;
2162 else
2163 return ERROR;
2165 return FLOAT;
2168 /* Handle base-switching prefixes 0x, 0t, 0d, 0 */
2169 if (p[0] == '0')
2170 switch (p[1])
2172 case 'x':
2173 case 'X':
2174 if (len >= 3)
2176 p += 2;
2177 base = 16;
2178 len -= 2;
2180 break;
2182 case 't':
2183 case 'T':
2184 case 'd':
2185 case 'D':
2186 if (len >= 3)
2188 p += 2;
2189 base = 10;
2190 len -= 2;
2192 break;
2194 default:
2195 base = 8;
2196 break;
2199 while (len-- > 0)
2201 c = *p++;
2202 if (c >= 'A' && c <= 'Z')
2203 c += 'a' - 'A';
2204 if (c != 'l' && c != 'u')
2205 n *= base;
2206 if (c >= '0' && c <= '9')
2208 if (found_suffix)
2209 return ERROR;
2210 n += i = c - '0';
2212 else
2214 if (base > 10 && c >= 'a' && c <= 'f')
2216 if (found_suffix)
2217 return ERROR;
2218 n += i = c - 'a' + 10;
2220 else if (c == 'l')
2222 ++long_p;
2223 found_suffix = 1;
2225 else if (c == 'u')
2227 unsigned_p = 1;
2228 found_suffix = 1;
2230 else
2231 return ERROR; /* Char not a digit */
2233 if (i >= base)
2234 return ERROR; /* Invalid digit in this base */
2236 /* Portably test for overflow (only works for nonzero values, so make
2237 a second check for zero). FIXME: Can't we just make n and prevn
2238 unsigned and avoid this? */
2239 if (c != 'l' && c != 'u' && (prevn >= n) && n != 0)
2240 unsigned_p = 1; /* Try something unsigned */
2242 /* Portably test for unsigned overflow.
2243 FIXME: This check is wrong; for example it doesn't find overflow
2244 on 0x123456789 when LONGEST is 32 bits. */
2245 if (c != 'l' && c != 'u' && n != 0)
2247 if ((unsigned_p && (ULONGEST) prevn >= (ULONGEST) n))
2248 error ("Numeric constant too large.");
2250 prevn = n;
2253 /* An integer constant is an int, a long, or a long long. An L
2254 suffix forces it to be long; an LL suffix forces it to be long
2255 long. If not forced to a larger size, it gets the first type of
2256 the above that it fits in. To figure out whether it fits, we
2257 shift it right and see whether anything remains. Note that we
2258 can't shift sizeof (LONGEST) * HOST_CHAR_BIT bits or more in one
2259 operation, because many compilers will warn about such a shift
2260 (which always produces a zero result). Sometimes TARGET_INT_BIT
2261 or TARGET_LONG_BIT will be that big, sometimes not. To deal with
2262 the case where it is we just always shift the value more than
2263 once, with fewer bits each time. */
2265 un = (ULONGEST)n >> 2;
2266 if (long_p == 0
2267 && (un >> (TARGET_INT_BIT - 2)) == 0)
2269 high_bit = ((ULONGEST)1) << (TARGET_INT_BIT-1);
2271 /* A large decimal (not hex or octal) constant (between INT_MAX
2272 and UINT_MAX) is a long or unsigned long, according to ANSI,
2273 never an unsigned int, but this code treats it as unsigned
2274 int. This probably should be fixed. GCC gives a warning on
2275 such constants. */
2277 unsigned_type = builtin_type_unsigned_int;
2278 signed_type = builtin_type_int;
2280 else if (long_p <= 1
2281 && (un >> (TARGET_LONG_BIT - 2)) == 0)
2283 high_bit = ((ULONGEST)1) << (TARGET_LONG_BIT-1);
2284 unsigned_type = builtin_type_unsigned_long;
2285 signed_type = builtin_type_long;
2287 else
2289 int shift;
2290 if (sizeof (ULONGEST) * HOST_CHAR_BIT < TARGET_LONG_LONG_BIT)
2291 /* A long long does not fit in a LONGEST. */
2292 shift = (sizeof (ULONGEST) * HOST_CHAR_BIT - 1);
2293 else
2294 shift = (TARGET_LONG_LONG_BIT - 1);
2295 high_bit = (ULONGEST) 1 << shift;
2296 unsigned_type = builtin_type_unsigned_long_long;
2297 signed_type = builtin_type_long_long;
2300 putithere->typed_val_int.val = n;
2302 /* If the high bit of the worked out type is set then this number
2303 has to be unsigned. */
2305 if (unsigned_p || (n & high_bit))
2307 putithere->typed_val_int.type = unsigned_type;
2309 else
2311 putithere->typed_val_int.type = signed_type;
2314 return INT;
2318 struct type_push
2320 struct type *stored;
2321 struct type_push *next;
2324 static struct type_push *tp_top = NULL;
2326 static void
2327 push_current_type (void)
2329 struct type_push *tpnew;
2330 tpnew = (struct type_push *) xmalloc (sizeof (struct type_push));
2331 tpnew->next = tp_top;
2332 tpnew->stored = current_type;
2333 current_type = NULL;
2334 tp_top = tpnew;
2337 static void
2338 pop_current_type (void)
2340 struct type_push *tp = tp_top;
2341 if (tp)
2343 current_type = tp->stored;
2344 tp_top = tp->next;
2345 xfree (tp);
2349 struct token
2351 char *operator;
2352 int token;
2353 enum exp_opcode opcode;
2356 static const struct token tokentab3[] =
2358 {"shr", RSH, BINOP_END},
2359 {"shl", LSH, BINOP_END},
2360 {"and", ANDAND, BINOP_END},
2361 {"div", DIV, BINOP_END},
2362 {"not", NOT, BINOP_END},
2363 {"mod", MOD, BINOP_END},
2364 {"inc", INCREMENT, BINOP_END},
2365 {"dec", DECREMENT, BINOP_END},
2366 {"xor", XOR, BINOP_END}
2369 static const struct token tokentab2[] =
2371 {"or", OR, BINOP_END},
2372 {"<>", NOTEQUAL, BINOP_END},
2373 {"<=", LEQ, BINOP_END},
2374 {">=", GEQ, BINOP_END},
2375 {":=", ASSIGN, BINOP_END},
2376 {"::", COLONCOLON, BINOP_END} };
2378 /* Allocate uppercased var */
2379 /* make an uppercased copy of tokstart */
2380 static char * uptok (tokstart, namelen)
2381 char *tokstart;
2382 int namelen;
2384 int i;
2385 char *uptokstart = (char *)xmalloc(namelen+1);
2386 for (i = 0;i <= namelen;i++)
2388 if ((tokstart[i]>='a' && tokstart[i]<='z'))
2389 uptokstart[i] = tokstart[i]-('a'-'A');
2390 else
2391 uptokstart[i] = tokstart[i];
2393 uptokstart[namelen]='\0';
2394 return uptokstart;
2396 /* Read one token, getting characters through lexptr. */
2399 static int
2400 yylex ()
2402 int c;
2403 int namelen;
2404 unsigned int i;
2405 char *tokstart;
2406 char *uptokstart;
2407 char *tokptr;
2408 char *p;
2409 int explen, tempbufindex;
2410 static char *tempbuf;
2411 static int tempbufsize;
2413 retry:
2415 prev_lexptr = lexptr;
2417 tokstart = lexptr;
2418 explen = strlen (lexptr);
2419 /* See if it is a special token of length 3. */
2420 if (explen > 2)
2421 for (i = 0; i < sizeof (tokentab3) / sizeof (tokentab3[0]); i++)
2422 if (strncasecmp (tokstart, tokentab3[i].operator, 3) == 0
2423 && (!isalpha (tokentab3[i].operator[0]) || explen == 3
2424 || (!isalpha (tokstart[3]) && !isdigit (tokstart[3]) && tokstart[3] != '_')))
2426 lexptr += 3;
2427 yylval.opcode = tokentab3[i].opcode;
2428 return tokentab3[i].token;
2431 /* See if it is a special token of length 2. */
2432 if (explen > 1)
2433 for (i = 0; i < sizeof (tokentab2) / sizeof (tokentab2[0]); i++)
2434 if (strncasecmp (tokstart, tokentab2[i].operator, 2) == 0
2435 && (!isalpha (tokentab2[i].operator[0]) || explen == 2
2436 || (!isalpha (tokstart[2]) && !isdigit (tokstart[2]) && tokstart[2] != '_')))
2438 lexptr += 2;
2439 yylval.opcode = tokentab2[i].opcode;
2440 return tokentab2[i].token;
2443 switch (c = *tokstart)
2445 case 0:
2446 return 0;
2448 case ' ':
2449 case '\t':
2450 case '\n':
2451 lexptr++;
2452 goto retry;
2454 case '\'':
2455 /* We either have a character constant ('0' or '\177' for example)
2456 or we have a quoted symbol reference ('foo(int,int)' in object pascal
2457 for example). */
2458 lexptr++;
2459 c = *lexptr++;
2460 if (c == '\\')
2461 c = parse_escape (&lexptr);
2462 else if (c == '\'')
2463 error ("Empty character constant.");
2465 yylval.typed_val_int.val = c;
2466 yylval.typed_val_int.type = builtin_type_char;
2468 c = *lexptr++;
2469 if (c != '\'')
2471 namelen = skip_quoted (tokstart) - tokstart;
2472 if (namelen > 2)
2474 lexptr = tokstart + namelen;
2475 if (lexptr[-1] != '\'')
2476 error ("Unmatched single quote.");
2477 namelen -= 2;
2478 tokstart++;
2479 uptokstart = uptok(tokstart,namelen);
2480 goto tryname;
2482 error ("Invalid character constant.");
2484 return INT;
2486 case '(':
2487 paren_depth++;
2488 lexptr++;
2489 return c;
2491 case ')':
2492 if (paren_depth == 0)
2493 return 0;
2494 paren_depth--;
2495 lexptr++;
2496 return c;
2498 case ',':
2499 if (comma_terminates && paren_depth == 0)
2500 return 0;
2501 lexptr++;
2502 return c;
2504 case '.':
2505 /* Might be a floating point number. */
2506 if (lexptr[1] < '0' || lexptr[1] > '9')
2507 goto symbol; /* Nope, must be a symbol. */
2508 /* FALL THRU into number case. */
2510 case '0':
2511 case '1':
2512 case '2':
2513 case '3':
2514 case '4':
2515 case '5':
2516 case '6':
2517 case '7':
2518 case '8':
2519 case '9':
2521 /* It's a number. */
2522 int got_dot = 0, got_e = 0, toktype;
2523 char *p = tokstart;
2524 int hex = input_radix > 10;
2526 if (c == '0' && (p[1] == 'x' || p[1] == 'X'))
2528 p += 2;
2529 hex = 1;
2531 else if (c == '0' && (p[1]=='t' || p[1]=='T' || p[1]=='d' || p[1]=='D'))
2533 p += 2;
2534 hex = 0;
2537 for (;; ++p)
2539 /* This test includes !hex because 'e' is a valid hex digit
2540 and thus does not indicate a floating point number when
2541 the radix is hex. */
2542 if (!hex && !got_e && (*p == 'e' || *p == 'E'))
2543 got_dot = got_e = 1;
2544 /* This test does not include !hex, because a '.' always indicates
2545 a decimal floating point number regardless of the radix. */
2546 else if (!got_dot && *p == '.')
2547 got_dot = 1;
2548 else if (got_e && (p[-1] == 'e' || p[-1] == 'E')
2549 && (*p == '-' || *p == '+'))
2550 /* This is the sign of the exponent, not the end of the
2551 number. */
2552 continue;
2553 /* We will take any letters or digits. parse_number will
2554 complain if past the radix, or if L or U are not final. */
2555 else if ((*p < '0' || *p > '9')
2556 && ((*p < 'a' || *p > 'z')
2557 && (*p < 'A' || *p > 'Z')))
2558 break;
2560 toktype = parse_number (tokstart, p - tokstart, got_dot|got_e, &yylval);
2561 if (toktype == ERROR)
2563 char *err_copy = (char *) alloca (p - tokstart + 1);
2565 memcpy (err_copy, tokstart, p - tokstart);
2566 err_copy[p - tokstart] = 0;
2567 error ("Invalid number \"%s\".", err_copy);
2569 lexptr = p;
2570 return toktype;
2573 case '+':
2574 case '-':
2575 case '*':
2576 case '/':
2577 case '|':
2578 case '&':
2579 case '^':
2580 case '~':
2581 case '!':
2582 case '@':
2583 case '<':
2584 case '>':
2585 case '[':
2586 case ']':
2587 case '?':
2588 case ':':
2589 case '=':
2590 case '{':
2591 case '}':
2592 symbol:
2593 lexptr++;
2594 return c;
2596 case '"':
2598 /* Build the gdb internal form of the input string in tempbuf,
2599 translating any standard C escape forms seen. Note that the
2600 buffer is null byte terminated *only* for the convenience of
2601 debugging gdb itself and printing the buffer contents when
2602 the buffer contains no embedded nulls. Gdb does not depend
2603 upon the buffer being null byte terminated, it uses the length
2604 string instead. This allows gdb to handle C strings (as well
2605 as strings in other languages) with embedded null bytes */
2607 tokptr = ++tokstart;
2608 tempbufindex = 0;
2610 do {
2611 /* Grow the static temp buffer if necessary, including allocating
2612 the first one on demand. */
2613 if (tempbufindex + 1 >= tempbufsize)
2615 tempbuf = (char *) xrealloc (tempbuf, tempbufsize += 64);
2618 switch (*tokptr)
2620 case '\0':
2621 case '"':
2622 /* Do nothing, loop will terminate. */
2623 break;
2624 case '\\':
2625 tokptr++;
2626 c = parse_escape (&tokptr);
2627 if (c == -1)
2629 continue;
2631 tempbuf[tempbufindex++] = c;
2632 break;
2633 default:
2634 tempbuf[tempbufindex++] = *tokptr++;
2635 break;
2637 } while ((*tokptr != '"') && (*tokptr != '\0'));
2638 if (*tokptr++ != '"')
2640 error ("Unterminated string in expression.");
2642 tempbuf[tempbufindex] = '\0'; /* See note above */
2643 yylval.sval.ptr = tempbuf;
2644 yylval.sval.length = tempbufindex;
2645 lexptr = tokptr;
2646 return (STRING);
2649 if (!(c == '_' || c == '$'
2650 || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')))
2651 /* We must have come across a bad character (e.g. ';'). */
2652 error ("Invalid character '%c' in expression.", c);
2654 /* It's a name. See how long it is. */
2655 namelen = 0;
2656 for (c = tokstart[namelen];
2657 (c == '_' || c == '$' || (c >= '0' && c <= '9')
2658 || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '<');)
2660 /* Template parameter lists are part of the name.
2661 FIXME: This mishandles `print $a<4&&$a>3'. */
2662 if (c == '<')
2664 int i = namelen;
2665 int nesting_level = 1;
2666 while (tokstart[++i])
2668 if (tokstart[i] == '<')
2669 nesting_level++;
2670 else if (tokstart[i] == '>')
2672 if (--nesting_level == 0)
2673 break;
2676 if (tokstart[i] == '>')
2677 namelen = i;
2678 else
2679 break;
2682 /* do NOT uppercase internals because of registers !!! */
2683 c = tokstart[++namelen];
2686 uptokstart = uptok(tokstart,namelen);
2688 /* The token "if" terminates the expression and is NOT
2689 removed from the input stream. */
2690 if (namelen == 2 && uptokstart[0] == 'I' && uptokstart[1] == 'F')
2692 return 0;
2695 lexptr += namelen;
2697 tryname:
2699 /* Catch specific keywords. Should be done with a data structure. */
2700 switch (namelen)
2702 case 6:
2703 if (DEPRECATED_STREQ (uptokstart, "OBJECT"))
2704 return CLASS;
2705 if (DEPRECATED_STREQ (uptokstart, "RECORD"))
2706 return STRUCT;
2707 if (DEPRECATED_STREQ (uptokstart, "SIZEOF"))
2708 return SIZEOF;
2709 break;
2710 case 5:
2711 if (DEPRECATED_STREQ (uptokstart, "CLASS"))
2712 return CLASS;
2713 if (DEPRECATED_STREQ (uptokstart, "FALSE"))
2715 yylval.lval = 0;
2716 return FALSEKEYWORD;
2718 break;
2719 case 4:
2720 if (DEPRECATED_STREQ (uptokstart, "TRUE"))
2722 yylval.lval = 1;
2723 return TRUEKEYWORD;
2725 if (DEPRECATED_STREQ (uptokstart, "SELF"))
2727 /* here we search for 'this' like
2728 inserted in FPC stabs debug info */
2729 static const char this_name[] = "this";
2731 if (lookup_symbol (this_name, expression_context_block,
2732 VAR_DOMAIN, (int *) NULL,
2733 (struct symtab **) NULL))
2734 return THIS;
2736 break;
2737 default:
2738 break;
2741 yylval.sval.ptr = tokstart;
2742 yylval.sval.length = namelen;
2744 if (*tokstart == '$')
2746 /* $ is the normal prefix for pascal hexadecimal values
2747 but this conflicts with the GDB use for debugger variables
2748 so in expression to enter hexadecimal values
2749 we still need to use C syntax with 0xff */
2750 write_dollar_variable (yylval.sval);
2751 return VARIABLE;
2754 /* Use token-type BLOCKNAME for symbols that happen to be defined as
2755 functions or symtabs. If this is not so, then ...
2756 Use token-type TYPENAME for symbols that happen to be defined
2757 currently as names of types; NAME for other symbols.
2758 The caller is not constrained to care about the distinction. */
2760 char *tmp = copy_name (yylval.sval);
2761 struct symbol *sym;
2762 int is_a_field_of_this = 0;
2763 int is_a_field = 0;
2764 int hextype;
2767 if (search_field && current_type)
2768 is_a_field = (lookup_struct_elt_type (current_type, tmp, 1) != NULL);
2769 if (is_a_field)
2770 sym = NULL;
2771 else
2772 sym = lookup_symbol (tmp, expression_context_block,
2773 VAR_DOMAIN,
2774 &is_a_field_of_this,
2775 (struct symtab **) NULL);
2776 /* second chance uppercased (as Free Pascal does). */
2777 if (!sym && !is_a_field_of_this && !is_a_field)
2779 for (i = 0; i <= namelen; i++)
2781 if ((tmp[i] >= 'a' && tmp[i] <= 'z'))
2782 tmp[i] -= ('a'-'A');
2784 if (search_field && current_type)
2785 is_a_field = (lookup_struct_elt_type (current_type, tmp, 1) != NULL);
2786 if (is_a_field)
2787 sym = NULL;
2788 else
2789 sym = lookup_symbol (tmp, expression_context_block,
2790 VAR_DOMAIN,
2791 &is_a_field_of_this,
2792 (struct symtab **) NULL);
2793 if (sym || is_a_field_of_this || is_a_field)
2794 for (i = 0; i <= namelen; i++)
2796 if ((tokstart[i] >= 'a' && tokstart[i] <= 'z'))
2797 tokstart[i] -= ('a'-'A');
2800 /* Third chance Capitalized (as GPC does). */
2801 if (!sym && !is_a_field_of_this && !is_a_field)
2803 for (i = 0; i <= namelen; i++)
2805 if (i == 0)
2807 if ((tmp[i] >= 'a' && tmp[i] <= 'z'))
2808 tmp[i] -= ('a'-'A');
2810 else
2811 if ((tmp[i] >= 'A' && tmp[i] <= 'Z'))
2812 tmp[i] -= ('A'-'a');
2814 if (search_field && current_type)
2815 is_a_field = (lookup_struct_elt_type (current_type, tmp, 1) != NULL);
2816 if (is_a_field)
2817 sym = NULL;
2818 else
2819 sym = lookup_symbol (tmp, expression_context_block,
2820 VAR_DOMAIN,
2821 &is_a_field_of_this,
2822 (struct symtab **) NULL);
2823 if (sym || is_a_field_of_this || is_a_field)
2824 for (i = 0; i <= namelen; i++)
2826 if (i == 0)
2828 if ((tokstart[i] >= 'a' && tokstart[i] <= 'z'))
2829 tokstart[i] -= ('a'-'A');
2831 else
2832 if ((tokstart[i] >= 'A' && tokstart[i] <= 'Z'))
2833 tokstart[i] -= ('A'-'a');
2837 if (is_a_field)
2839 tempbuf = (char *) xrealloc (tempbuf, namelen + 1);
2840 strncpy (tempbuf, tokstart, namelen); tempbuf [namelen] = 0;
2841 yylval.sval.ptr = tempbuf;
2842 yylval.sval.length = namelen;
2843 return FIELDNAME;
2845 /* Call lookup_symtab, not lookup_partial_symtab, in case there are
2846 no psymtabs (coff, xcoff, or some future change to blow away the
2847 psymtabs once once symbols are read). */
2848 if ((sym && SYMBOL_CLASS (sym) == LOC_BLOCK) ||
2849 lookup_symtab (tmp))
2851 yylval.ssym.sym = sym;
2852 yylval.ssym.is_a_field_of_this = is_a_field_of_this;
2853 return BLOCKNAME;
2855 if (sym && SYMBOL_CLASS (sym) == LOC_TYPEDEF)
2857 #if 1
2858 /* Despite the following flaw, we need to keep this code enabled.
2859 Because we can get called from check_stub_method, if we don't
2860 handle nested types then it screws many operations in any
2861 program which uses nested types. */
2862 /* In "A::x", if x is a member function of A and there happens
2863 to be a type (nested or not, since the stabs don't make that
2864 distinction) named x, then this code incorrectly thinks we
2865 are dealing with nested types rather than a member function. */
2867 char *p;
2868 char *namestart;
2869 struct symbol *best_sym;
2871 /* Look ahead to detect nested types. This probably should be
2872 done in the grammar, but trying seemed to introduce a lot
2873 of shift/reduce and reduce/reduce conflicts. It's possible
2874 that it could be done, though. Or perhaps a non-grammar, but
2875 less ad hoc, approach would work well. */
2877 /* Since we do not currently have any way of distinguishing
2878 a nested type from a non-nested one (the stabs don't tell
2879 us whether a type is nested), we just ignore the
2880 containing type. */
2882 p = lexptr;
2883 best_sym = sym;
2884 while (1)
2886 /* Skip whitespace. */
2887 while (*p == ' ' || *p == '\t' || *p == '\n')
2888 ++p;
2889 if (*p == ':' && p[1] == ':')
2891 /* Skip the `::'. */
2892 p += 2;
2893 /* Skip whitespace. */
2894 while (*p == ' ' || *p == '\t' || *p == '\n')
2895 ++p;
2896 namestart = p;
2897 while (*p == '_' || *p == '$' || (*p >= '0' && *p <= '9')
2898 || (*p >= 'a' && *p <= 'z')
2899 || (*p >= 'A' && *p <= 'Z'))
2900 ++p;
2901 if (p != namestart)
2903 struct symbol *cur_sym;
2904 /* As big as the whole rest of the expression, which is
2905 at least big enough. */
2906 char *ncopy = alloca (strlen (tmp)+strlen (namestart)+3);
2907 char *tmp1;
2909 tmp1 = ncopy;
2910 memcpy (tmp1, tmp, strlen (tmp));
2911 tmp1 += strlen (tmp);
2912 memcpy (tmp1, "::", 2);
2913 tmp1 += 2;
2914 memcpy (tmp1, namestart, p - namestart);
2915 tmp1[p - namestart] = '\0';
2916 cur_sym = lookup_symbol (ncopy, expression_context_block,
2917 VAR_DOMAIN, (int *) NULL,
2918 (struct symtab **) NULL);
2919 if (cur_sym)
2921 if (SYMBOL_CLASS (cur_sym) == LOC_TYPEDEF)
2923 best_sym = cur_sym;
2924 lexptr = p;
2926 else
2927 break;
2929 else
2930 break;
2932 else
2933 break;
2935 else
2936 break;
2939 yylval.tsym.type = SYMBOL_TYPE (best_sym);
2940 #else /* not 0 */
2941 yylval.tsym.type = SYMBOL_TYPE (sym);
2942 #endif /* not 0 */
2943 return TYPENAME;
2945 yylval.tsym.type
2946 = language_lookup_primitive_type_by_name (current_language,
2947 current_gdbarch, tmp);
2948 if (yylval.tsym.type != NULL)
2949 return TYPENAME;
2951 /* Input names that aren't symbols but ARE valid hex numbers,
2952 when the input radix permits them, can be names or numbers
2953 depending on the parse. Note we support radixes > 16 here. */
2954 if (!sym &&
2955 ((tokstart[0] >= 'a' && tokstart[0] < 'a' + input_radix - 10) ||
2956 (tokstart[0] >= 'A' && tokstart[0] < 'A' + input_radix - 10)))
2958 YYSTYPE newlval; /* Its value is ignored. */
2959 hextype = parse_number (tokstart, namelen, 0, &newlval);
2960 if (hextype == INT)
2962 yylval.ssym.sym = sym;
2963 yylval.ssym.is_a_field_of_this = is_a_field_of_this;
2964 return NAME_OR_INT;
2968 free(uptokstart);
2969 /* Any other kind of symbol */
2970 yylval.ssym.sym = sym;
2971 yylval.ssym.is_a_field_of_this = is_a_field_of_this;
2972 return NAME;
2976 void
2977 yyerror (msg)
2978 char *msg;
2980 if (prev_lexptr)
2981 lexptr = prev_lexptr;
2983 error ("A %s in expression, near `%s'.", (msg ? msg : "error"), lexptr);