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)
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. */
40 #define YYSKELETON_NAME "yacc.c"
45 /* Using locations. */
46 #define YYLSP_NEEDED 0
53 /* Put the tokens into the symbol table, so that GDB and other debuggers
98 #define NAME_OR_INT 264
102 #define COLONCOLON 268
106 #define TRUEKEYWORD 272
107 #define FALSEKEYWORD 273
108 #define ABOVE_COMMA 274
121 #define DECREMENT 287
122 #define INCREMENT 288
125 #define BLOCKNAME 291
130 /* Copy the first part of user declarations. */
135 #include "gdb_string.h"
137 #include "expression.h"
139 #include "parser-defs.h"
140 #include "language.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 */
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
174 #define yy_yys pascal_yys
175 #define yystate pascal_state
176 #define yytmp pascal_tmp
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
196 #define YYDEBUG 1 /* Default to yydebug support */
199 #define YYFPRINTF parser_fprintf
203 static int yylex (void);
208 static char * uptok (char *, int);
211 /* Enabling traces. */
216 /* Enabling verbose error messages. */
217 #ifdef YYERROR_VERBOSE
218 # undef YYERROR_VERBOSE
219 # define YYERROR_VERBOSE 1
221 # define YYERROR_VERBOSE 0
224 #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
226 typedef union YYSTYPE
{
240 struct symtoken ssym
;
243 enum exp_opcode opcode
;
244 struct internalvar
*ivar
;
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
258 /* Copy the second part of user declarations. */
261 /* YYSTYPE gets defined by %union */
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
281 # define YYMALLOC xmalloc
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
291 # if defined (alloca) || defined (_ALLOCA_H)
292 # define YYSTACK_ALLOC alloca
295 # define YYSTACK_ALLOC __builtin_alloca
300 # ifdef YYSTACK_ALLOC
301 /* Pacify GCC's `empty if-body' warning. */
302 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
304 # if defined (__STDC__) || defined (__cplusplus)
305 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
306 # define YYSIZE_T size_t
308 # define YYSTACK_ALLOC YYMALLOC
309 # define YYSTACK_FREE YYFREE
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. */
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
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
337 # if defined (__GNUC__) && 1 < __GNUC__
338 # define YYCOPY(To, From, Count) \
339 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
341 # define YYCOPY(To, From, Count) \
344 register YYSIZE_T yyi; \
345 for (yyi = 0; yyi < (Count); yyi++) \
346 (To)[yyi] = (From)[yyi]; \
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
357 # define YYSTACK_RELOCATE(Stack) \
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); \
370 #if defined (__STDC__) || defined (__cplusplus)
371 typedef signed char yysigned_char
;
373 typedef short yysigned_char
;
376 /* YYFINAL -- State number of the termination state. */
378 /* YYLAST -- Last index in YYTABLE. */
381 /* YYNTOKENS -- Number of terminals. */
383 /* YYNNTS -- Number of nonterminals. */
385 /* YYNRULES -- Number of rules. */
387 /* YYNRULES -- Number of states. */
388 #define YYNSTATES 123
390 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
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,
433 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
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,
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,
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,
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
508 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
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,
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,
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,
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,
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
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,
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,
705 #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
706 # define YYSIZE_T __SIZE_TYPE__
708 #if ! defined (YYSIZE_T) && defined (size_t)
709 # define YYSIZE_T size_t
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
717 #if ! defined (YYSIZE_T)
718 # define YYSIZE_T unsigned int
721 #define yyerrok (yyerrstatus = 0)
722 #define yyclearin (yychar = YYEMPTY)
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) \
741 if (yychar == YYEMPTY && yylen == 1) \
745 yytoken = YYTRANSLATE (yychar); \
751 yyerror ("syntax error: cannot back up");\
757 #define YYERRCODE 256
759 /* YYLLOC_DEFAULT -- Compute the default location (before the actions
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)
770 /* YYLEX -- calling `yylex' with the right arguments. */
773 # define YYLEX yylex (YYLEX_PARAM)
775 # define YYLEX yylex ()
778 /* Enable debugging if requested. */
782 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
783 # define YYFPRINTF fprintf
786 # define YYDPRINTF(Args) \
792 # define YYDSYMPRINT(Args) \
798 # define YYDSYMPRINTF(Title, Token, Value, Location) \
802 YYFPRINTF (stderr, "%s ", Title); \
803 yysymprint (stderr, \
805 YYFPRINTF (stderr, "\n"); \
809 /*------------------------------------------------------------------.
810 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
812 `------------------------------------------------------------------*/
814 #if defined (__STDC__) || defined (__cplusplus)
816 yy_stack_print (short *bottom
, short *top
)
819 yy_stack_print (bottom
, top
)
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) \
833 yy_stack_print ((Bottom), (Top)); \
837 /*------------------------------------------------.
838 | Report that the YYRULE is going to be reduced. |
839 `------------------------------------------------*/
841 #if defined (__STDC__) || defined (__cplusplus)
843 yy_reduce_print (int yyrule
)
846 yy_reduce_print (yyrule
)
851 unsigned int yylno
= yyrline
[yyrule
];
852 YYFPRINTF (stderr
, "Reducing stack by rule %d (line %u), ",
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) \
863 yy_reduce_print (Rule); \
866 /* Nonzero means print parse trace. It is left uninitialized so that
867 multiple parsers can coexist. */
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. */
880 # define YYINITDEPTH 200
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
895 # define YYMAXDEPTH 10000
903 # if defined (__GLIBC__) && defined (_STRING_H)
904 # define yystrlen strlen
906 /* Return the length of YYSTR. */
908 # if defined (__STDC__) || defined (__cplusplus)
909 yystrlen (const char *yystr
)
915 register const char *yys
= yystr
;
917 while (*yys
++ != '\0')
920 return yys
- yystr
- 1;
926 # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
927 # define yystpcpy stpcpy
929 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
932 # if defined (__STDC__) || defined (__cplusplus)
933 yystpcpy (char *yydest
, const char *yysrc
)
935 yystpcpy (yydest
, yysrc
)
940 register char *yyd
= yydest
;
941 register const char *yys
= yysrc
;
943 while ((*yyd
++ = *yys
++) != '\0')
951 #endif /* !YYERROR_VERBOSE */
956 /*--------------------------------.
957 | Print this symbol on YYOUTPUT. |
958 `--------------------------------*/
960 #if defined (__STDC__) || defined (__cplusplus)
962 yysymprint (FILE *yyoutput
, int yytype
, YYSTYPE
*yyvaluep
)
965 yysymprint (yyoutput
, yytype
, yyvaluep
)
971 /* Pacify ``unused variable'' warnings. */
974 if (yytype
< YYNTOKENS
)
976 YYFPRINTF (yyoutput
, "token %s (", yytname
[yytype
]);
978 YYPRINT (yyoutput
, yytoknum
[yytype
], *yyvaluep
);
982 YYFPRINTF (yyoutput
, "nterm %s (", yytname
[yytype
]);
989 YYFPRINTF (yyoutput
, ")");
992 #endif /* ! YYDEBUG */
993 /*-----------------------------------------------.
994 | Release the memory associated to this symbol. |
995 `-----------------------------------------------*/
997 #if defined (__STDC__) || defined (__cplusplus)
999 yydestruct (int yytype
, YYSTYPE
*yyvaluep
)
1002 yydestruct (yytype
, yyvaluep
)
1007 /* Pacify ``unused variable'' warnings. */
1019 /* Prevent warnings from -Wmissing-prototypes. */
1021 #ifdef YYPARSE_PARAM
1022 # if defined (__STDC__) || defined (__cplusplus)
1023 int yyparse (void *YYPARSE_PARAM
);
1027 #else /* ! YYPARSE_PARAM */
1028 #if defined (__STDC__) || defined (__cplusplus)
1033 #endif /* ! YYPARSE_PARAM */
1037 /* The lookahead symbol. */
1040 /* The semantic value of the lookahead symbol. */
1043 /* Number of syntax errors so far. */
1052 #ifdef YYPARSE_PARAM
1053 # if defined (__STDC__) || defined (__cplusplus)
1054 int yyparse (void *YYPARSE_PARAM
)
1056 int yyparse (YYPARSE_PARAM
)
1057 void *YYPARSE_PARAM
;
1059 #else /* ! YYPARSE_PARAM */
1060 #if defined (__STDC__) || defined (__cplusplus)
1071 register int yystate
;
1074 /* Number of tokens to shift before error messages enabled. */
1076 /* Lookahead token as an internal (translated) token number. */
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
1108 /* When reducing, the number of symbols on the RHS of the reduced
1112 YYDPRINTF ((stderr
, "Starting parse\n"));
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. */
1129 /*------------------------------------------------------------.
1130 | yynewstate -- Push a new state, which is found in yystate. |
1131 `------------------------------------------------------------*/
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.
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;
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
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
),
1168 #else /* no yyoverflow */
1169 # ifndef YYSTACK_RELOCATE
1172 /* Extend the stack our own way. */
1173 if (YYMAXDEPTH
<= yystacksize
)
1176 if (YYMAXDEPTH
< yystacksize
)
1177 yystacksize
= YYMAXDEPTH
;
1180 short *yyss1
= yyss
;
1181 union yyalloc
*yyptr
=
1182 (union yyalloc
*) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize
));
1185 YYSTACK_RELOCATE (yyss
);
1186 YYSTACK_RELOCATE (yyvs
);
1188 # undef YYSTACK_RELOCATE
1190 YYSTACK_FREE (yyss1
);
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
)
1206 YYDPRINTF ((stderr
, "Entering state %d\n", yystate
));
1215 /* Do appropriate processing given the current state. */
1216 /* Read a lookahead token if we need one and don't already have one. */
1219 /* First try to decide what to do without reference to lookahead token. */
1221 yyn
= yypact
[yystate
];
1222 if (yyn
== YYPACT_NINF
)
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: "));
1234 if (yychar
<= YYEOF
)
1236 yychar
= yytoken
= YYEOF
;
1237 YYDPRINTF ((stderr
, "Now at end of input.\n"));
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. */
1248 if (yyn
< 0 || YYLAST
< yyn
|| yycheck
[yyn
] != yytoken
)
1253 if (yyn
== 0 || yyn
== YYTABLE_NINF
)
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
)
1272 /* Count tokens shifted since error; after three, turn off error
1281 /*-----------------------------------------------------------.
1282 | yydefault -- do the default action for the current state. |
1283 `-----------------------------------------------------------*/
1285 yyn
= yydefact
[yystate
];
1291 /*-----------------------------.
1292 | yyreduce -- Do a reduction. |
1293 `-----------------------------*/
1295 /* yyn is the number of a rule to reduce with. */
1298 /* If YYLEN is nonzero, implement the default value of the action:
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
);
1314 { current_type
= NULL
;
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
; }
1334 { write_exp_elt_opcode (BINOP_COMMA
); }
1339 { write_exp_elt_opcode (UNOP_IND
);
1341 current_type
= TYPE_TARGET_TYPE (current_type
); }
1346 { write_exp_elt_opcode (UNOP_ADDR
);
1348 current_type
= TYPE_POINTER_TYPE (current_type
); }
1353 { write_exp_elt_opcode (UNOP_NEG
); }
1358 { write_exp_elt_opcode (UNOP_LOGICAL_NOT
); }
1363 { write_exp_elt_opcode (UNOP_PREINCREMENT
); }
1368 { write_exp_elt_opcode (UNOP_PREDECREMENT
); }
1373 { search_field
= 1; }
1378 { write_exp_elt_opcode (STRUCTOP_STRUCT
);
1379 write_exp_string (yyvsp
[0].sval
);
1380 write_exp_elt_opcode (STRUCTOP_STRUCT
);
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); };
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 (); }
1414 { pop_current_type ();
1415 write_exp_elt_opcode (BINOP_SUBSCRIPT
);
1417 current_type
= TYPE_TARGET_TYPE (current_type
); }
1422 { push_current_type ();
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 (); }
1436 { arglist_len
= 1; }
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
; }
1467 { write_exp_elt_opcode (BINOP_MUL
); }
1472 { write_exp_elt_opcode (BINOP_DIV
); }
1477 { write_exp_elt_opcode (BINOP_INTDIV
); }
1482 { write_exp_elt_opcode (BINOP_REM
); }
1487 { write_exp_elt_opcode (BINOP_ADD
); }
1492 { write_exp_elt_opcode (BINOP_SUB
); }
1497 { write_exp_elt_opcode (BINOP_LSH
); }
1502 { write_exp_elt_opcode (BINOP_RSH
); }
1507 { write_exp_elt_opcode (BINOP_EQUAL
); }
1512 { write_exp_elt_opcode (BINOP_NOTEQUAL
); }
1517 { write_exp_elt_opcode (BINOP_LEQ
); }
1522 { write_exp_elt_opcode (BINOP_GEQ
); }
1527 { write_exp_elt_opcode (BINOP_LESS
); }
1532 { write_exp_elt_opcode (BINOP_GTR
); }
1537 { write_exp_elt_opcode (BINOP_BITWISE_AND
); }
1542 { write_exp_elt_opcode (BINOP_BITWISE_XOR
); }
1547 { write_exp_elt_opcode (BINOP_BITWISE_IOR
); }
1552 { write_exp_elt_opcode (BINOP_ASSIGN
); }
1557 { write_exp_elt_opcode (OP_BOOL
);
1558 write_exp_elt_longcst ((LONGEST
) yyvsp
[0].lval
);
1559 write_exp_elt_opcode (OP_BOOL
); }
1564 { write_exp_elt_opcode (OP_BOOL
);
1565 write_exp_elt_longcst ((LONGEST
) yyvsp
[0].lval
);
1566 write_exp_elt_opcode (OP_BOOL
); }
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
); }
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
);
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
); }
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
); }
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
1612 char *sp
= yyvsp
[0].sval
.ptr
; int count
= yyvsp
[0].sval
.length
;
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
); }
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);
1640 this_type
= value_type (this_val
);
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
;
1659 if (yyvsp
[0].ssym
.sym
!= 0)
1660 yyval
.bval
= SYMBOL_BLOCK_VALUE (yyvsp
[0].ssym
.sym
);
1663 struct symtab
*tem
=
1664 lookup_symtab (copy_name (yyvsp
[0].ssym
.stoken
));
1666 yyval
.bval
= BLOCKVECTOR_BLOCK (BLOCKVECTOR (tem
), STATIC_BLOCK
);
1668 error ("No file or function \"%s\".",
1669 copy_name (yyvsp
[0].ssym
.stoken
));
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
); }
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
);
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
); }
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.",
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
);
1722 char *name
= copy_name (yyvsp
[0].sval
);
1724 struct minimal_symbol
*msymbol
;
1727 lookup_symbol (name
, (const struct block
*) NULL
,
1728 VAR_DOMAIN
, (int *) NULL
,
1729 (struct symtab
**) NULL
);
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
);
1739 msymbol
= lookup_minimal_symbol (name
, NULL
, NULL
);
1740 if (msymbol
!= NULL
)
1742 write_exp_msymbol (msymbol
,
1743 lookup_function_type (builtin_type_int
),
1747 if (!have_full_symbols () && !have_partial_symbols ())
1748 error ("No symbol table is loaded. Use the \"file\" command.");
1750 error ("No symbol \"%s\" in current context.", name
);
1756 { struct symbol
*sym
= yyvsp
[0].ssym
.sym
;
1760 if (symbol_read_needs_frame (sym
))
1762 if (innermost_block
== 0 ||
1763 contained_in (block_found
,
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
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);
1794 this_type
= value_type (this_val
);
1798 current_type
= lookup_struct_elt_type (
1800 copy_name (yyvsp
[0].ssym
.stoken
), 0);
1802 current_type
= NULL
;
1806 struct minimal_symbol
*msymbol
;
1807 char *arg
= copy_name (yyvsp
[0].ssym
.stoken
);
1810 lookup_minimal_symbol (arg
, NULL
, NULL
);
1811 if (msymbol
!= NULL
)
1813 write_exp_msymbol (msymbol
,
1814 lookup_function_type (builtin_type_int
),
1817 else if (!have_full_symbols () && !have_partial_symbols ())
1818 error ("No symbol table is loaded. Use the \"file\" command.");
1820 error ("No symbol \"%s\" in current context.",
1821 copy_name (yyvsp
[0].ssym
.stoken
));
1828 { yyval
.tval
= lookup_member_type (builtin_type_int
, yyvsp
[-2].tval
); }
1833 { yyval
.tval
= lookup_pointer_type (yyvsp
[0].tval
); }
1838 { yyval
.tval
= yyvsp
[0].tsym
.type
; }
1843 { yyval
.tval
= lookup_struct (copy_name (yyvsp
[0].sval
),
1844 expression_context_block
); }
1849 { yyval
.tval
= lookup_struct (copy_name (yyvsp
[0].sval
),
1850 expression_context_block
); }
1855 { yyval
.sval
= yyvsp
[0].ssym
.stoken
; }
1860 { yyval
.sval
= yyvsp
[0].ssym
.stoken
; }
1865 { yyval
.sval
= yyvsp
[0].tsym
.stoken
; }
1870 { yyval
.sval
= yyvsp
[0].ssym
.stoken
; }
1876 /* Line 1000 of yacc.c. */
1877 #line 1878 "p-exp.c.tmp"
1883 YY_STACK_PRINT (yyss
, yyssp
);
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. */
1894 yystate
= yypgoto
[yyn
- YYNTOKENS
] + *yyssp
;
1895 if (0 <= yystate
&& yystate
<= YYLAST
&& yycheck
[yystate
] == *yyssp
)
1896 yystate
= yytable
[yystate
];
1898 yystate
= yydefgoto
[yyn
- YYNTOKENS
];
1903 /*------------------------------------.
1904 | yyerrlab -- here on detecting error |
1905 `------------------------------------*/
1907 /* If not already recovering from an error, report this error. */
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
;
1922 /* Start YYX at -YYN if negative to avoid negative indexes in
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
;
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
]);
1943 yysize
+= (sizeof ("syntax error, unexpected ")
1944 + yystrlen (yytname
[yytype
]));
1945 yymsg
= (char *) YYSTACK_ALLOC (yysize
);
1948 char *yyp
= yystpcpy (yymsg
, "syntax error, unexpected ");
1949 yyp
= yystpcpy (yyp
, yytname
[yytype
]);
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
]);
1963 YYSTACK_FREE (yymsg
);
1966 yyerror ("syntax error; also virtual memory exhausted");
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
)
1990 YYDSYMPRINTF ("Error: popping", yystos
[*yyssp
], yyvsp
, yylsp
);
1991 yydestruct (yystos
[*yyssp
], yyvsp
);
1996 YYDSYMPRINTF ("Error: discarding", yytoken
, &yylval
, &yylloc
);
1997 yydestruct (yytoken
, &yylval
);
2003 /* Else will try to reuse lookahead token after shifting the error
2008 /*---------------------------------------------------.
2009 | yyerrorlab -- error raised explicitly by YYERROR. |
2010 `---------------------------------------------------*/
2014 /* Pacify GCC when the user code never invokes YYERROR and the label
2015 yyerrorlab therefore never appears in user code. */
2026 /*-------------------------------------------------------------.
2027 | yyerrlab1 -- common code for both syntax error and YYERROR. |
2028 `-------------------------------------------------------------*/
2030 yyerrstatus
= 3; /* Each real token shifted decrements this. */
2034 yyn
= yypact
[yystate
];
2035 if (yyn
!= YYPACT_NINF
)
2038 if (0 <= yyn
&& yyn
<= YYLAST
&& yycheck
[yyn
] == YYTERROR
)
2046 /* Pop the current state because it cannot handle the error token. */
2050 YYDSYMPRINTF ("Error: popping", yystos
[*yyssp
], yyvsp
, yylsp
);
2051 yydestruct (yystos
[yystate
], yyvsp
);
2054 YY_STACK_PRINT (yyss
, yyssp
);
2060 YYDPRINTF ((stderr
, "Shifting error token, "));
2069 /*-------------------------------------.
2070 | yyacceptlab -- YYACCEPT comes here. |
2071 `-------------------------------------*/
2076 /*-----------------------------------.
2077 | yyabortlab -- YYABORT comes here. |
2078 `-----------------------------------*/
2084 /*----------------------------------------------.
2085 | yyoverflowlab -- parser overflow comes here. |
2086 `----------------------------------------------*/
2088 yyerror ("parser stack overflow");
2096 YYSTACK_FREE (yyss
);
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 ***/
2112 parse_number (p
, len
, parsed_float
, 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. */
2126 int base
= input_radix
;
2129 /* Number of "L" suffixes encountered. */
2132 /* We have found a "L" or "U" suffix. */
2133 int found_suffix
= 0;
2136 struct type
*signed_type
;
2137 struct type
*unsigned_type
;
2141 /* It's a float since it contains a point or an exponent. */
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 ... */
2152 /* See if it has `f' or `l' suffix (float or long double). */
2154 c
= tolower (p
[len
- 1]);
2157 putithere
->typed_val_float
.type
= builtin_type_float
;
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
;
2168 /* Handle base-switching prefixes 0x, 0t, 0d, 0 */
2202 if (c
>= 'A' && c
<= 'Z')
2204 if (c
!= 'l' && c
!= 'u')
2206 if (c
>= '0' && c
<= '9')
2214 if (base
> 10 && c
>= 'a' && c
<= 'f')
2218 n
+= i
= c
- 'a' + 10;
2231 return ERROR
; /* Char not a digit */
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.");
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;
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
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
;
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);
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
;
2311 putithere
->typed_val_int
.type
= signed_type
;
2320 struct type
*stored
;
2321 struct type_push
*next
;
2324 static struct type_push
*tp_top
= NULL
;
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
;
2338 pop_current_type (void)
2340 struct type_push
*tp
= tp_top
;
2343 current_type
= tp
->stored
;
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
)
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');
2391 uptokstart
[i
] = tokstart
[i
];
2393 uptokstart
[namelen
]='\0';
2396 /* Read one token, getting characters through lexptr. */
2409 int explen
, tempbufindex
;
2410 static char *tempbuf
;
2411 static int tempbufsize
;
2415 prev_lexptr
= lexptr
;
2418 explen
= strlen (lexptr
);
2419 /* See if it is a special token of length 3. */
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] != '_')))
2427 yylval
.opcode
= tokentab3
[i
].opcode
;
2428 return tokentab3
[i
].token
;
2431 /* See if it is a special token of length 2. */
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] != '_')))
2439 yylval
.opcode
= tokentab2
[i
].opcode
;
2440 return tokentab2
[i
].token
;
2443 switch (c
= *tokstart
)
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
2461 c
= parse_escape (&lexptr
);
2463 error ("Empty character constant.");
2465 yylval
.typed_val_int
.val
= c
;
2466 yylval
.typed_val_int
.type
= builtin_type_char
;
2471 namelen
= skip_quoted (tokstart
) - tokstart
;
2474 lexptr
= tokstart
+ namelen
;
2475 if (lexptr
[-1] != '\'')
2476 error ("Unmatched single quote.");
2479 uptokstart
= uptok(tokstart
,namelen
);
2482 error ("Invalid character constant.");
2492 if (paren_depth
== 0)
2499 if (comma_terminates
&& paren_depth
== 0)
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. */
2521 /* It's a number. */
2522 int got_dot
= 0, got_e
= 0, toktype
;
2524 int hex
= input_radix
> 10;
2526 if (c
== '0' && (p
[1] == 'x' || p
[1] == 'X'))
2531 else if (c
== '0' && (p
[1]=='t' || p
[1]=='T' || p
[1]=='d' || p
[1]=='D'))
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
== '.')
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
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')))
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
);
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
;
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);
2622 /* Do nothing, loop will terminate. */
2626 c
= parse_escape (&tokptr
);
2631 tempbuf
[tempbufindex
++] = c
;
2634 tempbuf
[tempbufindex
++] = *tokptr
++;
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
;
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. */
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'. */
2665 int nesting_level
= 1;
2666 while (tokstart
[++i
])
2668 if (tokstart
[i
] == '<')
2670 else if (tokstart
[i
] == '>')
2672 if (--nesting_level
== 0)
2676 if (tokstart
[i
] == '>')
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')
2699 /* Catch specific keywords. Should be done with a data structure. */
2703 if (DEPRECATED_STREQ (uptokstart
, "OBJECT"))
2705 if (DEPRECATED_STREQ (uptokstart
, "RECORD"))
2707 if (DEPRECATED_STREQ (uptokstart
, "SIZEOF"))
2711 if (DEPRECATED_STREQ (uptokstart
, "CLASS"))
2713 if (DEPRECATED_STREQ (uptokstart
, "FALSE"))
2716 return FALSEKEYWORD
;
2720 if (DEPRECATED_STREQ (uptokstart
, "TRUE"))
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
))
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
);
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
);
2762 int is_a_field_of_this
= 0;
2767 if (search_field
&& current_type
)
2768 is_a_field
= (lookup_struct_elt_type (current_type
, tmp
, 1) != NULL
);
2772 sym
= lookup_symbol (tmp
, expression_context_block
,
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
);
2789 sym
= lookup_symbol (tmp
, expression_context_block
,
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
++)
2807 if ((tmp
[i
] >= 'a' && tmp
[i
] <= 'z'))
2808 tmp
[i
] -= ('a'-'A');
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
);
2819 sym
= lookup_symbol (tmp
, expression_context_block
,
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
++)
2828 if ((tokstart
[i
] >= 'a' && tokstart
[i
] <= 'z'))
2829 tokstart
[i
] -= ('a'-'A');
2832 if ((tokstart
[i
] >= 'A' && tokstart
[i
] <= 'Z'))
2833 tokstart
[i
] -= ('A'-'a');
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
;
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
;
2855 if (sym
&& SYMBOL_CLASS (sym
) == LOC_TYPEDEF
)
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. */
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
2886 /* Skip whitespace. */
2887 while (*p
== ' ' || *p
== '\t' || *p
== '\n')
2889 if (*p
== ':' && p
[1] == ':')
2891 /* Skip the `::'. */
2893 /* Skip whitespace. */
2894 while (*p
== ' ' || *p
== '\t' || *p
== '\n')
2897 while (*p
== '_' || *p
== '$' || (*p
>= '0' && *p
<= '9')
2898 || (*p
>= 'a' && *p
<= 'z')
2899 || (*p
>= 'A' && *p
<= 'Z'))
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);
2910 memcpy (tmp1
, tmp
, strlen (tmp
));
2911 tmp1
+= strlen (tmp
);
2912 memcpy (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
);
2921 if (SYMBOL_CLASS (cur_sym
) == LOC_TYPEDEF
)
2939 yylval
.tsym
.type
= SYMBOL_TYPE (best_sym
);
2941 yylval
.tsym
.type
= SYMBOL_TYPE (sym
);
2946 = language_lookup_primitive_type_by_name (current_language
,
2947 current_gdbarch
, tmp
);
2948 if (yylval
.tsym
.type
!= NULL
)
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. */
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
);
2962 yylval
.ssym
.sym
= sym
;
2963 yylval
.ssym
.is_a_field_of_this
= is_a_field_of_this
;
2969 /* Any other kind of symbol */
2970 yylval
.ssym
.sym
= sym
;
2971 yylval
.ssym
.is_a_field_of_this
= is_a_field_of_this
;
2981 lexptr
= prev_lexptr
;
2983 error ("A %s in expression, near `%s'.", (msg
? msg
: "error"), lexptr
);