Remove some more dead initialization.
[dragonfly.git] / contrib / gdb-6.2.1 / gdb / p-exp.c
blob21b2674fa21a2066a75375f013b397c4c359c704
1 /* A Bison parser, made by GNU Bison 1.875. */
3 /* Skeleton parser for Yacc-like parsing with Bison,
4 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 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 46 "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 130 "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 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
251 # define YYSTYPE_IS_DECLARED 1
252 # define YYSTYPE_IS_TRIVIAL 1
253 #endif
257 /* Copy the second part of user declarations. */
258 #line 154 "p-exp.y"
260 /* YYSTYPE gets defined by %union */
261 static int
262 parse_number (char *, int, int, YYSTYPE *);
264 static struct type *current_type;
266 static void push_current_type (void);
267 static void pop_current_type (void);
268 static int search_field;
271 /* Line 214 of yacc.c. */
273 #if ! defined (yyoverflow) || YYERROR_VERBOSE
275 /* The parser invokes alloca or xmalloc; define the necessary symbols. */
277 # if YYSTACK_USE_ALLOCA
278 # define YYSTACK_ALLOC alloca
279 # else
280 # ifndef YYSTACK_USE_ALLOCA
281 # if defined (alloca) || defined (_ALLOCA_H)
282 # define YYSTACK_ALLOC alloca
283 # else
284 # ifdef __GNUC__
285 # define YYSTACK_ALLOC __builtin_alloca
286 # endif
287 # endif
288 # endif
289 # endif
291 # ifdef YYSTACK_ALLOC
292 /* Pacify GCC's `empty if-body' warning. */
293 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
294 # else
295 # if defined (__STDC__) || defined (__cplusplus)
296 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
297 # define YYSIZE_T size_t
298 # endif
299 # define YYSTACK_ALLOC xmalloc
300 # define YYSTACK_FREE free
301 # endif
302 #endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
305 #if (! defined (yyoverflow) \
306 && (! defined (__cplusplus) \
307 || (YYSTYPE_IS_TRIVIAL)))
309 /* A type that is properly aligned for any stack member. */
310 union yyalloc
312 short yyss;
313 YYSTYPE yyvs;
316 /* The size of the maximum gap between one aligned stack and the next. */
317 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
319 /* The size of an array large to enough to hold all stacks, each with
320 N elements. */
321 # define YYSTACK_BYTES(N) \
322 ((N) * (sizeof (short) + sizeof (YYSTYPE)) \
323 + YYSTACK_GAP_MAXIMUM)
325 /* Copy COUNT objects from FROM to TO. The source and destination do
326 not overlap. */
327 # ifndef YYCOPY
328 # if 1 < __GNUC__
329 # define YYCOPY(To, From, Count) \
330 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
331 # else
332 # define YYCOPY(To, From, Count) \
333 do \
335 register YYSIZE_T yyi; \
336 for (yyi = 0; yyi < (Count); yyi++) \
337 (To)[yyi] = (From)[yyi]; \
339 while (0)
340 # endif
341 # endif
343 /* Relocate STACK from its old location to the new one. The
344 local variables YYSIZE and YYSTACKSIZE give the old and new number of
345 elements in the stack, and YYPTR gives the new location of the
346 stack. Advance YYPTR to a properly aligned location for the next
347 stack. */
348 # define YYSTACK_RELOCATE(Stack) \
349 do \
351 YYSIZE_T yynewbytes; \
352 YYCOPY (&yyptr->Stack, Stack, yysize); \
353 Stack = &yyptr->Stack; \
354 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
355 yyptr += yynewbytes / sizeof (*yyptr); \
357 while (0)
359 #endif
361 #if defined (__STDC__) || defined (__cplusplus)
362 typedef signed char yysigned_char;
363 #else
364 typedef short yysigned_char;
365 #endif
367 /* YYFINAL -- State number of the termination state. */
368 #define YYFINAL 3
369 /* YYLAST -- Last index in YYTABLE. */
370 #define YYLAST 359
372 /* YYNTOKENS -- Number of terminals. */
373 #define YYNTOKENS 52
374 /* YYNNTS -- Number of nonterminals. */
375 #define YYNNTS 19
376 /* YYNRULES -- Number of rules. */
377 #define YYNRULES 73
378 /* YYNRULES -- Number of states. */
379 #define YYNSTATES 123
381 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
382 #define YYUNDEFTOK 2
383 #define YYMAXUTOK 291
385 #define YYTRANSLATE(YYX) \
386 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
388 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
389 static const unsigned char yytranslate[] =
391 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
392 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
393 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
394 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
395 46, 50, 39, 37, 19, 38, 44, 40, 2, 2,
396 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
397 28, 26, 29, 2, 36, 2, 2, 2, 2, 2,
398 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
399 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
400 2, 45, 2, 51, 48, 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 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
405 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
406 2, 2, 2, 2, 2, 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, 2, 2, 2, 2, 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, 1, 2, 3, 4,
417 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
418 15, 16, 17, 18, 20, 21, 22, 23, 24, 25,
419 27, 30, 31, 32, 33, 34, 35, 41, 42, 43,
420 47, 49
423 #if YYDEBUG
424 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
425 YYRHS. */
426 static const unsigned char yyprhs[] =
428 0, 0, 3, 4, 7, 9, 11, 13, 15, 19,
429 22, 25, 28, 31, 36, 41, 42, 47, 48, 54,
430 55, 61, 62, 64, 68, 73, 77, 81, 85, 89,
431 93, 97, 101, 105, 109, 113, 117, 121, 125, 129,
432 133, 137, 141, 145, 149, 151, 153, 155, 157, 159,
433 161, 163, 168, 170, 172, 174, 178, 182, 186, 188,
434 191, 193, 195, 197, 201, 204, 206, 209, 212, 214,
435 216, 218, 220, 222
438 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
439 static const yysigned_char yyrhs[] =
441 53, 0, -1, -1, 54, 55, -1, 57, -1, 56,
442 -1, 67, -1, 58, -1, 57, 19, 58, -1, 58,
443 48, -1, 36, 58, -1, 38, 58, -1, 22, 58,
444 -1, 42, 46, 58, 50, -1, 41, 46, 58, 50,
445 -1, -1, 58, 44, 59, 6, -1, -1, 58, 45,
446 60, 57, 51, -1, -1, 58, 46, 61, 62, 50,
447 -1, -1, 58, -1, 62, 19, 58, -1, 67, 46,
448 58, 50, -1, 46, 57, 50, -1, 58, 39, 58,
449 -1, 58, 40, 58, -1, 58, 33, 58, -1, 58,
450 32, 58, -1, 58, 37, 58, -1, 58, 38, 58,
451 -1, 58, 35, 58, -1, 58, 34, 58, -1, 58,
452 26, 58, -1, 58, 27, 58, -1, 58, 31, 58,
453 -1, 58, 30, 58, -1, 58, 28, 58, -1, 58,
454 29, 58, -1, 58, 25, 58, -1, 58, 24, 58,
455 -1, 58, 23, 58, -1, 58, 21, 58, -1, 17,
456 -1, 18, -1, 3, -1, 9, -1, 4, -1, 64,
457 -1, 15, -1, 12, 46, 67, 50, -1, 5, -1,
458 16, -1, 49, -1, 63, 13, 69, -1, 63, 13,
459 69, -1, 68, 13, 69, -1, 65, -1, 13, 69,
460 -1, 70, -1, 68, -1, 66, -1, 68, 13, 39,
461 -1, 48, 68, -1, 8, -1, 10, 69, -1, 11,
462 69, -1, 7, -1, 49, -1, 8, -1, 9, -1,
463 7, -1, 49, -1
466 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
467 static const unsigned short yyrline[] =
469 0, 234, 234, 234, 241, 242, 245, 252, 253, 258,
470 264, 270, 274, 278, 282, 286, 286, 301, 299, 329,
471 326, 338, 339, 341, 345, 360, 366, 370, 374, 378,
472 382, 386, 390, 394, 398, 402, 406, 410, 414, 418,
473 422, 426, 430, 434, 438, 444, 450, 457, 468, 475,
474 478, 482, 490, 515, 542, 559, 570, 586, 601, 602,
475 636, 708, 719, 720, 725, 727, 729, 732, 740, 741,
476 742, 743, 746, 747
478 #endif
480 #if YYDEBUG || YYERROR_VERBOSE
481 /* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
482 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
483 static const char *const yytname[] =
485 "$end", "error", "$undefined", "INT", "FLOAT", "STRING", "FIELDNAME",
486 "NAME", "TYPENAME", "NAME_OR_INT", "STRUCT", "CLASS", "SIZEOF",
487 "COLONCOLON", "ERROR", "VARIABLE", "THIS", "TRUEKEYWORD",
488 "FALSEKEYWORD", "','", "ABOVE_COMMA", "ASSIGN", "NOT", "OR", "XOR",
489 "ANDAND", "'='", "NOTEQUAL", "'<'", "'>'", "GEQ", "LEQ", "MOD", "DIV",
490 "RSH", "LSH", "'@'", "'+'", "'-'", "'*'", "'/'", "DECREMENT",
491 "INCREMENT", "UNARY", "'.'", "'['", "'('", "ARROW", "'^'", "BLOCKNAME",
492 "')'", "']'", "$accept", "start", "@1", "normal_start", "type_exp",
493 "exp1", "exp", "@2", "@3", "@4", "arglist", "block", "variable",
494 "qualified_name", "ptype", "type", "typebase", "name",
495 "name_not_typename", 0
497 #endif
499 # ifdef YYPRINT
500 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
501 token YYLEX-NUM. */
502 static const unsigned short yytoknum[] =
504 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
505 265, 266, 267, 268, 269, 270, 271, 272, 273, 44,
506 274, 275, 276, 277, 278, 279, 61, 280, 60, 62,
507 281, 282, 283, 284, 285, 286, 64, 43, 45, 42,
508 47, 287, 288, 289, 46, 91, 40, 290, 94, 291,
509 41, 93
511 # endif
513 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
514 static const unsigned char yyr1[] =
516 0, 52, 54, 53, 55, 55, 56, 57, 57, 58,
517 58, 58, 58, 58, 58, 59, 58, 60, 58, 61,
518 58, 62, 62, 62, 58, 58, 58, 58, 58, 58,
519 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
520 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
521 58, 58, 58, 58, 63, 63, 64, 65, 64, 64,
522 64, 66, 67, 67, 68, 68, 68, 68, 69, 69,
523 69, 69, 70, 70
526 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
527 static const unsigned char yyr2[] =
529 0, 2, 0, 2, 1, 1, 1, 1, 3, 2,
530 2, 2, 2, 4, 4, 0, 4, 0, 5, 0,
531 5, 0, 1, 3, 4, 3, 3, 3, 3, 3,
532 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
533 3, 3, 3, 3, 1, 1, 1, 1, 1, 1,
534 1, 4, 1, 1, 1, 3, 3, 3, 1, 2,
535 1, 1, 1, 3, 2, 1, 2, 2, 1, 1,
536 1, 1, 1, 1
539 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
540 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
541 means the default is an error. */
542 static const unsigned char yydefact[] =
544 2, 0, 0, 1, 46, 48, 52, 72, 65, 47,
545 0, 0, 0, 0, 50, 53, 44, 45, 0, 0,
546 0, 0, 0, 0, 0, 73, 3, 5, 4, 7,
547 0, 49, 58, 62, 6, 61, 60, 68, 70, 71,
548 69, 66, 67, 0, 59, 12, 0, 10, 11, 0,
549 0, 0, 64, 0, 0, 0, 0, 0, 0, 0,
550 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
551 0, 0, 15, 17, 19, 9, 0, 0, 0, 0,
552 61, 0, 0, 25, 8, 43, 42, 41, 40, 34,
553 35, 38, 39, 37, 36, 29, 28, 33, 32, 30,
554 31, 26, 27, 0, 0, 21, 56, 0, 63, 57,
555 51, 0, 14, 13, 16, 0, 22, 0, 24, 18,
556 0, 20, 23
559 /* YYDEFGOTO[NTERM-NUM]. */
560 static const yysigned_char yydefgoto[] =
562 -1, 1, 2, 26, 27, 28, 29, 103, 104, 105,
563 117, 30, 31, 32, 33, 46, 35, 41, 36
566 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
567 STATE-NUM. */
568 #define YYPACT_NINF -37
569 static const short yypact[] =
571 -37, 5, 88, -37, -37, -37, -37, -37, -37, -37,
572 6, 6, -35, 6, -37, -37, -37, -37, 88, 88,
573 88, -29, -27, 88, 10, 12, -37, -37, 8, 201,
574 16, -37, -37, -37, -13, 21, -37, -37, -37, -37,
575 -37, -37, -37, 10, -37, -36, -13, -36, -36, 88,
576 88, 11, -37, 88, 88, 88, 88, 88, 88, 88,
577 88, 88, 88, 88, 88, 88, 88, 88, 88, 88,
578 88, 88, -37, -37, -37, -37, 6, 88, 15, 20,
579 43, 117, 145, -37, 201, 201, 226, 250, 273, 294,
580 294, 311, 311, 311, 311, 28, 28, 28, 28, 68,
581 68, -36, -36, 56, 88, 88, 62, 173, -37, -37,
582 -37, 38, -37, -37, -37, 9, 201, 44, -37, -37,
583 88, -37, 201
586 /* YYPGOTO[NTERM-NUM]. */
587 static const yysigned_char yypgoto[] =
589 -37, -37, -37, -37, -37, -20, -18, -37, -37, -37,
590 -37, -37, -37, -37, -37, 14, -17, -7, -37
593 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
594 positive, shift that token. If negative, reduce the rule which
595 number is the opposite. If zero, do what YYDEFACT says.
596 If YYTABLE_NINF, syntax error. */
597 #define YYTABLE_NINF -56
598 static const yysigned_char yytable[] =
600 45, 47, 48, 51, 42, 3, 44, 52, 72, 73,
601 74, 43, 75, 37, 38, 39, 34, 49, 8, 50,
602 10, 11, 37, 38, 39, -54, 80, 53, 53, 76,
603 53, 81, 82, 77, 78, 84, 85, 86, 87, 88,
604 89, 90, 91, 92, 93, 94, 95, 96, 97, 98,
605 99, 100, 101, 102, 108, 40, 111, 79, 24, 107,
606 119, 83, 114, 120, 40, 68, 69, 70, 71, 106,
607 110, 109, 72, 73, 74, -55, 75, 108, 0, 0,
608 0, 0, 0, 0, 115, 0, 0, 116, 0, 0,
609 0, 4, 5, 6, 121, 7, 8, 9, 10, 11,
610 12, 13, 122, 14, 15, 16, 17, 70, 71, 0,
611 18, 0, 72, 73, 74, 0, 75, 0, 0, 0,
612 0, 0, 0, 0, 19, 0, 20, 0, 0, 21,
613 22, 0, 0, 0, 23, 0, 24, 25, 54, 0,
614 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
615 65, 66, 67, 0, 68, 69, 70, 71, 0, 0,
616 0, 72, 73, 74, 0, 75, 54, 112, 55, 56,
617 57, 58, 59, 60, 61, 62, 63, 64, 65, 66,
618 67, 0, 68, 69, 70, 71, 0, 0, 0, 72,
619 73, 74, 0, 75, 54, 113, 55, 56, 57, 58,
620 59, 60, 61, 62, 63, 64, 65, 66, 67, 0,
621 68, 69, 70, 71, 0, 0, 0, 72, 73, 74,
622 0, 75, 54, 118, 55, 56, 57, 58, 59, 60,
623 61, 62, 63, 64, 65, 66, 67, 0, 68, 69,
624 70, 71, 0, 0, 0, 72, 73, 74, 0, 75,
625 56, 57, 58, 59, 60, 61, 62, 63, 64, 65,
626 66, 67, 0, 68, 69, 70, 71, 0, 0, 0,
627 72, 73, 74, 0, 75, 57, 58, 59, 60, 61,
628 62, 63, 64, 65, 66, 67, 0, 68, 69, 70,
629 71, 0, 0, 0, 72, 73, 74, 0, 75, 58,
630 59, 60, 61, 62, 63, 64, 65, 66, 67, 0,
631 68, 69, 70, 71, 0, 0, 0, 72, 73, 74,
632 0, 75, 60, 61, 62, 63, 64, 65, 66, 67,
633 0, 68, 69, 70, 71, 0, 0, 0, 72, 73,
634 74, 0, 75, 64, 65, 66, 67, 0, 68, 69,
635 70, 71, 0, 0, 0, 72, 73, 74, 0, 75
638 static const yysigned_char yycheck[] =
640 18, 19, 20, 23, 11, 0, 13, 24, 44, 45,
641 46, 46, 48, 7, 8, 9, 2, 46, 8, 46,
642 10, 11, 7, 8, 9, 13, 43, 19, 19, 13,
643 19, 49, 50, 46, 13, 53, 54, 55, 56, 57,
644 58, 59, 60, 61, 62, 63, 64, 65, 66, 67,
645 68, 69, 70, 71, 39, 49, 13, 43, 48, 77,
646 51, 50, 6, 19, 49, 37, 38, 39, 40, 76,
647 50, 78, 44, 45, 46, 13, 48, 39, -1, -1,
648 -1, -1, -1, -1, 104, -1, -1, 105, -1, -1,
649 -1, 3, 4, 5, 50, 7, 8, 9, 10, 11,
650 12, 13, 120, 15, 16, 17, 18, 39, 40, -1,
651 22, -1, 44, 45, 46, -1, 48, -1, -1, -1,
652 -1, -1, -1, -1, 36, -1, 38, -1, -1, 41,
653 42, -1, -1, -1, 46, -1, 48, 49, 21, -1,
654 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
655 33, 34, 35, -1, 37, 38, 39, 40, -1, -1,
656 -1, 44, 45, 46, -1, 48, 21, 50, 23, 24,
657 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
658 35, -1, 37, 38, 39, 40, -1, -1, -1, 44,
659 45, 46, -1, 48, 21, 50, 23, 24, 25, 26,
660 27, 28, 29, 30, 31, 32, 33, 34, 35, -1,
661 37, 38, 39, 40, -1, -1, -1, 44, 45, 46,
662 -1, 48, 21, 50, 23, 24, 25, 26, 27, 28,
663 29, 30, 31, 32, 33, 34, 35, -1, 37, 38,
664 39, 40, -1, -1, -1, 44, 45, 46, -1, 48,
665 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
666 34, 35, -1, 37, 38, 39, 40, -1, -1, -1,
667 44, 45, 46, -1, 48, 25, 26, 27, 28, 29,
668 30, 31, 32, 33, 34, 35, -1, 37, 38, 39,
669 40, -1, -1, -1, 44, 45, 46, -1, 48, 26,
670 27, 28, 29, 30, 31, 32, 33, 34, 35, -1,
671 37, 38, 39, 40, -1, -1, -1, 44, 45, 46,
672 -1, 48, 28, 29, 30, 31, 32, 33, 34, 35,
673 -1, 37, 38, 39, 40, -1, -1, -1, 44, 45,
674 46, -1, 48, 32, 33, 34, 35, -1, 37, 38,
675 39, 40, -1, -1, -1, 44, 45, 46, -1, 48
678 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
679 symbol of state STATE-NUM. */
680 static const unsigned char yystos[] =
682 0, 53, 54, 0, 3, 4, 5, 7, 8, 9,
683 10, 11, 12, 13, 15, 16, 17, 18, 22, 36,
684 38, 41, 42, 46, 48, 49, 55, 56, 57, 58,
685 63, 64, 65, 66, 67, 68, 70, 7, 8, 9,
686 49, 69, 69, 46, 69, 58, 67, 58, 58, 46,
687 46, 57, 68, 19, 21, 23, 24, 25, 26, 27,
688 28, 29, 30, 31, 32, 33, 34, 35, 37, 38,
689 39, 40, 44, 45, 46, 48, 13, 46, 13, 67,
690 68, 58, 58, 50, 58, 58, 58, 58, 58, 58,
691 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
692 58, 58, 58, 59, 60, 61, 69, 58, 39, 69,
693 50, 13, 50, 50, 6, 57, 58, 62, 50, 51,
694 19, 50, 58
697 #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
698 # define YYSIZE_T __SIZE_TYPE__
699 #endif
700 #if ! defined (YYSIZE_T) && defined (size_t)
701 # define YYSIZE_T size_t
702 #endif
703 #if ! defined (YYSIZE_T)
704 # if defined (__STDC__) || defined (__cplusplus)
705 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
706 # define YYSIZE_T size_t
707 # endif
708 #endif
709 #if ! defined (YYSIZE_T)
710 # define YYSIZE_T unsigned int
711 #endif
713 #define yyerrok (yyerrstatus = 0)
714 #define yyclearin (yychar = YYEMPTY)
715 #define YYEMPTY (-2)
716 #define YYEOF 0
718 #define YYACCEPT goto yyacceptlab
719 #define YYABORT goto yyabortlab
720 #define YYERROR goto yyerrlab1
722 /* Like YYERROR except do call yyerror. This remains here temporarily
723 to ease the transition to the new meaning of YYERROR, for GCC.
724 Once GCC version 2 has supplanted version 1, this can go. */
726 #define YYFAIL goto yyerrlab
728 #define YYRECOVERING() (!!yyerrstatus)
730 #define YYBACKUP(Token, Value) \
731 do \
732 if (yychar == YYEMPTY && yylen == 1) \
734 yychar = (Token); \
735 yylval = (Value); \
736 yytoken = YYTRANSLATE (yychar); \
737 YYPOPSTACK; \
738 goto yybackup; \
740 else \
742 yyerror ("syntax error: cannot back up");\
743 YYERROR; \
745 while (0)
747 #define YYTERROR 1
748 #define YYERRCODE 256
750 /* YYLLOC_DEFAULT -- Compute the default location (before the actions
751 are run). */
753 #ifndef YYLLOC_DEFAULT
754 # define YYLLOC_DEFAULT(Current, Rhs, N) \
755 Current.first_line = Rhs[1].first_line; \
756 Current.first_column = Rhs[1].first_column; \
757 Current.last_line = Rhs[N].last_line; \
758 Current.last_column = Rhs[N].last_column;
759 #endif
761 /* YYLEX -- calling `yylex' with the right arguments. */
763 #ifdef YYLEX_PARAM
764 # define YYLEX yylex (YYLEX_PARAM)
765 #else
766 # define YYLEX yylex ()
767 #endif
769 /* Enable debugging if requested. */
770 #if YYDEBUG
772 # ifndef YYFPRINTF
773 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
774 # define YYFPRINTF fprintf
775 # endif
777 # define YYDPRINTF(Args) \
778 do { \
779 if (yydebug) \
780 YYFPRINTF Args; \
781 } while (0)
783 # define YYDSYMPRINT(Args) \
784 do { \
785 if (yydebug) \
786 yysymprint Args; \
787 } while (0)
789 # define YYDSYMPRINTF(Title, Token, Value, Location) \
790 do { \
791 if (yydebug) \
793 YYFPRINTF (stderr, "%s ", Title); \
794 yysymprint (stderr, \
795 Token, Value); \
796 YYFPRINTF (stderr, "\n"); \
798 } while (0)
800 /*------------------------------------------------------------------.
801 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
802 | TOP (cinluded). |
803 `------------------------------------------------------------------*/
805 #if defined (__STDC__) || defined (__cplusplus)
806 static void
807 yy_stack_print (short *bottom, short *top)
808 #else
809 static void
810 yy_stack_print (bottom, top)
811 short *bottom;
812 short *top;
813 #endif
815 YYFPRINTF (stderr, "Stack now");
816 for (/* Nothing. */; bottom <= top; ++bottom)
817 YYFPRINTF (stderr, " %d", *bottom);
818 YYFPRINTF (stderr, "\n");
821 # define YY_STACK_PRINT(Bottom, Top) \
822 do { \
823 if (yydebug) \
824 yy_stack_print ((Bottom), (Top)); \
825 } while (0)
828 /*------------------------------------------------.
829 | Report that the YYRULE is going to be reduced. |
830 `------------------------------------------------*/
832 #if defined (__STDC__) || defined (__cplusplus)
833 static void
834 yy_reduce_print (int yyrule)
835 #else
836 static void
837 yy_reduce_print (yyrule)
838 int yyrule;
839 #endif
841 int yyi;
842 unsigned int yylineno = yyrline[yyrule];
843 YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ",
844 yyrule - 1, yylineno);
845 /* Print the symbols being reduced, and their result. */
846 for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
847 YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]);
848 YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]);
851 # define YY_REDUCE_PRINT(Rule) \
852 do { \
853 if (yydebug) \
854 yy_reduce_print (Rule); \
855 } while (0)
857 /* Nonzero means print parse trace. It is left uninitialized so that
858 multiple parsers can coexist. */
859 int yydebug;
860 #else /* !YYDEBUG */
861 # define YYDPRINTF(Args)
862 # define YYDSYMPRINT(Args)
863 # define YYDSYMPRINTF(Title, Token, Value, Location)
864 # define YY_STACK_PRINT(Bottom, Top)
865 # define YY_REDUCE_PRINT(Rule)
866 #endif /* !YYDEBUG */
869 /* YYINITDEPTH -- initial size of the parser's stacks. */
870 #ifndef YYINITDEPTH
871 # define YYINITDEPTH 200
872 #endif
874 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
875 if the built-in stack extension method is used).
877 Do not make this value too large; the results are undefined if
878 SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
879 evaluated with infinite-precision integer arithmetic. */
881 #if YYMAXDEPTH == 0
882 # undef YYMAXDEPTH
883 #endif
885 #ifndef YYMAXDEPTH
886 # define YYMAXDEPTH 10000
887 #endif
891 #if YYERROR_VERBOSE
893 # ifndef yystrlen
894 # if defined (__GLIBC__) && defined (_STRING_H)
895 # define yystrlen strlen
896 # else
897 /* Return the length of YYSTR. */
898 static YYSIZE_T
899 # if defined (__STDC__) || defined (__cplusplus)
900 yystrlen (const char *yystr)
901 # else
902 yystrlen (yystr)
903 const char *yystr;
904 # endif
906 register const char *yys = yystr;
908 while (*yys++ != '\0')
909 continue;
911 return yys - yystr - 1;
913 # endif
914 # endif
916 # ifndef yystpcpy
917 # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
918 # define yystpcpy stpcpy
919 # else
920 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
921 YYDEST. */
922 static char *
923 # if defined (__STDC__) || defined (__cplusplus)
924 yystpcpy (char *yydest, const char *yysrc)
925 # else
926 yystpcpy (yydest, yysrc)
927 char *yydest;
928 const char *yysrc;
929 # endif
931 register char *yyd = yydest;
932 register const char *yys = yysrc;
934 while ((*yyd++ = *yys++) != '\0')
935 continue;
937 return yyd - 1;
939 # endif
940 # endif
942 #endif /* !YYERROR_VERBOSE */
946 #if YYDEBUG
947 /*--------------------------------.
948 | Print this symbol on YYOUTPUT. |
949 `--------------------------------*/
951 #if defined (__STDC__) || defined (__cplusplus)
952 static void
953 yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep)
954 #else
955 static void
956 yysymprint (yyoutput, yytype, yyvaluep)
957 FILE *yyoutput;
958 int yytype;
959 YYSTYPE *yyvaluep;
960 #endif
962 /* Pacify ``unused variable'' warnings. */
963 (void) yyvaluep;
965 if (yytype < YYNTOKENS)
967 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
968 # ifdef YYPRINT
969 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
970 # endif
972 else
973 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
975 switch (yytype)
977 default:
978 break;
980 YYFPRINTF (yyoutput, ")");
983 #endif /* ! YYDEBUG */
984 /*-----------------------------------------------.
985 | Release the memory associated to this symbol. |
986 `-----------------------------------------------*/
988 #if defined (__STDC__) || defined (__cplusplus)
989 static void
990 yydestruct (int yytype, YYSTYPE *yyvaluep)
991 #else
992 static void
993 yydestruct (yytype, yyvaluep)
994 int yytype;
995 YYSTYPE *yyvaluep;
996 #endif
998 /* Pacify ``unused variable'' warnings. */
999 (void) yyvaluep;
1001 switch (yytype)
1004 default:
1005 break;
1010 /* Prevent warnings from -Wmissing-prototypes. */
1012 #ifdef YYPARSE_PARAM
1013 # if defined (__STDC__) || defined (__cplusplus)
1014 int yyparse (void *YYPARSE_PARAM);
1015 # else
1016 int yyparse ();
1017 # endif
1018 #else /* ! YYPARSE_PARAM */
1019 #if defined (__STDC__) || defined (__cplusplus)
1020 int yyparse (void);
1021 #else
1022 int yyparse ();
1023 #endif
1024 #endif /* ! YYPARSE_PARAM */
1028 /* The lookahead symbol. */
1029 int yychar;
1031 /* The semantic value of the lookahead symbol. */
1032 YYSTYPE yylval;
1034 /* Number of syntax errors so far. */
1035 int yynerrs;
1039 /*----------.
1040 | yyparse. |
1041 `----------*/
1043 #ifdef YYPARSE_PARAM
1044 # if defined (__STDC__) || defined (__cplusplus)
1045 int yyparse (void *YYPARSE_PARAM)
1046 # else
1047 int yyparse (YYPARSE_PARAM)
1048 void *YYPARSE_PARAM;
1049 # endif
1050 #else /* ! YYPARSE_PARAM */
1051 #if defined (__STDC__) || defined (__cplusplus)
1053 yyparse (void)
1054 #else
1056 yyparse ()
1058 #endif
1059 #endif
1062 register int yystate;
1063 register int yyn;
1064 int yyresult;
1065 /* Number of tokens to shift before error messages enabled. */
1066 int yyerrstatus;
1067 /* Lookahead token as an internal (translated) token number. */
1068 int yytoken = 0;
1070 /* Three stacks and their tools:
1071 `yyss': related to states,
1072 `yyvs': related to semantic values,
1073 `yyls': related to locations.
1075 Refer to the stacks thru separate pointers, to allow yyoverflow
1076 to xreallocate them elsewhere. */
1078 /* The state stack. */
1079 short yyssa[YYINITDEPTH];
1080 short *yyss = yyssa;
1081 register short *yyssp;
1083 /* The semantic value stack. */
1084 YYSTYPE yyvsa[YYINITDEPTH];
1085 YYSTYPE *yyvs = yyvsa;
1086 register YYSTYPE *yyvsp;
1090 #define YYPOPSTACK (yyvsp--, yyssp--)
1092 YYSIZE_T yystacksize = YYINITDEPTH;
1094 /* The variables used to return semantic value and location from the
1095 action routines. */
1096 YYSTYPE yyval;
1099 /* When reducing, the number of symbols on the RHS of the reduced
1100 rule. */
1101 int yylen;
1103 YYDPRINTF ((stderr, "Starting parse\n"));
1105 yystate = 0;
1106 yyerrstatus = 0;
1107 yynerrs = 0;
1108 yychar = YYEMPTY; /* Cause a token to be read. */
1110 /* Initialize stack pointers.
1111 Waste one element of value and location stack
1112 so that they stay on the same level as the state stack.
1113 The wasted elements are never initialized. */
1115 yyssp = yyss;
1116 yyvsp = yyvs;
1118 goto yysetstate;
1120 /*------------------------------------------------------------.
1121 | yynewstate -- Push a new state, which is found in yystate. |
1122 `------------------------------------------------------------*/
1123 yynewstate:
1124 /* In all cases, when you get here, the value and location stacks
1125 have just been pushed. so pushing a state here evens the stacks.
1127 yyssp++;
1129 yysetstate:
1130 *yyssp = yystate;
1132 if (yyss + yystacksize - 1 <= yyssp)
1134 /* Get the current used size of the three stacks, in elements. */
1135 YYSIZE_T yysize = yyssp - yyss + 1;
1137 #ifdef yyoverflow
1139 /* Give user a chance to xreallocate the stack. Use copies of
1140 these so that the &'s don't force the real ones into
1141 memory. */
1142 YYSTYPE *yyvs1 = yyvs;
1143 short *yyss1 = yyss;
1146 /* Each stack pointer address is followed by the size of the
1147 data in use in that stack, in bytes. This used to be a
1148 conditional around just the two extra args, but that might
1149 be undefined if yyoverflow is a macro. */
1150 yyoverflow ("parser stack overflow",
1151 &yyss1, yysize * sizeof (*yyssp),
1152 &yyvs1, yysize * sizeof (*yyvsp),
1154 &yystacksize);
1156 yyss = yyss1;
1157 yyvs = yyvs1;
1159 #else /* no yyoverflow */
1160 # ifndef YYSTACK_RELOCATE
1161 goto yyoverflowlab;
1162 # else
1163 /* Extend the stack our own way. */
1164 if (YYMAXDEPTH <= yystacksize)
1165 goto yyoverflowlab;
1166 yystacksize *= 2;
1167 if (YYMAXDEPTH < yystacksize)
1168 yystacksize = YYMAXDEPTH;
1171 short *yyss1 = yyss;
1172 union yyalloc *yyptr =
1173 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1174 if (! yyptr)
1175 goto yyoverflowlab;
1176 YYSTACK_RELOCATE (yyss);
1177 YYSTACK_RELOCATE (yyvs);
1179 # undef YYSTACK_RELOCATE
1180 if (yyss1 != yyssa)
1181 YYSTACK_FREE (yyss1);
1183 # endif
1184 #endif /* no yyoverflow */
1186 yyssp = yyss + yysize - 1;
1187 yyvsp = yyvs + yysize - 1;
1190 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1191 (unsigned long int) yystacksize));
1193 if (yyss + yystacksize - 1 <= yyssp)
1194 YYABORT;
1197 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1199 goto yybackup;
1201 /*-----------.
1202 | yybackup. |
1203 `-----------*/
1204 yybackup:
1206 /* Do appropriate processing given the current state. */
1207 /* Read a lookahead token if we need one and don't already have one. */
1208 /* yyresume: */
1210 /* First try to decide what to do without reference to lookahead token. */
1212 yyn = yypact[yystate];
1213 if (yyn == YYPACT_NINF)
1214 goto yydefault;
1216 /* Not known => get a lookahead token if don't already have one. */
1218 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1219 if (yychar == YYEMPTY)
1221 YYDPRINTF ((stderr, "Reading a token: "));
1222 yychar = YYLEX;
1225 if (yychar <= YYEOF)
1227 yychar = yytoken = YYEOF;
1228 YYDPRINTF ((stderr, "Now at end of input.\n"));
1230 else
1232 yytoken = YYTRANSLATE (yychar);
1233 YYDSYMPRINTF ("Next token is", yytoken, &yylval, &yylloc);
1236 /* If the proper action on seeing token YYTOKEN is to reduce or to
1237 detect an error, take that action. */
1238 yyn += yytoken;
1239 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1240 goto yydefault;
1241 yyn = yytable[yyn];
1242 if (yyn <= 0)
1244 if (yyn == 0 || yyn == YYTABLE_NINF)
1245 goto yyerrlab;
1246 yyn = -yyn;
1247 goto yyreduce;
1250 if (yyn == YYFINAL)
1251 YYACCEPT;
1253 /* Shift the lookahead token. */
1254 YYDPRINTF ((stderr, "Shifting token %s, ", yytname[yytoken]));
1256 /* Discard the token being shifted unless it is eof. */
1257 if (yychar != YYEOF)
1258 yychar = YYEMPTY;
1260 *++yyvsp = yylval;
1263 /* Count tokens shifted since error; after three, turn off error
1264 status. */
1265 if (yyerrstatus)
1266 yyerrstatus--;
1268 yystate = yyn;
1269 goto yynewstate;
1272 /*-----------------------------------------------------------.
1273 | yydefault -- do the default action for the current state. |
1274 `-----------------------------------------------------------*/
1275 yydefault:
1276 yyn = yydefact[yystate];
1277 if (yyn == 0)
1278 goto yyerrlab;
1279 goto yyreduce;
1282 /*-----------------------------.
1283 | yyreduce -- Do a reduction. |
1284 `-----------------------------*/
1285 yyreduce:
1286 /* yyn is the number of a rule to reduce with. */
1287 yylen = yyr2[yyn];
1289 /* If YYLEN is nonzero, implement the default value of the action:
1290 `$$ = $1'.
1292 Otherwise, the following line sets YYVAL to garbage.
1293 This behavior is undocumented and Bison
1294 users should not rely upon it. Assigning to YYVAL
1295 unconditionally makes the parser a bit smaller, and it avoids a
1296 GCC warning that YYVAL may be used uninitialized. */
1297 yyval = yyvsp[1-yylen];
1300 YY_REDUCE_PRINT (yyn);
1301 switch (yyn)
1303 case 2:
1304 #line 234 "p-exp.y"
1305 { current_type = NULL;
1306 search_field = 0;
1308 break;
1310 case 3:
1311 #line 237 "p-exp.y"
1313 break;
1315 case 6:
1316 #line 246 "p-exp.y"
1317 { write_exp_elt_opcode(OP_TYPE);
1318 write_exp_elt_type(yyvsp[0].tval);
1319 write_exp_elt_opcode(OP_TYPE);
1320 current_type = yyvsp[0].tval; }
1321 break;
1323 case 8:
1324 #line 254 "p-exp.y"
1325 { write_exp_elt_opcode (BINOP_COMMA); }
1326 break;
1328 case 9:
1329 #line 259 "p-exp.y"
1330 { write_exp_elt_opcode (UNOP_IND);
1331 if (current_type)
1332 current_type = TYPE_TARGET_TYPE (current_type); }
1333 break;
1335 case 10:
1336 #line 265 "p-exp.y"
1337 { write_exp_elt_opcode (UNOP_ADDR);
1338 if (current_type)
1339 current_type = TYPE_POINTER_TYPE (current_type); }
1340 break;
1342 case 11:
1343 #line 271 "p-exp.y"
1344 { write_exp_elt_opcode (UNOP_NEG); }
1345 break;
1347 case 12:
1348 #line 275 "p-exp.y"
1349 { write_exp_elt_opcode (UNOP_LOGICAL_NOT); }
1350 break;
1352 case 13:
1353 #line 279 "p-exp.y"
1354 { write_exp_elt_opcode (UNOP_PREINCREMENT); }
1355 break;
1357 case 14:
1358 #line 283 "p-exp.y"
1359 { write_exp_elt_opcode (UNOP_PREDECREMENT); }
1360 break;
1362 case 15:
1363 #line 286 "p-exp.y"
1364 { search_field = 1; }
1365 break;
1367 case 16:
1368 #line 289 "p-exp.y"
1369 { write_exp_elt_opcode (STRUCTOP_STRUCT);
1370 write_exp_string (yyvsp[0].sval);
1371 write_exp_elt_opcode (STRUCTOP_STRUCT);
1372 search_field = 0;
1373 if (current_type)
1374 { while (TYPE_CODE (current_type) == TYPE_CODE_PTR)
1375 current_type = TYPE_TARGET_TYPE (current_type);
1376 current_type = lookup_struct_elt_type (
1377 current_type, yyvsp[0].sval.ptr, 0); };
1379 break;
1381 case 17:
1382 #line 301 "p-exp.y"
1383 { char *arrayname;
1384 int arrayfieldindex;
1385 arrayfieldindex = is_pascal_string_type (
1386 current_type, NULL, NULL,
1387 NULL, NULL, &arrayname);
1388 if (arrayfieldindex)
1390 struct stoken stringsval;
1391 stringsval.ptr = alloca (strlen (arrayname) + 1);
1392 stringsval.length = strlen (arrayname);
1393 strcpy (stringsval.ptr, arrayname);
1394 current_type = TYPE_FIELD_TYPE (current_type,
1395 arrayfieldindex - 1);
1396 write_exp_elt_opcode (STRUCTOP_STRUCT);
1397 write_exp_string (stringsval);
1398 write_exp_elt_opcode (STRUCTOP_STRUCT);
1400 push_current_type (); }
1401 break;
1403 case 18:
1404 #line 320 "p-exp.y"
1405 { pop_current_type ();
1406 write_exp_elt_opcode (BINOP_SUBSCRIPT);
1407 if (current_type)
1408 current_type = TYPE_TARGET_TYPE (current_type); }
1409 break;
1411 case 19:
1412 #line 329 "p-exp.y"
1413 { push_current_type ();
1414 start_arglist (); }
1415 break;
1417 case 20:
1418 #line 332 "p-exp.y"
1419 { write_exp_elt_opcode (OP_FUNCALL);
1420 write_exp_elt_longcst ((LONGEST) end_arglist ());
1421 write_exp_elt_opcode (OP_FUNCALL);
1422 pop_current_type (); }
1423 break;
1425 case 22:
1426 #line 340 "p-exp.y"
1427 { arglist_len = 1; }
1428 break;
1430 case 23:
1431 #line 342 "p-exp.y"
1432 { arglist_len++; }
1433 break;
1435 case 24:
1436 #line 346 "p-exp.y"
1437 { if (current_type)
1439 /* Allow automatic dereference of classes. */
1440 if ((TYPE_CODE (current_type) == TYPE_CODE_PTR)
1441 && (TYPE_CODE (TYPE_TARGET_TYPE (current_type)) == TYPE_CODE_CLASS)
1442 && (TYPE_CODE (yyvsp[-3].tval) == TYPE_CODE_CLASS))
1443 write_exp_elt_opcode (UNOP_IND);
1445 write_exp_elt_opcode (UNOP_CAST);
1446 write_exp_elt_type (yyvsp[-3].tval);
1447 write_exp_elt_opcode (UNOP_CAST);
1448 current_type = yyvsp[-3].tval; }
1449 break;
1451 case 25:
1452 #line 361 "p-exp.y"
1454 break;
1456 case 26:
1457 #line 367 "p-exp.y"
1458 { write_exp_elt_opcode (BINOP_MUL); }
1459 break;
1461 case 27:
1462 #line 371 "p-exp.y"
1463 { write_exp_elt_opcode (BINOP_DIV); }
1464 break;
1466 case 28:
1467 #line 375 "p-exp.y"
1468 { write_exp_elt_opcode (BINOP_INTDIV); }
1469 break;
1471 case 29:
1472 #line 379 "p-exp.y"
1473 { write_exp_elt_opcode (BINOP_REM); }
1474 break;
1476 case 30:
1477 #line 383 "p-exp.y"
1478 { write_exp_elt_opcode (BINOP_ADD); }
1479 break;
1481 case 31:
1482 #line 387 "p-exp.y"
1483 { write_exp_elt_opcode (BINOP_SUB); }
1484 break;
1486 case 32:
1487 #line 391 "p-exp.y"
1488 { write_exp_elt_opcode (BINOP_LSH); }
1489 break;
1491 case 33:
1492 #line 395 "p-exp.y"
1493 { write_exp_elt_opcode (BINOP_RSH); }
1494 break;
1496 case 34:
1497 #line 399 "p-exp.y"
1498 { write_exp_elt_opcode (BINOP_EQUAL); }
1499 break;
1501 case 35:
1502 #line 403 "p-exp.y"
1503 { write_exp_elt_opcode (BINOP_NOTEQUAL); }
1504 break;
1506 case 36:
1507 #line 407 "p-exp.y"
1508 { write_exp_elt_opcode (BINOP_LEQ); }
1509 break;
1511 case 37:
1512 #line 411 "p-exp.y"
1513 { write_exp_elt_opcode (BINOP_GEQ); }
1514 break;
1516 case 38:
1517 #line 415 "p-exp.y"
1518 { write_exp_elt_opcode (BINOP_LESS); }
1519 break;
1521 case 39:
1522 #line 419 "p-exp.y"
1523 { write_exp_elt_opcode (BINOP_GTR); }
1524 break;
1526 case 40:
1527 #line 423 "p-exp.y"
1528 { write_exp_elt_opcode (BINOP_BITWISE_AND); }
1529 break;
1531 case 41:
1532 #line 427 "p-exp.y"
1533 { write_exp_elt_opcode (BINOP_BITWISE_XOR); }
1534 break;
1536 case 42:
1537 #line 431 "p-exp.y"
1538 { write_exp_elt_opcode (BINOP_BITWISE_IOR); }
1539 break;
1541 case 43:
1542 #line 435 "p-exp.y"
1543 { write_exp_elt_opcode (BINOP_ASSIGN); }
1544 break;
1546 case 44:
1547 #line 439 "p-exp.y"
1548 { write_exp_elt_opcode (OP_BOOL);
1549 write_exp_elt_longcst ((LONGEST) yyvsp[0].lval);
1550 write_exp_elt_opcode (OP_BOOL); }
1551 break;
1553 case 45:
1554 #line 445 "p-exp.y"
1555 { write_exp_elt_opcode (OP_BOOL);
1556 write_exp_elt_longcst ((LONGEST) yyvsp[0].lval);
1557 write_exp_elt_opcode (OP_BOOL); }
1558 break;
1560 case 46:
1561 #line 451 "p-exp.y"
1562 { write_exp_elt_opcode (OP_LONG);
1563 write_exp_elt_type (yyvsp[0].typed_val_int.type);
1564 write_exp_elt_longcst ((LONGEST)(yyvsp[0].typed_val_int.val));
1565 write_exp_elt_opcode (OP_LONG); }
1566 break;
1568 case 47:
1569 #line 458 "p-exp.y"
1570 { YYSTYPE val;
1571 parse_number (yyvsp[0].ssym.stoken.ptr, yyvsp[0].ssym.stoken.length, 0, &val);
1572 write_exp_elt_opcode (OP_LONG);
1573 write_exp_elt_type (val.typed_val_int.type);
1574 write_exp_elt_longcst ((LONGEST)val.typed_val_int.val);
1575 write_exp_elt_opcode (OP_LONG);
1577 break;
1579 case 48:
1580 #line 469 "p-exp.y"
1581 { write_exp_elt_opcode (OP_DOUBLE);
1582 write_exp_elt_type (yyvsp[0].typed_val_float.type);
1583 write_exp_elt_dblcst (yyvsp[0].typed_val_float.dval);
1584 write_exp_elt_opcode (OP_DOUBLE); }
1585 break;
1587 case 51:
1588 #line 483 "p-exp.y"
1589 { write_exp_elt_opcode (OP_LONG);
1590 write_exp_elt_type (builtin_type_int);
1591 CHECK_TYPEDEF (yyvsp[-1].tval);
1592 write_exp_elt_longcst ((LONGEST) TYPE_LENGTH (yyvsp[-1].tval));
1593 write_exp_elt_opcode (OP_LONG); }
1594 break;
1596 case 52:
1597 #line 491 "p-exp.y"
1598 { /* C strings are converted into array constants with
1599 an explicit null byte added at the end. Thus
1600 the array upper bound is the string length.
1601 There is no such thing in C as a completely empty
1602 string. */
1603 char *sp = yyvsp[0].sval.ptr; int count = yyvsp[0].sval.length;
1604 while (count-- > 0)
1606 write_exp_elt_opcode (OP_LONG);
1607 write_exp_elt_type (builtin_type_char);
1608 write_exp_elt_longcst ((LONGEST)(*sp++));
1609 write_exp_elt_opcode (OP_LONG);
1611 write_exp_elt_opcode (OP_LONG);
1612 write_exp_elt_type (builtin_type_char);
1613 write_exp_elt_longcst ((LONGEST)'\0');
1614 write_exp_elt_opcode (OP_LONG);
1615 write_exp_elt_opcode (OP_ARRAY);
1616 write_exp_elt_longcst ((LONGEST) 0);
1617 write_exp_elt_longcst ((LONGEST) (yyvsp[0].sval.length));
1618 write_exp_elt_opcode (OP_ARRAY); }
1619 break;
1621 case 53:
1622 #line 516 "p-exp.y"
1624 struct value * this_val;
1625 struct type * this_type;
1626 write_exp_elt_opcode (OP_THIS);
1627 write_exp_elt_opcode (OP_THIS);
1628 /* we need type of this */
1629 this_val = value_of_this (0);
1630 if (this_val)
1631 this_type = this_val->type;
1632 else
1633 this_type = NULL;
1634 if (this_type)
1636 if (TYPE_CODE (this_type) == TYPE_CODE_PTR)
1638 this_type = TYPE_TARGET_TYPE (this_type);
1639 write_exp_elt_opcode (UNOP_IND);
1643 current_type = this_type;
1645 break;
1647 case 54:
1648 #line 543 "p-exp.y"
1650 if (yyvsp[0].ssym.sym != 0)
1651 yyval.bval = SYMBOL_BLOCK_VALUE (yyvsp[0].ssym.sym);
1652 else
1654 struct symtab *tem =
1655 lookup_symtab (copy_name (yyvsp[0].ssym.stoken));
1656 if (tem)
1657 yyval.bval = BLOCKVECTOR_BLOCK (BLOCKVECTOR (tem), STATIC_BLOCK);
1658 else
1659 error ("No file or function \"%s\".",
1660 copy_name (yyvsp[0].ssym.stoken));
1663 break;
1665 case 55:
1666 #line 560 "p-exp.y"
1667 { struct symbol *tem
1668 = lookup_symbol (copy_name (yyvsp[0].sval), yyvsp[-2].bval,
1669 VAR_DOMAIN, (int *) NULL,
1670 (struct symtab **) NULL);
1671 if (!tem || SYMBOL_CLASS (tem) != LOC_BLOCK)
1672 error ("No function \"%s\" in specified context.",
1673 copy_name (yyvsp[0].sval));
1674 yyval.bval = SYMBOL_BLOCK_VALUE (tem); }
1675 break;
1677 case 56:
1678 #line 571 "p-exp.y"
1679 { struct symbol *sym;
1680 sym = lookup_symbol (copy_name (yyvsp[0].sval), yyvsp[-2].bval,
1681 VAR_DOMAIN, (int *) NULL,
1682 (struct symtab **) NULL);
1683 if (sym == 0)
1684 error ("No symbol \"%s\" in specified context.",
1685 copy_name (yyvsp[0].sval));
1687 write_exp_elt_opcode (OP_VAR_VALUE);
1688 /* block_found is set by lookup_symbol. */
1689 write_exp_elt_block (block_found);
1690 write_exp_elt_sym (sym);
1691 write_exp_elt_opcode (OP_VAR_VALUE); }
1692 break;
1694 case 57:
1695 #line 587 "p-exp.y"
1697 struct type *type = yyvsp[-2].tval;
1698 if (TYPE_CODE (type) != TYPE_CODE_STRUCT
1699 && TYPE_CODE (type) != TYPE_CODE_UNION)
1700 error ("`%s' is not defined as an aggregate type.",
1701 TYPE_NAME (type));
1703 write_exp_elt_opcode (OP_SCOPE);
1704 write_exp_elt_type (type);
1705 write_exp_string (yyvsp[0].sval);
1706 write_exp_elt_opcode (OP_SCOPE);
1708 break;
1710 case 59:
1711 #line 603 "p-exp.y"
1713 char *name = copy_name (yyvsp[0].sval);
1714 struct symbol *sym;
1715 struct minimal_symbol *msymbol;
1717 sym =
1718 lookup_symbol (name, (const struct block *) NULL,
1719 VAR_DOMAIN, (int *) NULL,
1720 (struct symtab **) NULL);
1721 if (sym)
1723 write_exp_elt_opcode (OP_VAR_VALUE);
1724 write_exp_elt_block (NULL);
1725 write_exp_elt_sym (sym);
1726 write_exp_elt_opcode (OP_VAR_VALUE);
1727 break;
1730 msymbol = lookup_minimal_symbol (name, NULL, NULL);
1731 if (msymbol != NULL)
1733 write_exp_msymbol (msymbol,
1734 lookup_function_type (builtin_type_int),
1735 builtin_type_int);
1737 else
1738 if (!have_full_symbols () && !have_partial_symbols ())
1739 error ("No symbol table is loaded. Use the \"file\" command.");
1740 else
1741 error ("No symbol \"%s\" in current context.", name);
1743 break;
1745 case 60:
1746 #line 637 "p-exp.y"
1747 { struct symbol *sym = yyvsp[0].ssym.sym;
1749 if (sym)
1751 if (symbol_read_needs_frame (sym))
1753 if (innermost_block == 0 ||
1754 contained_in (block_found,
1755 innermost_block))
1756 innermost_block = block_found;
1759 write_exp_elt_opcode (OP_VAR_VALUE);
1760 /* We want to use the selected frame, not
1761 another more inner frame which happens to
1762 be in the same block. */
1763 write_exp_elt_block (NULL);
1764 write_exp_elt_sym (sym);
1765 write_exp_elt_opcode (OP_VAR_VALUE);
1766 current_type = sym->type; }
1767 else if (yyvsp[0].ssym.is_a_field_of_this)
1769 struct value * this_val;
1770 struct type * this_type;
1771 /* Object pascal: it hangs off of `this'. Must
1772 not inadvertently convert from a method call
1773 to data ref. */
1774 if (innermost_block == 0 ||
1775 contained_in (block_found, innermost_block))
1776 innermost_block = block_found;
1777 write_exp_elt_opcode (OP_THIS);
1778 write_exp_elt_opcode (OP_THIS);
1779 write_exp_elt_opcode (STRUCTOP_PTR);
1780 write_exp_string (yyvsp[0].ssym.stoken);
1781 write_exp_elt_opcode (STRUCTOP_PTR);
1782 /* we need type of this */
1783 this_val = value_of_this (0);
1784 if (this_val)
1785 this_type = this_val->type;
1786 else
1787 this_type = NULL;
1788 if (this_type)
1789 current_type = lookup_struct_elt_type (
1790 this_type,
1791 copy_name (yyvsp[0].ssym.stoken), 0);
1792 else
1793 current_type = NULL;
1795 else
1797 struct minimal_symbol *msymbol;
1798 char *arg = copy_name (yyvsp[0].ssym.stoken);
1800 msymbol =
1801 lookup_minimal_symbol (arg, NULL, NULL);
1802 if (msymbol != NULL)
1804 write_exp_msymbol (msymbol,
1805 lookup_function_type (builtin_type_int),
1806 builtin_type_int);
1808 else if (!have_full_symbols () && !have_partial_symbols ())
1809 error ("No symbol table is loaded. Use the \"file\" command.");
1810 else
1811 error ("No symbol \"%s\" in current context.",
1812 copy_name (yyvsp[0].ssym.stoken));
1815 break;
1817 case 63:
1818 #line 721 "p-exp.y"
1819 { yyval.tval = lookup_member_type (builtin_type_int, yyvsp[-2].tval); }
1820 break;
1822 case 64:
1823 #line 726 "p-exp.y"
1824 { yyval.tval = lookup_pointer_type (yyvsp[0].tval); }
1825 break;
1827 case 65:
1828 #line 728 "p-exp.y"
1829 { yyval.tval = yyvsp[0].tsym.type; }
1830 break;
1832 case 66:
1833 #line 730 "p-exp.y"
1834 { yyval.tval = lookup_struct (copy_name (yyvsp[0].sval),
1835 expression_context_block); }
1836 break;
1838 case 67:
1839 #line 733 "p-exp.y"
1840 { yyval.tval = lookup_struct (copy_name (yyvsp[0].sval),
1841 expression_context_block); }
1842 break;
1844 case 68:
1845 #line 740 "p-exp.y"
1846 { yyval.sval = yyvsp[0].ssym.stoken; }
1847 break;
1849 case 69:
1850 #line 741 "p-exp.y"
1851 { yyval.sval = yyvsp[0].ssym.stoken; }
1852 break;
1854 case 70:
1855 #line 742 "p-exp.y"
1856 { yyval.sval = yyvsp[0].tsym.stoken; }
1857 break;
1859 case 71:
1860 #line 743 "p-exp.y"
1861 { yyval.sval = yyvsp[0].ssym.stoken; }
1862 break;
1867 /* Line 991 of yacc.c. */
1869 yyvsp -= yylen;
1870 yyssp -= yylen;
1873 YY_STACK_PRINT (yyss, yyssp);
1875 *++yyvsp = yyval;
1878 /* Now `shift' the result of the reduction. Determine what state
1879 that goes to, based on the state we popped back to and the rule
1880 number reduced by. */
1882 yyn = yyr1[yyn];
1884 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1885 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1886 yystate = yytable[yystate];
1887 else
1888 yystate = yydefgoto[yyn - YYNTOKENS];
1890 goto yynewstate;
1893 /*------------------------------------.
1894 | yyerrlab -- here on detecting error |
1895 `------------------------------------*/
1896 yyerrlab:
1897 /* If not already recovering from an error, report this error. */
1898 if (!yyerrstatus)
1900 ++yynerrs;
1901 #if YYERROR_VERBOSE
1902 yyn = yypact[yystate];
1904 if (YYPACT_NINF < yyn && yyn < YYLAST)
1906 YYSIZE_T yysize = 0;
1907 int yytype = YYTRANSLATE (yychar);
1908 char *yymsg;
1909 int yyx, yycount;
1911 yycount = 0;
1912 /* Start YYX at -YYN if negative to avoid negative indexes in
1913 YYCHECK. */
1914 for (yyx = yyn < 0 ? -yyn : 0;
1915 yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++)
1916 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1917 yysize += yystrlen (yytname[yyx]) + 15, yycount++;
1918 yysize += yystrlen ("syntax error, unexpected ") + 1;
1919 yysize += yystrlen (yytname[yytype]);
1920 yymsg = (char *) YYSTACK_ALLOC (yysize);
1921 if (yymsg != 0)
1923 char *yyp = yystpcpy (yymsg, "syntax error, unexpected ");
1924 yyp = yystpcpy (yyp, yytname[yytype]);
1926 if (yycount < 5)
1928 yycount = 0;
1929 for (yyx = yyn < 0 ? -yyn : 0;
1930 yyx < (int) (sizeof (yytname) / sizeof (char *));
1931 yyx++)
1932 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1934 const char *yyq = ! yycount ? ", expecting " : " or ";
1935 yyp = yystpcpy (yyp, yyq);
1936 yyp = yystpcpy (yyp, yytname[yyx]);
1937 yycount++;
1940 yyerror (yymsg);
1941 YYSTACK_FREE (yymsg);
1943 else
1944 yyerror ("syntax error; also virtual memory exhausted");
1946 else
1947 #endif /* YYERROR_VERBOSE */
1948 yyerror ("syntax error");
1953 if (yyerrstatus == 3)
1955 /* If just tried and failed to reuse lookahead token after an
1956 error, discard it. */
1958 /* Return failure if at end of input. */
1959 if (yychar == YYEOF)
1961 /* Pop the error token. */
1962 YYPOPSTACK;
1963 /* Pop the rest of the stack. */
1964 while (yyss < yyssp)
1966 YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
1967 yydestruct (yystos[*yyssp], yyvsp);
1968 YYPOPSTACK;
1970 YYABORT;
1973 YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc);
1974 yydestruct (yytoken, &yylval);
1975 yychar = YYEMPTY;
1979 /* Else will try to reuse lookahead token after shifting the error
1980 token. */
1981 goto yyerrlab2;
1984 /*----------------------------------------------------.
1985 | yyerrlab1 -- error raised explicitly by an action. |
1986 `----------------------------------------------------*/
1987 yyerrlab1:
1989 /* Suppress GCC warning that yyerrlab1 is unused when no action
1990 invokes YYERROR. MacOS 10.2.3's buggy "smart preprocessor"
1991 insists on the trailing semicolon. */
1992 #if defined (__GNUC_MINOR__) && 2093 <= (__GNUC__ * 1000 + __GNUC_MINOR__)
1993 __attribute__ ((__unused__));
1994 #endif
1997 goto yyerrlab2;
2000 /*---------------------------------------------------------------.
2001 | yyerrlab2 -- pop states until the error token can be shifted. |
2002 `---------------------------------------------------------------*/
2003 yyerrlab2:
2004 yyerrstatus = 3; /* Each real token shifted decrements this. */
2006 for (;;)
2008 yyn = yypact[yystate];
2009 if (yyn != YYPACT_NINF)
2011 yyn += YYTERROR;
2012 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
2014 yyn = yytable[yyn];
2015 if (0 < yyn)
2016 break;
2020 /* Pop the current state because it cannot handle the error token. */
2021 if (yyssp == yyss)
2022 YYABORT;
2024 YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
2025 yydestruct (yystos[yystate], yyvsp);
2026 yyvsp--;
2027 yystate = *--yyssp;
2029 YY_STACK_PRINT (yyss, yyssp);
2032 if (yyn == YYFINAL)
2033 YYACCEPT;
2035 YYDPRINTF ((stderr, "Shifting error token, "));
2037 *++yyvsp = yylval;
2040 yystate = yyn;
2041 goto yynewstate;
2044 /*-------------------------------------.
2045 | yyacceptlab -- YYACCEPT comes here. |
2046 `-------------------------------------*/
2047 yyacceptlab:
2048 yyresult = 0;
2049 goto yyreturn;
2051 /*-----------------------------------.
2052 | yyabortlab -- YYABORT comes here. |
2053 `-----------------------------------*/
2054 yyabortlab:
2055 yyresult = 1;
2056 goto yyreturn;
2058 #ifndef yyoverflow
2059 /*----------------------------------------------.
2060 | yyoverflowlab -- parser overflow comes here. |
2061 `----------------------------------------------*/
2062 yyoverflowlab:
2063 yyerror ("parser stack overflow");
2064 yyresult = 2;
2065 /* Fall through. */
2066 #endif
2068 yyreturn:
2069 #ifndef yyoverflow
2070 if (yyss != yyssa)
2071 YYSTACK_FREE (yyss);
2072 #endif
2073 return yyresult;
2077 #line 757 "p-exp.y"
2080 /* Take care of parsing a number (anything that starts with a digit).
2081 Set yylval and return the token type; update lexptr.
2082 LEN is the number of characters in it. */
2084 /*** Needs some error checking for the float case ***/
2086 static int
2087 parse_number (p, len, parsed_float, putithere)
2088 char *p;
2089 int len;
2090 int parsed_float;
2091 YYSTYPE *putithere;
2093 /* FIXME: Shouldn't these be unsigned? We don't deal with negative values
2094 here, and we do kind of silly things like cast to unsigned. */
2095 LONGEST n = 0;
2096 LONGEST prevn = 0;
2097 ULONGEST un;
2099 int i = 0;
2100 int c;
2101 int base = input_radix;
2102 int unsigned_p = 0;
2104 /* Number of "L" suffixes encountered. */
2105 int long_p = 0;
2107 /* We have found a "L" or "U" suffix. */
2108 int found_suffix = 0;
2110 ULONGEST high_bit;
2111 struct type *signed_type;
2112 struct type *unsigned_type;
2114 if (parsed_float)
2116 /* It's a float since it contains a point or an exponent. */
2117 char c;
2118 int num = 0; /* number of tokens scanned by scanf */
2119 char saved_char = p[len];
2121 p[len] = 0; /* null-terminate the token */
2122 if (sizeof (putithere->typed_val_float.dval) <= sizeof (float))
2123 num = sscanf (p, "%g%c", (float *) &putithere->typed_val_float.dval,&c);
2124 else if (sizeof (putithere->typed_val_float.dval) <= sizeof (double))
2125 num = sscanf (p, "%lg%c", (double *) &putithere->typed_val_float.dval,&c);
2126 else
2128 #ifdef SCANF_HAS_LONG_DOUBLE
2129 num = sscanf (p, "%Lg%c", &putithere->typed_val_float.dval,&c);
2130 #else
2131 /* Scan it into a double, then assign it to the long double.
2132 This at least wins with values representable in the range
2133 of doubles. */
2134 double temp;
2135 num = sscanf (p, "%lg%c", &temp,&c);
2136 putithere->typed_val_float.dval = temp;
2137 #endif
2139 p[len] = saved_char; /* restore the input stream */
2140 if (num != 1) /* check scanf found ONLY a float ... */
2141 return ERROR;
2142 /* See if it has `f' or `l' suffix (float or long double). */
2144 c = tolower (p[len - 1]);
2146 if (c == 'f')
2147 putithere->typed_val_float.type = builtin_type_float;
2148 else if (c == 'l')
2149 putithere->typed_val_float.type = builtin_type_long_double;
2150 else if (isdigit (c) || c == '.')
2151 putithere->typed_val_float.type = builtin_type_double;
2152 else
2153 return ERROR;
2155 return FLOAT;
2158 /* Handle base-switching prefixes 0x, 0t, 0d, 0 */
2159 if (p[0] == '0')
2160 switch (p[1])
2162 case 'x':
2163 case 'X':
2164 if (len >= 3)
2166 p += 2;
2167 base = 16;
2168 len -= 2;
2170 break;
2172 case 't':
2173 case 'T':
2174 case 'd':
2175 case 'D':
2176 if (len >= 3)
2178 p += 2;
2179 base = 10;
2180 len -= 2;
2182 break;
2184 default:
2185 base = 8;
2186 break;
2189 while (len-- > 0)
2191 c = *p++;
2192 if (c >= 'A' && c <= 'Z')
2193 c += 'a' - 'A';
2194 if (c != 'l' && c != 'u')
2195 n *= base;
2196 if (c >= '0' && c <= '9')
2198 if (found_suffix)
2199 return ERROR;
2200 n += i = c - '0';
2202 else
2204 if (base > 10 && c >= 'a' && c <= 'f')
2206 if (found_suffix)
2207 return ERROR;
2208 n += i = c - 'a' + 10;
2210 else if (c == 'l')
2212 ++long_p;
2213 found_suffix = 1;
2215 else if (c == 'u')
2217 unsigned_p = 1;
2218 found_suffix = 1;
2220 else
2221 return ERROR; /* Char not a digit */
2223 if (i >= base)
2224 return ERROR; /* Invalid digit in this base */
2226 /* Portably test for overflow (only works for nonzero values, so make
2227 a second check for zero). FIXME: Can't we just make n and prevn
2228 unsigned and avoid this? */
2229 if (c != 'l' && c != 'u' && (prevn >= n) && n != 0)
2230 unsigned_p = 1; /* Try something unsigned */
2232 /* Portably test for unsigned overflow.
2233 FIXME: This check is wrong; for example it doesn't find overflow
2234 on 0x123456789 when LONGEST is 32 bits. */
2235 if (c != 'l' && c != 'u' && n != 0)
2237 if ((unsigned_p && (ULONGEST) prevn >= (ULONGEST) n))
2238 error ("Numeric constant too large.");
2240 prevn = n;
2243 /* An integer constant is an int, a long, or a long long. An L
2244 suffix forces it to be long; an LL suffix forces it to be long
2245 long. If not forced to a larger size, it gets the first type of
2246 the above that it fits in. To figure out whether it fits, we
2247 shift it right and see whether anything remains. Note that we
2248 can't shift sizeof (LONGEST) * HOST_CHAR_BIT bits or more in one
2249 operation, because many compilers will warn about such a shift
2250 (which always produces a zero result). Sometimes TARGET_INT_BIT
2251 or TARGET_LONG_BIT will be that big, sometimes not. To deal with
2252 the case where it is we just always shift the value more than
2253 once, with fewer bits each time. */
2255 un = (ULONGEST)n >> 2;
2256 if (long_p == 0
2257 && (un >> (TARGET_INT_BIT - 2)) == 0)
2259 high_bit = ((ULONGEST)1) << (TARGET_INT_BIT-1);
2261 /* A large decimal (not hex or octal) constant (between INT_MAX
2262 and UINT_MAX) is a long or unsigned long, according to ANSI,
2263 never an unsigned int, but this code treats it as unsigned
2264 int. This probably should be fixed. GCC gives a warning on
2265 such constants. */
2267 unsigned_type = builtin_type_unsigned_int;
2268 signed_type = builtin_type_int;
2270 else if (long_p <= 1
2271 && (un >> (TARGET_LONG_BIT - 2)) == 0)
2273 high_bit = ((ULONGEST)1) << (TARGET_LONG_BIT-1);
2274 unsigned_type = builtin_type_unsigned_long;
2275 signed_type = builtin_type_long;
2277 else
2279 int shift;
2280 if (sizeof (ULONGEST) * HOST_CHAR_BIT < TARGET_LONG_LONG_BIT)
2281 /* A long long does not fit in a LONGEST. */
2282 shift = (sizeof (ULONGEST) * HOST_CHAR_BIT - 1);
2283 else
2284 shift = (TARGET_LONG_LONG_BIT - 1);
2285 high_bit = (ULONGEST) 1 << shift;
2286 unsigned_type = builtin_type_unsigned_long_long;
2287 signed_type = builtin_type_long_long;
2290 putithere->typed_val_int.val = n;
2292 /* If the high bit of the worked out type is set then this number
2293 has to be unsigned. */
2295 if (unsigned_p || (n & high_bit))
2297 putithere->typed_val_int.type = unsigned_type;
2299 else
2301 putithere->typed_val_int.type = signed_type;
2304 return INT;
2308 struct type_push
2310 struct type *stored;
2311 struct type_push *next;
2314 static struct type_push *tp_top = NULL;
2316 static void
2317 push_current_type (void)
2319 struct type_push *tpnew;
2320 tpnew = (struct type_push *) xmalloc (sizeof (struct type_push));
2321 tpnew->next = tp_top;
2322 tpnew->stored = current_type;
2323 current_type = NULL;
2324 tp_top = tpnew;
2327 static void
2328 pop_current_type (void)
2330 struct type_push *tp = tp_top;
2331 if (tp)
2333 current_type = tp->stored;
2334 tp_top = tp->next;
2335 xfree (tp);
2339 struct token
2341 char *operator;
2342 int token;
2343 enum exp_opcode opcode;
2346 static const struct token tokentab3[] =
2348 {"shr", RSH, BINOP_END},
2349 {"shl", LSH, BINOP_END},
2350 {"and", ANDAND, BINOP_END},
2351 {"div", DIV, BINOP_END},
2352 {"not", NOT, BINOP_END},
2353 {"mod", MOD, BINOP_END},
2354 {"inc", INCREMENT, BINOP_END},
2355 {"dec", DECREMENT, BINOP_END},
2356 {"xor", XOR, BINOP_END}
2359 static const struct token tokentab2[] =
2361 {"or", OR, BINOP_END},
2362 {"<>", NOTEQUAL, BINOP_END},
2363 {"<=", LEQ, BINOP_END},
2364 {">=", GEQ, BINOP_END},
2365 {":=", ASSIGN, BINOP_END},
2366 {"::", COLONCOLON, BINOP_END} };
2368 /* Allocate uppercased var */
2369 /* make an uppercased copy of tokstart */
2370 static char * uptok (tokstart, namelen)
2371 char *tokstart;
2372 int namelen;
2374 int i;
2375 char *uptokstart = (char *)xmalloc(namelen+1);
2376 for (i = 0;i <= namelen;i++)
2378 if ((tokstart[i]>='a' && tokstart[i]<='z'))
2379 uptokstart[i] = tokstart[i]-('a'-'A');
2380 else
2381 uptokstart[i] = tokstart[i];
2383 uptokstart[namelen]='\0';
2384 return uptokstart;
2386 /* Read one token, getting characters through lexptr. */
2389 static int
2390 yylex ()
2392 int c;
2393 int namelen;
2394 unsigned int i;
2395 char *tokstart;
2396 char *uptokstart;
2397 char *tokptr;
2398 char *p;
2399 int explen, tempbufindex;
2400 static char *tempbuf;
2401 static int tempbufsize;
2403 retry:
2405 prev_lexptr = lexptr;
2407 tokstart = lexptr;
2408 explen = strlen (lexptr);
2409 /* See if it is a special token of length 3. */
2410 if (explen > 2)
2411 for (i = 0; i < sizeof (tokentab3) / sizeof (tokentab3[0]); i++)
2412 if (strncasecmp (tokstart, tokentab3[i].operator, 3) == 0
2413 && (!isalpha (tokentab3[i].operator[0]) || explen == 3
2414 || (!isalpha (tokstart[3]) && !isdigit (tokstart[3]) && tokstart[3] != '_')))
2416 lexptr += 3;
2417 yylval.opcode = tokentab3[i].opcode;
2418 return tokentab3[i].token;
2421 /* See if it is a special token of length 2. */
2422 if (explen > 1)
2423 for (i = 0; i < sizeof (tokentab2) / sizeof (tokentab2[0]); i++)
2424 if (strncasecmp (tokstart, tokentab2[i].operator, 2) == 0
2425 && (!isalpha (tokentab2[i].operator[0]) || explen == 2
2426 || (!isalpha (tokstart[2]) && !isdigit (tokstart[2]) && tokstart[2] != '_')))
2428 lexptr += 2;
2429 yylval.opcode = tokentab2[i].opcode;
2430 return tokentab2[i].token;
2433 switch (c = *tokstart)
2435 case 0:
2436 return 0;
2438 case ' ':
2439 case '\t':
2440 case '\n':
2441 lexptr++;
2442 goto retry;
2444 case '\'':
2445 /* We either have a character constant ('0' or '\177' for example)
2446 or we have a quoted symbol reference ('foo(int,int)' in object pascal
2447 for example). */
2448 lexptr++;
2449 c = *lexptr++;
2450 if (c == '\\')
2451 c = parse_escape (&lexptr);
2452 else if (c == '\'')
2453 error ("Empty character constant.");
2455 yylval.typed_val_int.val = c;
2456 yylval.typed_val_int.type = builtin_type_char;
2458 c = *lexptr++;
2459 if (c != '\'')
2461 namelen = skip_quoted (tokstart) - tokstart;
2462 if (namelen > 2)
2464 lexptr = tokstart + namelen;
2465 if (lexptr[-1] != '\'')
2466 error ("Unmatched single quote.");
2467 namelen -= 2;
2468 tokstart++;
2469 uptokstart = uptok(tokstart,namelen);
2470 goto tryname;
2472 error ("Invalid character constant.");
2474 return INT;
2476 case '(':
2477 paren_depth++;
2478 lexptr++;
2479 return c;
2481 case ')':
2482 if (paren_depth == 0)
2483 return 0;
2484 paren_depth--;
2485 lexptr++;
2486 return c;
2488 case ',':
2489 if (comma_terminates && paren_depth == 0)
2490 return 0;
2491 lexptr++;
2492 return c;
2494 case '.':
2495 /* Might be a floating point number. */
2496 if (lexptr[1] < '0' || lexptr[1] > '9')
2497 goto symbol; /* Nope, must be a symbol. */
2498 /* FALL THRU into number case. */
2500 case '0':
2501 case '1':
2502 case '2':
2503 case '3':
2504 case '4':
2505 case '5':
2506 case '6':
2507 case '7':
2508 case '8':
2509 case '9':
2511 /* It's a number. */
2512 int got_dot = 0, got_e = 0, toktype;
2513 char *p = tokstart;
2514 int hex = input_radix > 10;
2516 if (c == '0' && (p[1] == 'x' || p[1] == 'X'))
2518 p += 2;
2519 hex = 1;
2521 else if (c == '0' && (p[1]=='t' || p[1]=='T' || p[1]=='d' || p[1]=='D'))
2523 p += 2;
2524 hex = 0;
2527 for (;; ++p)
2529 /* This test includes !hex because 'e' is a valid hex digit
2530 and thus does not indicate a floating point number when
2531 the radix is hex. */
2532 if (!hex && !got_e && (*p == 'e' || *p == 'E'))
2533 got_dot = got_e = 1;
2534 /* This test does not include !hex, because a '.' always indicates
2535 a decimal floating point number regardless of the radix. */
2536 else if (!got_dot && *p == '.')
2537 got_dot = 1;
2538 else if (got_e && (p[-1] == 'e' || p[-1] == 'E')
2539 && (*p == '-' || *p == '+'))
2540 /* This is the sign of the exponent, not the end of the
2541 number. */
2542 continue;
2543 /* We will take any letters or digits. parse_number will
2544 complain if past the radix, or if L or U are not final. */
2545 else if ((*p < '0' || *p > '9')
2546 && ((*p < 'a' || *p > 'z')
2547 && (*p < 'A' || *p > 'Z')))
2548 break;
2550 toktype = parse_number (tokstart, p - tokstart, got_dot|got_e, &yylval);
2551 if (toktype == ERROR)
2553 char *err_copy = (char *) alloca (p - tokstart + 1);
2555 memcpy (err_copy, tokstart, p - tokstart);
2556 err_copy[p - tokstart] = 0;
2557 error ("Invalid number \"%s\".", err_copy);
2559 lexptr = p;
2560 return toktype;
2563 case '+':
2564 case '-':
2565 case '*':
2566 case '/':
2567 case '|':
2568 case '&':
2569 case '^':
2570 case '~':
2571 case '!':
2572 case '@':
2573 case '<':
2574 case '>':
2575 case '[':
2576 case ']':
2577 case '?':
2578 case ':':
2579 case '=':
2580 case '{':
2581 case '}':
2582 symbol:
2583 lexptr++;
2584 return c;
2586 case '"':
2588 /* Build the gdb internal form of the input string in tempbuf,
2589 translating any standard C escape forms seen. Note that the
2590 buffer is null byte terminated *only* for the convenience of
2591 debugging gdb itself and printing the buffer contents when
2592 the buffer contains no embedded nulls. Gdb does not depend
2593 upon the buffer being null byte terminated, it uses the length
2594 string instead. This allows gdb to handle C strings (as well
2595 as strings in other languages) with embedded null bytes */
2597 tokptr = ++tokstart;
2598 tempbufindex = 0;
2600 do {
2601 /* Grow the static temp buffer if necessary, including allocating
2602 the first one on demand. */
2603 if (tempbufindex + 1 >= tempbufsize)
2605 tempbuf = (char *) xrealloc (tempbuf, tempbufsize += 64);
2608 switch (*tokptr)
2610 case '\0':
2611 case '"':
2612 /* Do nothing, loop will terminate. */
2613 break;
2614 case '\\':
2615 tokptr++;
2616 c = parse_escape (&tokptr);
2617 if (c == -1)
2619 continue;
2621 tempbuf[tempbufindex++] = c;
2622 break;
2623 default:
2624 tempbuf[tempbufindex++] = *tokptr++;
2625 break;
2627 } while ((*tokptr != '"') && (*tokptr != '\0'));
2628 if (*tokptr++ != '"')
2630 error ("Unterminated string in expression.");
2632 tempbuf[tempbufindex] = '\0'; /* See note above */
2633 yylval.sval.ptr = tempbuf;
2634 yylval.sval.length = tempbufindex;
2635 lexptr = tokptr;
2636 return (STRING);
2639 if (!(c == '_' || c == '$'
2640 || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')))
2641 /* We must have come across a bad character (e.g. ';'). */
2642 error ("Invalid character '%c' in expression.", c);
2644 /* It's a name. See how long it is. */
2645 namelen = 0;
2646 for (c = tokstart[namelen];
2647 (c == '_' || c == '$' || (c >= '0' && c <= '9')
2648 || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '<');)
2650 /* Template parameter lists are part of the name.
2651 FIXME: This mishandles `print $a<4&&$a>3'. */
2652 if (c == '<')
2654 int i = namelen;
2655 int nesting_level = 1;
2656 while (tokstart[++i])
2658 if (tokstart[i] == '<')
2659 nesting_level++;
2660 else if (tokstart[i] == '>')
2662 if (--nesting_level == 0)
2663 break;
2666 if (tokstart[i] == '>')
2667 namelen = i;
2668 else
2669 break;
2672 /* do NOT uppercase internals because of registers !!! */
2673 c = tokstart[++namelen];
2676 uptokstart = uptok(tokstart,namelen);
2678 /* The token "if" terminates the expression and is NOT
2679 removed from the input stream. */
2680 if (namelen == 2 && uptokstart[0] == 'I' && uptokstart[1] == 'F')
2682 return 0;
2685 lexptr += namelen;
2687 tryname:
2689 /* Catch specific keywords. Should be done with a data structure. */
2690 switch (namelen)
2692 case 6:
2693 if (DEPRECATED_STREQ (uptokstart, "OBJECT"))
2694 return CLASS;
2695 if (DEPRECATED_STREQ (uptokstart, "RECORD"))
2696 return STRUCT;
2697 if (DEPRECATED_STREQ (uptokstart, "SIZEOF"))
2698 return SIZEOF;
2699 break;
2700 case 5:
2701 if (DEPRECATED_STREQ (uptokstart, "CLASS"))
2702 return CLASS;
2703 if (DEPRECATED_STREQ (uptokstart, "FALSE"))
2705 yylval.lval = 0;
2706 return FALSEKEYWORD;
2708 break;
2709 case 4:
2710 if (DEPRECATED_STREQ (uptokstart, "TRUE"))
2712 yylval.lval = 1;
2713 return TRUEKEYWORD;
2715 if (DEPRECATED_STREQ (uptokstart, "SELF"))
2717 /* here we search for 'this' like
2718 inserted in FPC stabs debug info */
2719 static const char this_name[] = "this";
2721 if (lookup_symbol (this_name, expression_context_block,
2722 VAR_DOMAIN, (int *) NULL,
2723 (struct symtab **) NULL))
2724 return THIS;
2726 break;
2727 default:
2728 break;
2731 yylval.sval.ptr = tokstart;
2732 yylval.sval.length = namelen;
2734 if (*tokstart == '$')
2736 /* $ is the normal prefix for pascal hexadecimal values
2737 but this conflicts with the GDB use for debugger variables
2738 so in expression to enter hexadecimal values
2739 we still need to use C syntax with 0xff */
2740 write_dollar_variable (yylval.sval);
2741 return VARIABLE;
2744 /* Use token-type BLOCKNAME for symbols that happen to be defined as
2745 functions or symtabs. If this is not so, then ...
2746 Use token-type TYPENAME for symbols that happen to be defined
2747 currently as names of types; NAME for other symbols.
2748 The caller is not constrained to care about the distinction. */
2750 char *tmp = copy_name (yylval.sval);
2751 struct symbol *sym;
2752 int is_a_field_of_this = 0;
2753 int is_a_field = 0;
2754 int hextype;
2757 if (search_field && current_type)
2758 is_a_field = (lookup_struct_elt_type (current_type, tmp, 1) != NULL);
2759 if (is_a_field)
2760 sym = NULL;
2761 else
2762 sym = lookup_symbol (tmp, expression_context_block,
2763 VAR_DOMAIN,
2764 &is_a_field_of_this,
2765 (struct symtab **) NULL);
2766 /* second chance uppercased (as Free Pascal does). */
2767 if (!sym && !is_a_field_of_this && !is_a_field)
2769 for (i = 0; i <= namelen; i++)
2771 if ((tmp[i] >= 'a' && tmp[i] <= 'z'))
2772 tmp[i] -= ('a'-'A');
2774 if (search_field && current_type)
2775 is_a_field = (lookup_struct_elt_type (current_type, tmp, 1) != NULL);
2776 if (is_a_field)
2777 sym = NULL;
2778 else
2779 sym = lookup_symbol (tmp, expression_context_block,
2780 VAR_DOMAIN,
2781 &is_a_field_of_this,
2782 (struct symtab **) NULL);
2783 if (sym || is_a_field_of_this || is_a_field)
2784 for (i = 0; i <= namelen; i++)
2786 if ((tokstart[i] >= 'a' && tokstart[i] <= 'z'))
2787 tokstart[i] -= ('a'-'A');
2790 /* Third chance Capitalized (as GPC does). */
2791 if (!sym && !is_a_field_of_this && !is_a_field)
2793 for (i = 0; i <= namelen; i++)
2795 if (i == 0)
2797 if ((tmp[i] >= 'a' && tmp[i] <= 'z'))
2798 tmp[i] -= ('a'-'A');
2800 else
2801 if ((tmp[i] >= 'A' && tmp[i] <= 'Z'))
2802 tmp[i] -= ('A'-'a');
2804 if (search_field && current_type)
2805 is_a_field = (lookup_struct_elt_type (current_type, tmp, 1) != NULL);
2806 if (is_a_field)
2807 sym = NULL;
2808 else
2809 sym = lookup_symbol (tmp, expression_context_block,
2810 VAR_DOMAIN,
2811 &is_a_field_of_this,
2812 (struct symtab **) NULL);
2813 if (sym || is_a_field_of_this || is_a_field)
2814 for (i = 0; i <= namelen; i++)
2816 if (i == 0)
2818 if ((tokstart[i] >= 'a' && tokstart[i] <= 'z'))
2819 tokstart[i] -= ('a'-'A');
2821 else
2822 if ((tokstart[i] >= 'A' && tokstart[i] <= 'Z'))
2823 tokstart[i] -= ('A'-'a');
2827 if (is_a_field)
2829 tempbuf = (char *) xrealloc (tempbuf, namelen + 1);
2830 strncpy (tempbuf, tokstart, namelen); tempbuf [namelen] = 0;
2831 yylval.sval.ptr = tempbuf;
2832 yylval.sval.length = namelen;
2833 return FIELDNAME;
2835 /* Call lookup_symtab, not lookup_partial_symtab, in case there are
2836 no psymtabs (coff, xcoff, or some future change to blow away the
2837 psymtabs once once symbols are read). */
2838 if ((sym && SYMBOL_CLASS (sym) == LOC_BLOCK) ||
2839 lookup_symtab (tmp))
2841 yylval.ssym.sym = sym;
2842 yylval.ssym.is_a_field_of_this = is_a_field_of_this;
2843 return BLOCKNAME;
2845 if (sym && SYMBOL_CLASS (sym) == LOC_TYPEDEF)
2847 #if 1
2848 /* Despite the following flaw, we need to keep this code enabled.
2849 Because we can get called from check_stub_method, if we don't
2850 handle nested types then it screws many operations in any
2851 program which uses nested types. */
2852 /* In "A::x", if x is a member function of A and there happens
2853 to be a type (nested or not, since the stabs don't make that
2854 distinction) named x, then this code incorrectly thinks we
2855 are dealing with nested types rather than a member function. */
2857 char *p;
2858 char *namestart;
2859 struct symbol *best_sym;
2861 /* Look ahead to detect nested types. This probably should be
2862 done in the grammar, but trying seemed to introduce a lot
2863 of shift/reduce and reduce/reduce conflicts. It's possible
2864 that it could be done, though. Or perhaps a non-grammar, but
2865 less ad hoc, approach would work well. */
2867 /* Since we do not currently have any way of distinguishing
2868 a nested type from a non-nested one (the stabs don't tell
2869 us whether a type is nested), we just ignore the
2870 containing type. */
2872 p = lexptr;
2873 best_sym = sym;
2874 while (1)
2876 /* Skip whitespace. */
2877 while (*p == ' ' || *p == '\t' || *p == '\n')
2878 ++p;
2879 if (*p == ':' && p[1] == ':')
2881 /* Skip the `::'. */
2882 p += 2;
2883 /* Skip whitespace. */
2884 while (*p == ' ' || *p == '\t' || *p == '\n')
2885 ++p;
2886 namestart = p;
2887 while (*p == '_' || *p == '$' || (*p >= '0' && *p <= '9')
2888 || (*p >= 'a' && *p <= 'z')
2889 || (*p >= 'A' && *p <= 'Z'))
2890 ++p;
2891 if (p != namestart)
2893 struct symbol *cur_sym;
2894 /* As big as the whole rest of the expression, which is
2895 at least big enough. */
2896 char *ncopy = alloca (strlen (tmp)+strlen (namestart)+3);
2897 char *tmp1;
2899 tmp1 = ncopy;
2900 memcpy (tmp1, tmp, strlen (tmp));
2901 tmp1 += strlen (tmp);
2902 memcpy (tmp1, "::", 2);
2903 tmp1 += 2;
2904 memcpy (tmp1, namestart, p - namestart);
2905 tmp1[p - namestart] = '\0';
2906 cur_sym = lookup_symbol (ncopy, expression_context_block,
2907 VAR_DOMAIN, (int *) NULL,
2908 (struct symtab **) NULL);
2909 if (cur_sym)
2911 if (SYMBOL_CLASS (cur_sym) == LOC_TYPEDEF)
2913 best_sym = cur_sym;
2914 lexptr = p;
2916 else
2917 break;
2919 else
2920 break;
2922 else
2923 break;
2925 else
2926 break;
2929 yylval.tsym.type = SYMBOL_TYPE (best_sym);
2930 #else /* not 0 */
2931 yylval.tsym.type = SYMBOL_TYPE (sym);
2932 #endif /* not 0 */
2933 return TYPENAME;
2935 if ((yylval.tsym.type = lookup_primitive_typename (tmp)) != 0)
2936 return TYPENAME;
2938 /* Input names that aren't symbols but ARE valid hex numbers,
2939 when the input radix permits them, can be names or numbers
2940 depending on the parse. Note we support radixes > 16 here. */
2941 if (!sym &&
2942 ((tokstart[0] >= 'a' && tokstart[0] < 'a' + input_radix - 10) ||
2943 (tokstart[0] >= 'A' && tokstart[0] < 'A' + input_radix - 10)))
2945 YYSTYPE newlval; /* Its value is ignored. */
2946 hextype = parse_number (tokstart, namelen, 0, &newlval);
2947 if (hextype == INT)
2949 yylval.ssym.sym = sym;
2950 yylval.ssym.is_a_field_of_this = is_a_field_of_this;
2951 return NAME_OR_INT;
2955 free(uptokstart);
2956 /* Any other kind of symbol */
2957 yylval.ssym.sym = sym;
2958 yylval.ssym.is_a_field_of_this = is_a_field_of_this;
2959 return NAME;
2963 void
2964 yyerror (msg)
2965 char *msg;
2967 if (prev_lexptr)
2968 lexptr = prev_lexptr;
2970 error ("A %s in expression, near `%s'.", (msg ? msg : "error"), lexptr);