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 #define parse_type builtin_type (parse_gdbarch)
149 /* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc),
150 as well as gratuitiously global symbol names, so we can have multiple
151 yacc generated parsers in gdb. Note that these are only the variables
152 produced by yacc. If other parser generators (bison, byacc, etc) produce
153 additional global names that conflict at link time, then those parser
154 generators need to be fixed instead of adding those names to this list. */
156 #define yymaxdepth pascal_maxdepth
157 #define yyparse pascal_parse
158 #define yylex pascal_lex
159 #define yyerror pascal_error
160 #define yylval pascal_lval
161 #define yychar pascal_char
162 #define yydebug pascal_debug
163 #define yypact pascal_pact
164 #define yyr1 pascal_r1
165 #define yyr2 pascal_r2
166 #define yydef pascal_def
167 #define yychk pascal_chk
168 #define yypgo pascal_pgo
169 #define yyact pascal_act
170 #define yyexca pascal_exca
171 #define yyerrflag pascal_errflag
172 #define yynerrs pascal_nerrs
173 #define yyps pascal_ps
174 #define yypv pascal_pv
176 #define yy_yys pascal_yys
177 #define yystate pascal_state
178 #define yytmp pascal_tmp
180 #define yy_yyv pascal_yyv
181 #define yyval pascal_val
182 #define yylloc pascal_lloc
183 #define yyreds pascal_reds /* With YYDEBUG defined */
184 #define yytoks pascal_toks /* With YYDEBUG defined */
185 #define yyname pascal_name /* With YYDEBUG defined */
186 #define yyrule pascal_rule /* With YYDEBUG defined */
187 #define yylhs pascal_yylhs
188 #define yylen pascal_yylen
189 #define yydefred pascal_yydefred
190 #define yydgoto pascal_yydgoto
191 #define yysindex pascal_yysindex
192 #define yyrindex pascal_yyrindex
193 #define yygindex pascal_yygindex
194 #define yytable pascal_yytable
195 #define yycheck pascal_yycheck
198 #define YYDEBUG 1 /* Default to yydebug support */
201 #define YYFPRINTF parser_fprintf
205 static int yylex (void);
210 static char * uptok (char *, int);
213 /* Enabling traces. */
218 /* Enabling verbose error messages. */
219 #ifdef YYERROR_VERBOSE
220 # undef YYERROR_VERBOSE
221 # define YYERROR_VERBOSE 1
223 # define YYERROR_VERBOSE 0
226 #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
228 typedef union YYSTYPE {
242 struct symtoken ssym;
245 enum exp_opcode opcode;
246 struct internalvar *ivar;
251 /* Line 191 of yacc.c. */
252 #line 253 "p-exp.c.tmp"
253 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
254 # define YYSTYPE_IS_DECLARED 1
255 # define YYSTYPE_IS_TRIVIAL 1
260 /* Copy the second part of user declarations. */
263 /* YYSTYPE gets defined by %union */
265 parse_number (char *, int, int, YYSTYPE *);
267 static struct type *current_type;
268 static int leftdiv_is_integer;
269 static void push_current_type (void);
270 static void pop_current_type (void);
271 static int search_field;
274 /* Line 214 of yacc.c. */
275 #line 276 "p-exp.c.tmp"
277 #if ! defined (yyoverflow) || YYERROR_VERBOSE
280 # define YYFREE xfree
283 # define YYMALLOC xmalloc
286 /* The parser invokes alloca or xmalloc; define the necessary symbols. */
288 # ifdef YYSTACK_USE_ALLOCA
289 # if YYSTACK_USE_ALLOCA
290 # define YYSTACK_ALLOC alloca
293 # if defined (alloca) || defined (_ALLOCA_H)
294 # define YYSTACK_ALLOC alloca
297 # define YYSTACK_ALLOC __builtin_alloca
302 # ifdef YYSTACK_ALLOC
303 /* Pacify GCC's `empty if-body' warning. */
304 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
306 # if defined (__STDC__) || defined (__cplusplus)
307 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
308 # define YYSIZE_T size_t
310 # define YYSTACK_ALLOC YYMALLOC
311 # define YYSTACK_FREE YYFREE
313 #endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
316 #if (! defined (yyoverflow) \
317 && (! defined (__cplusplus) \
318 || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL)))
320 /* A type that is properly aligned for any stack member. */
327 /* The size of the maximum gap between one aligned stack and the next. */
328 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
330 /* The size of an array large to enough to hold all stacks, each with
332 # define YYSTACK_BYTES(N) \
333 ((N) * (sizeof (short) + sizeof (YYSTYPE)) \
334 + YYSTACK_GAP_MAXIMUM)
336 /* Copy COUNT objects from FROM to TO. The source and destination do
339 # if defined (__GNUC__) && 1 < __GNUC__
340 # define YYCOPY(To, From, Count) \
341 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
343 # define YYCOPY(To, From, Count) \
346 register YYSIZE_T yyi; \
347 for (yyi = 0; yyi < (Count); yyi++) \
348 (To)[yyi] = (From)[yyi]; \
354 /* Relocate STACK from its old location to the new one. The
355 local variables YYSIZE and YYSTACKSIZE give the old and new number of
356 elements in the stack, and YYPTR gives the new location of the
357 stack. Advance YYPTR to a properly aligned location for the next
359 # define YYSTACK_RELOCATE(Stack) \
362 YYSIZE_T yynewbytes; \
363 YYCOPY (&yyptr->Stack, Stack, yysize); \
364 Stack = &yyptr->Stack; \
365 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
366 yyptr += yynewbytes / sizeof (*yyptr); \
372 #if defined (__STDC__) || defined (__cplusplus)
373 typedef signed char yysigned_char;
375 typedef short yysigned_char;
378 /* YYFINAL -- State number of the termination state. */
380 /* YYLAST -- Last index in YYTABLE. */
383 /* YYNTOKENS -- Number of terminals. */
385 /* YYNNTS -- Number of nonterminals. */
387 /* YYNRULES -- Number of rules. */
389 /* YYNRULES -- Number of states. */
390 #define YYNSTATES 123
392 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
394 #define YYMAXUTOK 291
396 #define YYTRANSLATE(YYX) \
397 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
399 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
400 static const unsigned char yytranslate[] =
402 0, 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 46, 50, 39, 37, 19, 38, 44, 40, 2, 2,
407 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
408 28, 26, 29, 2, 36, 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, 45, 2, 51, 48, 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, 2, 2, 2, 2,
426 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
427 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
428 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
429 15, 16, 17, 18, 20, 21, 22, 23, 24, 25,
430 27, 30, 31, 32, 33, 34, 35, 41, 42, 43,
435 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
437 static const unsigned char yyprhs[] =
439 0, 0, 3, 4, 7, 9, 11, 13, 15, 19,
440 22, 25, 28, 31, 36, 41, 42, 47, 48, 54,
441 55, 61, 62, 64, 68, 73, 77, 81, 82, 87,
442 91, 95, 99, 103, 107, 111, 115, 119, 123, 127,
443 131, 135, 139, 143, 147, 151, 153, 155, 157, 159,
444 161, 163, 165, 170, 175, 177, 179, 181, 185, 189,
445 193, 195, 198, 200, 202, 204, 207, 209, 212, 215,
446 217, 219, 221, 223, 225
449 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
450 static const yysigned_char yyrhs[] =
452 53, 0, -1, -1, 54, 55, -1, 57, -1, 56,
453 -1, 68, -1, 58, -1, 57, 19, 58, -1, 58,
454 48, -1, 36, 58, -1, 38, 58, -1, 22, 58,
455 -1, 42, 46, 58, 50, -1, 41, 46, 58, 50,
456 -1, -1, 58, 44, 59, 6, -1, -1, 58, 45,
457 60, 57, 51, -1, -1, 58, 46, 61, 62, 50,
458 -1, -1, 58, -1, 62, 19, 58, -1, 68, 46,
459 58, 50, -1, 46, 57, 50, -1, 58, 39, 58,
460 -1, -1, 58, 40, 63, 58, -1, 58, 33, 58,
461 -1, 58, 32, 58, -1, 58, 37, 58, -1, 58,
462 38, 58, -1, 58, 35, 58, -1, 58, 34, 58,
463 -1, 58, 26, 58, -1, 58, 27, 58, -1, 58,
464 31, 58, -1, 58, 30, 58, -1, 58, 28, 58,
465 -1, 58, 29, 58, -1, 58, 25, 58, -1, 58,
466 24, 58, -1, 58, 23, 58, -1, 58, 21, 58,
467 -1, 17, -1, 18, -1, 3, -1, 9, -1, 4,
468 -1, 65, -1, 15, -1, 12, 46, 68, 50, -1,
469 12, 46, 58, 50, -1, 5, -1, 16, -1, 49,
470 -1, 64, 13, 70, -1, 64, 13, 70, -1, 69,
471 13, 70, -1, 66, -1, 13, 70, -1, 71, -1,
472 69, -1, 67, -1, 48, 69, -1, 8, -1, 10,
473 70, -1, 11, 70, -1, 7, -1, 49, -1, 8,
474 -1, 9, -1, 7, -1, 49, -1
477 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
478 static const unsigned short yyrline[] =
480 0, 235, 235, 235, 243, 244, 247, 254, 255, 260,
481 266, 272, 276, 280, 284, 288, 288, 303, 301, 331,
482 328, 343, 344, 346, 350, 365, 371, 375, 375, 395,
483 399, 403, 407, 411, 415, 419, 425, 431, 437, 443,
484 449, 455, 459, 463, 467, 471, 478, 485, 493, 505,
485 513, 516, 520, 528, 531, 556, 583, 600, 610, 625,
486 640, 641, 669, 738, 749, 753, 755, 757, 760, 768,
487 769, 770, 771, 774, 775
491 #if YYDEBUG || YYERROR_VERBOSE
492 /* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
493 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
494 static const char *const yytname[] =
496 "$end", "error", "$undefined", "INT", "FLOAT", "STRING", "FIELDNAME",
497 "NAME", "TYPENAME", "NAME_OR_INT", "STRUCT", "CLASS", "SIZEOF",
498 "COLONCOLON", "ERROR", "VARIABLE", "THIS", "TRUEKEYWORD", "FALSEKEYWORD",
499 "','", "ABOVE_COMMA", "ASSIGN", "NOT", "OR", "XOR", "ANDAND", "'='",
500 "NOTEQUAL", "'<'", "'>'", "GEQ", "LEQ", "MOD", "DIV", "RSH", "LSH",
501 "'@'", "'+'", "'-'", "'*'", "'/'", "DECREMENT", "INCREMENT", "UNARY",
502 "'.'", "'['", "'('", "ARROW", "'^'", "BLOCKNAME", "')'", "']'",
503 "$accept", "start", "@1", "normal_start", "type_exp", "exp1", "exp",
504 "@2", "@3", "@4", "arglist", "@5", "block", "variable", "qualified_name",
505 "ptype", "type", "typebase", "name", "name_not_typename", 0
510 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
512 static const unsigned short yytoknum[] =
514 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
515 265, 266, 267, 268, 269, 270, 271, 272, 273, 44,
516 274, 275, 276, 277, 278, 279, 61, 280, 60, 62,
517 281, 282, 283, 284, 285, 286, 64, 43, 45, 42,
518 47, 287, 288, 289, 46, 91, 40, 290, 94, 291,
523 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
524 static const unsigned char yyr1[] =
526 0, 52, 54, 53, 55, 55, 56, 57, 57, 58,
527 58, 58, 58, 58, 58, 59, 58, 60, 58, 61,
528 58, 62, 62, 62, 58, 58, 58, 63, 58, 58,
529 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
530 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
531 58, 58, 58, 58, 58, 58, 64, 64, 65, 66,
532 65, 65, 65, 67, 68, 69, 69, 69, 69, 70,
536 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
537 static const unsigned char yyr2[] =
539 0, 2, 0, 2, 1, 1, 1, 1, 3, 2,
540 2, 2, 2, 4, 4, 0, 4, 0, 5, 0,
541 5, 0, 1, 3, 4, 3, 3, 0, 4, 3,
542 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
543 3, 3, 3, 3, 3, 1, 1, 1, 1, 1,
544 1, 1, 4, 4, 1, 1, 1, 3, 3, 3,
545 1, 2, 1, 1, 1, 2, 1, 2, 2, 1,
549 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
550 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
551 means the default is an error. */
552 static const unsigned char yydefact[] =
554 2, 0, 0, 1, 47, 49, 54, 73, 66, 48,
555 0, 0, 0, 0, 51, 55, 45, 46, 0, 0,
556 0, 0, 0, 0, 0, 74, 3, 5, 4, 7,
557 0, 50, 60, 64, 6, 63, 62, 69, 71, 72,
558 70, 67, 68, 0, 61, 12, 0, 10, 11, 0,
559 0, 0, 65, 0, 0, 0, 0, 0, 0, 0,
560 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
561 0, 27, 15, 17, 19, 9, 0, 0, 0, 0,
562 0, 0, 0, 25, 8, 44, 43, 42, 41, 35,
563 36, 39, 40, 38, 37, 30, 29, 34, 33, 31,
564 32, 26, 0, 0, 0, 21, 58, 0, 59, 53,
565 52, 14, 13, 28, 16, 0, 22, 0, 24, 18,
569 /* YYDEFGOTO[NTERM-NUM]. */
570 static const yysigned_char yydefgoto[] =
572 -1, 1, 2, 26, 27, 28, 29, 103, 104, 105,
573 117, 102, 30, 31, 32, 33, 46, 35, 41, 36
576 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
578 #define YYPACT_NINF -39
579 static const short yypact[] =
581 -39, 9, 88, -39, -39, -39, -39, -39, -39, -39,
582 4, 4, -31, 4, -39, -39, -39, -39, 88, 88,
583 88, -26, -23, 88, 8, 11, -39, -39, 14, 229,
584 15, -39, -39, -39, -16, 21, -39, -39, -39, -39,
585 -39, -39, -39, 88, -39, -38, -16, -38, -38, 88,
586 88, 7, -39, 88, 88, 88, 88, 88, 88, 88,
587 88, 88, 88, 88, 88, 88, 88, 88, 88, 88,
588 88, -39, -39, -39, -39, -39, 4, 88, 4, 117,
589 -29, 145, 173, -39, 229, 229, 254, 278, 301, 322,
590 322, 339, 339, 339, 339, 27, 27, 27, 27, 68,
591 68, -38, 88, 52, 88, 88, 48, 201, -39, -39,
592 -39, -39, -39, -38, -39, 3, 229, 10, -39, -39,
596 /* YYPGOTO[NTERM-NUM]. */
597 static const yysigned_char yypgoto[] =
599 -39, -39, -39, -39, -39, -19, -18, -39, -39, -39,
600 -39, -39, -39, -39, -39, -39, 12, 38, -8, -39
603 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
604 positive, shift that token. If negative, reduce the rule which
605 number is the opposite. If zero, do what YYDEFACT says.
606 If YYTABLE_NINF, syntax error. */
607 #define YYTABLE_NINF -58
608 static const yysigned_char yytable[] =
610 45, 47, 48, 42, 51, 44, 72, 73, 74, 3,
611 75, 37, 38, 39, 34, 43, 8, 77, 10, 11,
612 49, 110, 53, 50, -56, 79, 53, 0, 76, 120,
613 77, 81, 82, 53, 78, 84, 85, 86, 87, 88,
614 89, 90, 91, 92, 93, 94, 95, 96, 97, 98,
615 99, 100, 101, 40, 119, 80, 24, 83, 114, 107,
616 121, -57, 52, 0, 68, 69, 70, 71, 106, 0,
617 108, 72, 73, 74, 0, 75, 0, 0, 0, 0,
618 0, 0, 0, 0, 113, 115, 0, 116, 0, 0,
619 0, 4, 5, 6, 0, 7, 8, 9, 10, 11,
620 12, 13, 122, 14, 15, 16, 17, 70, 71, 0,
621 18, 0, 72, 73, 74, 0, 75, 0, 0, 0,
622 0, 0, 0, 0, 19, 0, 20, 0, 0, 21,
623 22, 0, 0, 0, 23, 0, 24, 25, 54, 0,
624 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
625 65, 66, 67, 0, 68, 69, 70, 71, 0, 0,
626 0, 72, 73, 74, 0, 75, 54, 109, 55, 56,
627 57, 58, 59, 60, 61, 62, 63, 64, 65, 66,
628 67, 0, 68, 69, 70, 71, 0, 0, 0, 72,
629 73, 74, 0, 75, 54, 111, 55, 56, 57, 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, 54, 112, 55, 56, 57, 58, 59, 60,
633 61, 62, 63, 64, 65, 66, 67, 0, 68, 69,
634 70, 71, 0, 0, 0, 72, 73, 74, 0, 75,
635 54, 118, 55, 56, 57, 58, 59, 60, 61, 62,
636 63, 64, 65, 66, 67, 0, 68, 69, 70, 71,
637 0, 0, 0, 72, 73, 74, 0, 75, 56, 57,
638 58, 59, 60, 61, 62, 63, 64, 65, 66, 67,
639 0, 68, 69, 70, 71, 0, 0, 0, 72, 73,
640 74, 0, 75, 57, 58, 59, 60, 61, 62, 63,
641 64, 65, 66, 67, 0, 68, 69, 70, 71, 0,
642 0, 0, 72, 73, 74, 0, 75, 58, 59, 60,
643 61, 62, 63, 64, 65, 66, 67, 0, 68, 69,
644 70, 71, 0, 0, 0, 72, 73, 74, 0, 75,
645 60, 61, 62, 63, 64, 65, 66, 67, 0, 68,
646 69, 70, 71, 0, 0, 0, 72, 73, 74, 0,
647 75, 64, 65, 66, 67, 0, 68, 69, 70, 71,
648 0, 0, 0, 72, 73, 74, 0, 75
651 static const yysigned_char yycheck[] =
653 18, 19, 20, 11, 23, 13, 44, 45, 46, 0,
654 48, 7, 8, 9, 2, 46, 8, 46, 10, 11,
655 46, 50, 19, 46, 13, 43, 19, -1, 13, 19,
656 46, 49, 50, 19, 13, 53, 54, 55, 56, 57,
657 58, 59, 60, 61, 62, 63, 64, 65, 66, 67,
658 68, 69, 70, 49, 51, 43, 48, 50, 6, 77,
659 50, 13, 24, -1, 37, 38, 39, 40, 76, -1,
660 78, 44, 45, 46, -1, 48, -1, -1, -1, -1,
661 -1, -1, -1, -1, 102, 104, -1, 105, -1, -1,
662 -1, 3, 4, 5, -1, 7, 8, 9, 10, 11,
663 12, 13, 120, 15, 16, 17, 18, 39, 40, -1,
664 22, -1, 44, 45, 46, -1, 48, -1, -1, -1,
665 -1, -1, -1, -1, 36, -1, 38, -1, -1, 41,
666 42, -1, -1, -1, 46, -1, 48, 49, 21, -1,
667 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
668 33, 34, 35, -1, 37, 38, 39, 40, -1, -1,
669 -1, 44, 45, 46, -1, 48, 21, 50, 23, 24,
670 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
671 35, -1, 37, 38, 39, 40, -1, -1, -1, 44,
672 45, 46, -1, 48, 21, 50, 23, 24, 25, 26,
673 27, 28, 29, 30, 31, 32, 33, 34, 35, -1,
674 37, 38, 39, 40, -1, -1, -1, 44, 45, 46,
675 -1, 48, 21, 50, 23, 24, 25, 26, 27, 28,
676 29, 30, 31, 32, 33, 34, 35, -1, 37, 38,
677 39, 40, -1, -1, -1, 44, 45, 46, -1, 48,
678 21, 50, 23, 24, 25, 26, 27, 28, 29, 30,
679 31, 32, 33, 34, 35, -1, 37, 38, 39, 40,
680 -1, -1, -1, 44, 45, 46, -1, 48, 24, 25,
681 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
682 -1, 37, 38, 39, 40, -1, -1, -1, 44, 45,
683 46, -1, 48, 25, 26, 27, 28, 29, 30, 31,
684 32, 33, 34, 35, -1, 37, 38, 39, 40, -1,
685 -1, -1, 44, 45, 46, -1, 48, 26, 27, 28,
686 29, 30, 31, 32, 33, 34, 35, -1, 37, 38,
687 39, 40, -1, -1, -1, 44, 45, 46, -1, 48,
688 28, 29, 30, 31, 32, 33, 34, 35, -1, 37,
689 38, 39, 40, -1, -1, -1, 44, 45, 46, -1,
690 48, 32, 33, 34, 35, -1, 37, 38, 39, 40,
691 -1, -1, -1, 44, 45, 46, -1, 48
694 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
695 symbol of state STATE-NUM. */
696 static const unsigned char yystos[] =
698 0, 53, 54, 0, 3, 4, 5, 7, 8, 9,
699 10, 11, 12, 13, 15, 16, 17, 18, 22, 36,
700 38, 41, 42, 46, 48, 49, 55, 56, 57, 58,
701 64, 65, 66, 67, 68, 69, 71, 7, 8, 9,
702 49, 70, 70, 46, 70, 58, 68, 58, 58, 46,
703 46, 57, 69, 19, 21, 23, 24, 25, 26, 27,
704 28, 29, 30, 31, 32, 33, 34, 35, 37, 38,
705 39, 40, 44, 45, 46, 48, 13, 46, 13, 58,
706 68, 58, 58, 50, 58, 58, 58, 58, 58, 58,
707 58, 58, 58, 58, 58, 58, 58, 58, 58, 58,
708 58, 58, 63, 59, 60, 61, 70, 58, 70, 50,
709 50, 50, 50, 58, 6, 57, 58, 62, 50, 51,
713 #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
714 # define YYSIZE_T __SIZE_TYPE__
716 #if ! defined (YYSIZE_T) && defined (size_t)
717 # define YYSIZE_T size_t
719 #if ! defined (YYSIZE_T)
720 # if defined (__STDC__) || defined (__cplusplus)
721 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
722 # define YYSIZE_T size_t
725 #if ! defined (YYSIZE_T)
726 # define YYSIZE_T unsigned int
729 #define yyerrok (yyerrstatus = 0)
730 #define yyclearin (yychar = YYEMPTY)
734 #define YYACCEPT goto yyacceptlab
735 #define YYABORT goto yyabortlab
736 #define YYERROR goto yyerrorlab
739 /* Like YYERROR except do call yyerror. This remains here temporarily
740 to ease the transition to the new meaning of YYERROR, for GCC.
741 Once GCC version 2 has supplanted version 1, this can go. */
743 #define YYFAIL goto yyerrlab
745 #define YYRECOVERING() (!!yyerrstatus)
747 #define YYBACKUP(Token, Value) \
749 if (yychar == YYEMPTY && yylen == 1) \
753 yytoken = YYTRANSLATE (yychar); \
759 yyerror ("syntax error: cannot back up");\
765 #define YYERRCODE 256
767 /* YYLLOC_DEFAULT -- Compute the default location (before the actions
770 #ifndef YYLLOC_DEFAULT
771 # define YYLLOC_DEFAULT(Current, Rhs, N) \
772 ((Current).first_line = (Rhs)[1].first_line, \
773 (Current).first_column = (Rhs)[1].first_column, \
774 (Current).last_line = (Rhs)[N].last_line, \
775 (Current).last_column = (Rhs)[N].last_column)
778 /* YYLEX -- calling `yylex' with the right arguments. */
781 # define YYLEX yylex (YYLEX_PARAM)
783 # define YYLEX yylex ()
786 /* Enable debugging if requested. */
790 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
791 # define YYFPRINTF fprintf
794 # define YYDPRINTF(Args) \
800 # define YYDSYMPRINT(Args) \
806 # define YYDSYMPRINTF(Title, Token, Value, Location) \
810 YYFPRINTF (stderr, "%s ", Title); \
811 yysymprint (stderr, \
813 YYFPRINTF (stderr, "\n"); \
817 /*------------------------------------------------------------------.
818 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
820 `------------------------------------------------------------------*/
822 #if defined (__STDC__) || defined (__cplusplus)
824 yy_stack_print (short *bottom, short *top)
827 yy_stack_print (bottom, top)
832 YYFPRINTF (stderr, "Stack now");
833 for (/* Nothing. */; bottom <= top; ++bottom)
834 YYFPRINTF (stderr, " %d", *bottom);
835 YYFPRINTF (stderr, "\n");
838 # define YY_STACK_PRINT(Bottom, Top) \
841 yy_stack_print ((Bottom), (Top)); \
845 /*------------------------------------------------.
846 | Report that the YYRULE is going to be reduced. |
847 `------------------------------------------------*/
849 #if defined (__STDC__) || defined (__cplusplus)
851 yy_reduce_print (int yyrule)
854 yy_reduce_print (yyrule)
859 unsigned int yylno = yyrline[yyrule];
860 YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ",
862 /* Print the symbols being reduced, and their result. */
863 for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
864 YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]);
865 YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]);
868 # define YY_REDUCE_PRINT(Rule) \
871 yy_reduce_print (Rule); \
874 /* Nonzero means print parse trace. It is left uninitialized so that
875 multiple parsers can coexist. */
878 # define YYDPRINTF(Args)
879 # define YYDSYMPRINT(Args)
880 # define YYDSYMPRINTF(Title, Token, Value, Location)
881 # define YY_STACK_PRINT(Bottom, Top)
882 # define YY_REDUCE_PRINT(Rule)
883 #endif /* !YYDEBUG */
886 /* YYINITDEPTH -- initial size of the parser's stacks. */
888 # define YYINITDEPTH 200
891 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
892 if the built-in stack extension method is used).
894 Do not make this value too large; the results are undefined if
895 SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
896 evaluated with infinite-precision integer arithmetic. */
898 #if defined (YYMAXDEPTH) && YYMAXDEPTH == 0
903 # define YYMAXDEPTH 10000
911 # if defined (__GLIBC__) && defined (_STRING_H)
912 # define yystrlen strlen
914 /* Return the length of YYSTR. */
916 # if defined (__STDC__) || defined (__cplusplus)
917 yystrlen (const char *yystr)
923 register const char *yys = yystr;
925 while (*yys++ != '\0')
928 return yys - yystr - 1;
934 # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
935 # define yystpcpy stpcpy
937 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
940 # if defined (__STDC__) || defined (__cplusplus)
941 yystpcpy (char *yydest, const char *yysrc)
943 yystpcpy (yydest, yysrc)
948 register char *yyd = yydest;
949 register const char *yys = yysrc;
951 while ((*yyd++ = *yys++) != '\0')
959 #endif /* !YYERROR_VERBOSE */
964 /*--------------------------------.
965 | Print this symbol on YYOUTPUT. |
966 `--------------------------------*/
968 #if defined (__STDC__) || defined (__cplusplus)
970 yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep)
973 yysymprint (yyoutput, yytype, yyvaluep)
979 /* Pacify ``unused variable'' warnings. */
982 if (yytype < YYNTOKENS)
984 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
986 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
990 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
997 YYFPRINTF (yyoutput, ")");
1000 #endif /* ! YYDEBUG */
1001 /*-----------------------------------------------.
1002 | Release the memory associated to this symbol. |
1003 `-----------------------------------------------*/
1005 #if defined (__STDC__) || defined (__cplusplus)
1007 yydestruct (int yytype, YYSTYPE *yyvaluep)
1010 yydestruct (yytype, yyvaluep)
1015 /* Pacify ``unused variable'' warnings. */
1027 /* Prevent warnings from -Wmissing-prototypes. */
1029 #ifdef YYPARSE_PARAM
1030 # if defined (__STDC__) || defined (__cplusplus)
1031 int yyparse (void *YYPARSE_PARAM);
1035 #else /* ! YYPARSE_PARAM */
1036 #if defined (__STDC__) || defined (__cplusplus)
1041 #endif /* ! YYPARSE_PARAM */
1045 /* The lookahead symbol. */
1048 /* The semantic value of the lookahead symbol. */
1051 /* Number of syntax errors so far. */
1060 #ifdef YYPARSE_PARAM
1061 # if defined (__STDC__) || defined (__cplusplus)
1062 int yyparse (void *YYPARSE_PARAM)
1064 int yyparse (YYPARSE_PARAM)
1065 void *YYPARSE_PARAM;
1067 #else /* ! YYPARSE_PARAM */
1068 #if defined (__STDC__) || defined (__cplusplus)
1079 register int yystate;
1082 /* Number of tokens to shift before error messages enabled. */
1084 /* Lookahead token as an internal (translated) token number. */
1087 /* Three stacks and their tools:
1088 `yyss': related to states,
1089 `yyvs': related to semantic values,
1090 `yyls': related to locations.
1092 Refer to the stacks thru separate pointers, to allow yyoverflow
1093 to xreallocate them elsewhere. */
1095 /* The state stack. */
1096 short yyssa[YYINITDEPTH];
1097 short *yyss = yyssa;
1098 register short *yyssp;
1100 /* The semantic value stack. */
1101 YYSTYPE yyvsa[YYINITDEPTH];
1102 YYSTYPE *yyvs = yyvsa;
1103 register YYSTYPE *yyvsp;
1107 #define YYPOPSTACK (yyvsp--, yyssp--)
1109 YYSIZE_T yystacksize = YYINITDEPTH;
1111 /* The variables used to return semantic value and location from the
1116 /* When reducing, the number of symbols on the RHS of the reduced
1120 YYDPRINTF ((stderr, "Starting parse\n"));
1125 yychar = YYEMPTY; /* Cause a token to be read. */
1127 /* Initialize stack pointers.
1128 Waste one element of value and location stack
1129 so that they stay on the same level as the state stack.
1130 The wasted elements are never initialized. */
1137 /*------------------------------------------------------------.
1138 | yynewstate -- Push a new state, which is found in yystate. |
1139 `------------------------------------------------------------*/
1141 /* In all cases, when you get here, the value and location stacks
1142 have just been pushed. so pushing a state here evens the stacks.
1149 if (yyss + yystacksize - 1 <= yyssp)
1151 /* Get the current used size of the three stacks, in elements. */
1152 YYSIZE_T yysize = yyssp - yyss + 1;
1156 /* Give user a chance to xreallocate the stack. Use copies of
1157 these so that the &'s don't force the real ones into
1159 YYSTYPE *yyvs1 = yyvs;
1160 short *yyss1 = yyss;
1163 /* Each stack pointer address is followed by the size of the
1164 data in use in that stack, in bytes. This used to be a
1165 conditional around just the two extra args, but that might
1166 be undefined if yyoverflow is a macro. */
1167 yyoverflow ("parser stack overflow",
1168 &yyss1, yysize * sizeof (*yyssp),
1169 &yyvs1, yysize * sizeof (*yyvsp),
1176 #else /* no yyoverflow */
1177 # ifndef YYSTACK_RELOCATE
1180 /* Extend the stack our own way. */
1181 if (YYMAXDEPTH <= yystacksize)
1184 if (YYMAXDEPTH < yystacksize)
1185 yystacksize = YYMAXDEPTH;
1188 short *yyss1 = yyss;
1189 union yyalloc *yyptr =
1190 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1193 YYSTACK_RELOCATE (yyss);
1194 YYSTACK_RELOCATE (yyvs);
1196 # undef YYSTACK_RELOCATE
1198 YYSTACK_FREE (yyss1);
1201 #endif /* no yyoverflow */
1203 yyssp = yyss + yysize - 1;
1204 yyvsp = yyvs + yysize - 1;
1207 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1208 (unsigned long int) yystacksize));
1210 if (yyss + yystacksize - 1 <= yyssp)
1214 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1223 /* Do appropriate processing given the current state. */
1224 /* Read a lookahead token if we need one and don't already have one. */
1227 /* First try to decide what to do without reference to lookahead token. */
1229 yyn = yypact[yystate];
1230 if (yyn == YYPACT_NINF)
1233 /* Not known => get a lookahead token if don't already have one. */
1235 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1236 if (yychar == YYEMPTY)
1238 YYDPRINTF ((stderr, "Reading a token: "));
1242 if (yychar <= YYEOF)
1244 yychar = yytoken = YYEOF;
1245 YYDPRINTF ((stderr, "Now at end of input.\n"));
1249 yytoken = YYTRANSLATE (yychar);
1250 YYDSYMPRINTF ("Next token is", yytoken, &yylval, &yylloc);
1253 /* If the proper action on seeing token YYTOKEN is to reduce or to
1254 detect an error, take that action. */
1256 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1261 if (yyn == 0 || yyn == YYTABLE_NINF)
1270 /* Shift the lookahead token. */
1271 YYDPRINTF ((stderr, "Shifting token %s, ", yytname[yytoken]));
1273 /* Discard the token being shifted unless it is eof. */
1274 if (yychar != YYEOF)
1280 /* Count tokens shifted since error; after three, turn off error
1289 /*-----------------------------------------------------------.
1290 | yydefault -- do the default action for the current state. |
1291 `-----------------------------------------------------------*/
1293 yyn = yydefact[yystate];
1299 /*-----------------------------.
1300 | yyreduce -- Do a reduction. |
1301 `-----------------------------*/
1303 /* yyn is the number of a rule to reduce with. */
1306 /* If YYLEN is nonzero, implement the default value of the action:
1309 Otherwise, the following line sets YYVAL to garbage.
1310 This behavior is undocumented and Bison
1311 users should not rely upon it. Assigning to YYVAL
1312 unconditionally makes the parser a bit smaller, and it avoids a
1313 GCC warning that YYVAL may be used uninitialized. */
1314 yyval = yyvsp[1-yylen];
1317 YY_REDUCE_PRINT (yyn);
1322 { current_type = NULL;
1324 leftdiv_is_integer = 0;
1335 { write_exp_elt_opcode(OP_TYPE);
1336 write_exp_elt_type(yyvsp[0].tval);
1337 write_exp_elt_opcode(OP_TYPE);
1338 current_type = yyvsp[0].tval; }
1343 { write_exp_elt_opcode (BINOP_COMMA); }
1348 { write_exp_elt_opcode (UNOP_IND);
1350 current_type = TYPE_TARGET_TYPE (current_type); }
1355 { write_exp_elt_opcode (UNOP_ADDR);
1357 current_type = TYPE_POINTER_TYPE (current_type); }
1362 { write_exp_elt_opcode (UNOP_NEG); }
1367 { write_exp_elt_opcode (UNOP_LOGICAL_NOT); }
1372 { write_exp_elt_opcode (UNOP_PREINCREMENT); }
1377 { write_exp_elt_opcode (UNOP_PREDECREMENT); }
1382 { search_field = 1; }
1387 { write_exp_elt_opcode (STRUCTOP_STRUCT);
1388 write_exp_string (yyvsp[0].sval);
1389 write_exp_elt_opcode (STRUCTOP_STRUCT);
1392 { while (TYPE_CODE (current_type) == TYPE_CODE_PTR)
1393 current_type = TYPE_TARGET_TYPE (current_type);
1394 current_type = lookup_struct_elt_type (
1395 current_type, yyvsp[0].sval.ptr, 0); };
1402 int arrayfieldindex;
1403 arrayfieldindex = is_pascal_string_type (
1404 current_type, NULL, NULL,
1405 NULL, NULL, &arrayname);
1406 if (arrayfieldindex)
1408 struct stoken stringsval;
1409 stringsval.ptr = alloca (strlen (arrayname) + 1);
1410 stringsval.length = strlen (arrayname);
1411 strcpy (stringsval.ptr, arrayname);
1412 current_type = TYPE_FIELD_TYPE (current_type,
1413 arrayfieldindex - 1);
1414 write_exp_elt_opcode (STRUCTOP_STRUCT);
1415 write_exp_string (stringsval);
1416 write_exp_elt_opcode (STRUCTOP_STRUCT);
1418 push_current_type (); }
1423 { pop_current_type ();
1424 write_exp_elt_opcode (BINOP_SUBSCRIPT);
1426 current_type = TYPE_TARGET_TYPE (current_type); }
1431 { push_current_type ();
1437 { write_exp_elt_opcode (OP_FUNCALL);
1438 write_exp_elt_longcst ((LONGEST) end_arglist ());
1439 write_exp_elt_opcode (OP_FUNCALL);
1440 pop_current_type ();
1442 current_type = TYPE_TARGET_TYPE (current_type);
1448 { arglist_len = 1; }
1460 /* Allow automatic dereference of classes. */
1461 if ((TYPE_CODE (current_type) == TYPE_CODE_PTR)
1462 && (TYPE_CODE (TYPE_TARGET_TYPE (current_type)) == TYPE_CODE_CLASS)
1463 && (TYPE_CODE (yyvsp[-3].tval) == TYPE_CODE_CLASS))
1464 write_exp_elt_opcode (UNOP_IND);
1466 write_exp_elt_opcode (UNOP_CAST);
1467 write_exp_elt_type (yyvsp[-3].tval);
1468 write_exp_elt_opcode (UNOP_CAST);
1469 current_type = yyvsp[-3].tval; }
1479 { write_exp_elt_opcode (BINOP_MUL); }
1485 if (current_type && is_integral_type (current_type))
1486 leftdiv_is_integer = 1;
1493 if (leftdiv_is_integer && current_type
1494 && is_integral_type (current_type))
1496 write_exp_elt_opcode (UNOP_CAST);
1497 write_exp_elt_type (parse_type->builtin_long_double);
1498 current_type = parse_type->builtin_long_double;
1499 write_exp_elt_opcode (UNOP_CAST);
1500 leftdiv_is_integer = 0;
1503 write_exp_elt_opcode (BINOP_DIV);
1509 { write_exp_elt_opcode (BINOP_INTDIV); }
1514 { write_exp_elt_opcode (BINOP_REM); }
1519 { write_exp_elt_opcode (BINOP_ADD); }
1524 { write_exp_elt_opcode (BINOP_SUB); }
1529 { write_exp_elt_opcode (BINOP_LSH); }
1534 { write_exp_elt_opcode (BINOP_RSH); }
1539 { write_exp_elt_opcode (BINOP_EQUAL);
1540 current_type = parse_type->builtin_bool;
1546 { write_exp_elt_opcode (BINOP_NOTEQUAL);
1547 current_type = parse_type->builtin_bool;
1553 { write_exp_elt_opcode (BINOP_LEQ);
1554 current_type = parse_type->builtin_bool;
1560 { write_exp_elt_opcode (BINOP_GEQ);
1561 current_type = parse_type->builtin_bool;
1567 { write_exp_elt_opcode (BINOP_LESS);
1568 current_type = parse_type->builtin_bool;
1574 { write_exp_elt_opcode (BINOP_GTR);
1575 current_type = parse_type->builtin_bool;
1581 { write_exp_elt_opcode (BINOP_BITWISE_AND); }
1586 { write_exp_elt_opcode (BINOP_BITWISE_XOR); }
1591 { write_exp_elt_opcode (BINOP_BITWISE_IOR); }
1596 { write_exp_elt_opcode (BINOP_ASSIGN); }
1601 { write_exp_elt_opcode (OP_BOOL);
1602 write_exp_elt_longcst ((LONGEST) yyvsp[0].lval);
1603 current_type = parse_type->builtin_bool;
1604 write_exp_elt_opcode (OP_BOOL); }
1609 { write_exp_elt_opcode (OP_BOOL);
1610 write_exp_elt_longcst ((LONGEST) yyvsp[0].lval);
1611 current_type = parse_type->builtin_bool;
1612 write_exp_elt_opcode (OP_BOOL); }
1617 { write_exp_elt_opcode (OP_LONG);
1618 write_exp_elt_type (yyvsp[0].typed_val_int.type);
1619 current_type = yyvsp[0].typed_val_int.type;
1620 write_exp_elt_longcst ((LONGEST)(yyvsp[0].typed_val_int.val));
1621 write_exp_elt_opcode (OP_LONG); }
1627 parse_number (yyvsp[0].ssym.stoken.ptr, yyvsp[0].ssym.stoken.length, 0, &val);
1628 write_exp_elt_opcode (OP_LONG);
1629 write_exp_elt_type (val.typed_val_int.type);
1630 current_type = val.typed_val_int.type;
1631 write_exp_elt_longcst ((LONGEST)val.typed_val_int.val);
1632 write_exp_elt_opcode (OP_LONG);
1638 { write_exp_elt_opcode (OP_DOUBLE);
1639 write_exp_elt_type (yyvsp[0].typed_val_float.type);
1640 current_type = yyvsp[0].typed_val_float.type;
1641 write_exp_elt_dblcst (yyvsp[0].typed_val_float.dval);
1642 write_exp_elt_opcode (OP_DOUBLE); }
1647 { write_exp_elt_opcode (OP_LONG);
1648 write_exp_elt_type (parse_type->builtin_int);
1649 CHECK_TYPEDEF (yyvsp[-1].tval);
1650 write_exp_elt_longcst ((LONGEST) TYPE_LENGTH (yyvsp[-1].tval));
1651 write_exp_elt_opcode (OP_LONG); }
1656 { write_exp_elt_opcode (UNOP_SIZEOF); }
1661 { /* C strings are converted into array constants with
1662 an explicit null byte added at the end. Thus
1663 the array upper bound is the string length.
1664 There is no such thing in C as a completely empty
1666 char *sp = yyvsp[0].sval.ptr; int count = yyvsp[0].sval.length;
1669 write_exp_elt_opcode (OP_LONG);
1670 write_exp_elt_type (parse_type->builtin_char);
1671 write_exp_elt_longcst ((LONGEST)(*sp++));
1672 write_exp_elt_opcode (OP_LONG);
1674 write_exp_elt_opcode (OP_LONG);
1675 write_exp_elt_type (parse_type->builtin_char);
1676 write_exp_elt_longcst ((LONGEST)'\0');
1677 write_exp_elt_opcode (OP_LONG);
1678 write_exp_elt_opcode (OP_ARRAY);
1679 write_exp_elt_longcst ((LONGEST) 0);
1680 write_exp_elt_longcst ((LONGEST) (yyvsp[0].sval.length));
1681 write_exp_elt_opcode (OP_ARRAY); }
1687 struct value * this_val;
1688 struct type * this_type;
1689 write_exp_elt_opcode (OP_THIS);
1690 write_exp_elt_opcode (OP_THIS);
1691 /* we need type of this */
1692 this_val = value_of_this (0);
1694 this_type = value_type (this_val);
1699 if (TYPE_CODE (this_type) == TYPE_CODE_PTR)
1701 this_type = TYPE_TARGET_TYPE (this_type);
1702 write_exp_elt_opcode (UNOP_IND);
1706 current_type = this_type;
1713 if (yyvsp[0].ssym.sym != 0)
1714 yyval.bval = SYMBOL_BLOCK_VALUE (yyvsp[0].ssym.sym);
1717 struct symtab *tem =
1718 lookup_symtab (copy_name (yyvsp[0].ssym.stoken));
1720 yyval.bval = BLOCKVECTOR_BLOCK (BLOCKVECTOR (tem), STATIC_BLOCK);
1722 error ("No file or function \"%s\".",
1723 copy_name (yyvsp[0].ssym.stoken));
1730 { struct symbol *tem
1731 = lookup_symbol (copy_name (yyvsp[0].sval), yyvsp[-2].bval,
1732 VAR_DOMAIN, (int *) NULL);
1733 if (!tem || SYMBOL_CLASS (tem) != LOC_BLOCK)
1734 error ("No function \"%s\" in specified context.",
1735 copy_name (yyvsp[0].sval));
1736 yyval.bval = SYMBOL_BLOCK_VALUE (tem); }
1741 { struct symbol *sym;
1742 sym = lookup_symbol (copy_name (yyvsp[0].sval), yyvsp[-2].bval,
1743 VAR_DOMAIN, (int *) NULL);
1745 error ("No symbol \"%s\" in specified context.",
1746 copy_name (yyvsp[0].sval));
1748 write_exp_elt_opcode (OP_VAR_VALUE);
1749 /* block_found is set by lookup_symbol. */
1750 write_exp_elt_block (block_found);
1751 write_exp_elt_sym (sym);
1752 write_exp_elt_opcode (OP_VAR_VALUE); }
1758 struct type *type = yyvsp[-2].tval;
1759 if (TYPE_CODE (type) != TYPE_CODE_STRUCT
1760 && TYPE_CODE (type) != TYPE_CODE_UNION)
1761 error ("`%s' is not defined as an aggregate type.",
1764 write_exp_elt_opcode (OP_SCOPE);
1765 write_exp_elt_type (type);
1766 write_exp_string (yyvsp[0].sval);
1767 write_exp_elt_opcode (OP_SCOPE);
1774 char *name = copy_name (yyvsp[0].sval);
1776 struct minimal_symbol *msymbol;
1779 lookup_symbol (name, (const struct block *) NULL,
1780 VAR_DOMAIN, (int *) NULL);
1783 write_exp_elt_opcode (OP_VAR_VALUE);
1784 write_exp_elt_block (NULL);
1785 write_exp_elt_sym (sym);
1786 write_exp_elt_opcode (OP_VAR_VALUE);
1790 msymbol = lookup_minimal_symbol (name, NULL, NULL);
1791 if (msymbol != NULL)
1792 write_exp_msymbol (msymbol);
1793 else if (!have_full_symbols () && !have_partial_symbols ())
1794 error ("No symbol table is loaded. Use the \"file\" command.");
1796 error ("No symbol \"%s\" in current context.", name);
1802 { struct symbol *sym = yyvsp[0].ssym.sym;
1806 if (symbol_read_needs_frame (sym))
1808 if (innermost_block == 0
1809 || contained_in (block_found,
1811 innermost_block = block_found;
1814 write_exp_elt_opcode (OP_VAR_VALUE);
1815 /* We want to use the selected frame, not
1816 another more inner frame which happens to
1817 be in the same block. */
1818 write_exp_elt_block (NULL);
1819 write_exp_elt_sym (sym);
1820 write_exp_elt_opcode (OP_VAR_VALUE);
1821 current_type = sym->type; }
1822 else if (yyvsp[0].ssym.is_a_field_of_this)
1824 struct value * this_val;
1825 struct type * this_type;
1826 /* Object pascal: it hangs off of `this'. Must
1827 not inadvertently convert from a method call
1829 if (innermost_block == 0
1830 || contained_in (block_found,
1832 innermost_block = block_found;
1833 write_exp_elt_opcode (OP_THIS);
1834 write_exp_elt_opcode (OP_THIS);
1835 write_exp_elt_opcode (STRUCTOP_PTR);
1836 write_exp_string (yyvsp[0].ssym.stoken);
1837 write_exp_elt_opcode (STRUCTOP_PTR);
1838 /* we need type of this */
1839 this_val = value_of_this (0);
1841 this_type = value_type (this_val);
1845 current_type = lookup_struct_elt_type (
1847 copy_name (yyvsp[0].ssym.stoken), 0);
1849 current_type = NULL;
1853 struct minimal_symbol *msymbol;
1854 char *arg = copy_name (yyvsp[0].ssym.stoken);
1857 lookup_minimal_symbol (arg, NULL, NULL);
1858 if (msymbol != NULL)
1859 write_exp_msymbol (msymbol);
1860 else if (!have_full_symbols () && !have_partial_symbols ())
1861 error ("No symbol table is loaded. Use the \"file\" command.");
1863 error ("No symbol \"%s\" in current context.",
1864 copy_name (yyvsp[0].ssym.stoken));
1871 { yyval.tval = lookup_pointer_type (yyvsp[0].tval); }
1876 { yyval.tval = yyvsp[0].tsym.type; }
1881 { yyval.tval = lookup_struct (copy_name (yyvsp[0].sval),
1882 expression_context_block); }
1887 { yyval.tval = lookup_struct (copy_name (yyvsp[0].sval),
1888 expression_context_block); }
1893 { yyval.sval = yyvsp[0].ssym.stoken; }
1898 { yyval.sval = yyvsp[0].ssym.stoken; }
1903 { yyval.sval = yyvsp[0].tsym.stoken; }
1908 { yyval.sval = yyvsp[0].ssym.stoken; }
1914 /* Line 1000 of yacc.c. */
1915 #line 1916 "p-exp.c.tmp"
1921 YY_STACK_PRINT (yyss, yyssp);
1926 /* Now `shift' the result of the reduction. Determine what state
1927 that goes to, based on the state we popped back to and the rule
1928 number reduced by. */
1932 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1933 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1934 yystate = yytable[yystate];
1936 yystate = yydefgoto[yyn - YYNTOKENS];
1941 /*------------------------------------.
1942 | yyerrlab -- here on detecting error |
1943 `------------------------------------*/
1945 /* If not already recovering from an error, report this error. */
1950 yyn = yypact[yystate];
1952 if (YYPACT_NINF < yyn && yyn < YYLAST)
1954 YYSIZE_T yysize = 0;
1955 int yytype = YYTRANSLATE (yychar);
1956 const char* yyprefix;
1960 /* Start YYX at -YYN if negative to avoid negative indexes in
1962 int yyxbegin = yyn < 0 ? -yyn : 0;
1964 /* Stay within bounds of both yycheck and yytname. */
1965 int yychecklim = YYLAST - yyn;
1966 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1969 yyprefix = ", expecting ";
1970 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1971 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1973 yysize += yystrlen (yyprefix) + yystrlen (yytname [yyx]);
1981 yysize += (sizeof ("syntax error, unexpected ")
1982 + yystrlen (yytname[yytype]));
1983 yymsg = (char *) YYSTACK_ALLOC (yysize);
1986 char *yyp = yystpcpy (yymsg, "syntax error, unexpected ");
1987 yyp = yystpcpy (yyp, yytname[yytype]);
1991 yyprefix = ", expecting ";
1992 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1993 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1995 yyp = yystpcpy (yyp, yyprefix);
1996 yyp = yystpcpy (yyp, yytname[yyx]);
2001 YYSTACK_FREE (yymsg);
2004 yyerror ("syntax error; also virtual memory exhausted");
2007 #endif /* YYERROR_VERBOSE */
2008 yyerror ("syntax error");
2013 if (yyerrstatus == 3)
2015 /* If just tried and failed to reuse lookahead token after an
2016 error, discard it. */
2018 if (yychar <= YYEOF)
2020 /* If at end of input, pop the error token,
2021 then the rest of the stack, then return failure. */
2022 if (yychar == YYEOF)
2028 YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
2029 yydestruct (yystos[*yyssp], yyvsp);
2034 YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc);
2035 yydestruct (yytoken, &yylval);
2041 /* Else will try to reuse lookahead token after shifting the error
2046 /*---------------------------------------------------.
2047 | yyerrorlab -- error raised explicitly by YYERROR. |
2048 `---------------------------------------------------*/
2052 /* Pacify GCC when the user code never invokes YYERROR and the label
2053 yyerrorlab therefore never appears in user code. */
2064 /*-------------------------------------------------------------.
2065 | yyerrlab1 -- common code for both syntax error and YYERROR. |
2066 `-------------------------------------------------------------*/
2068 yyerrstatus = 3; /* Each real token shifted decrements this. */
2072 yyn = yypact[yystate];
2073 if (yyn != YYPACT_NINF)
2076 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
2084 /* Pop the current state because it cannot handle the error token. */
2088 YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
2089 yydestruct (yystos[yystate], yyvsp);
2092 YY_STACK_PRINT (yyss, yyssp);
2098 YYDPRINTF ((stderr, "Shifting error token, "));
2107 /*-------------------------------------.
2108 | yyacceptlab -- YYACCEPT comes here. |
2109 `-------------------------------------*/
2114 /*-----------------------------------.
2115 | yyabortlab -- YYABORT comes here. |
2116 `-----------------------------------*/
2122 /*----------------------------------------------.
2123 | yyoverflowlab -- parser overflow comes here. |
2124 `----------------------------------------------*/
2126 yyerror ("parser stack overflow");
2134 YYSTACK_FREE (yyss);
2143 /* Take care of parsing a number (anything that starts with a digit).
2144 Set yylval and return the token type; update lexptr.
2145 LEN is the number of characters in it. */
2147 /*** Needs some error checking for the float case ***/
2150 parse_number (p, len, parsed_float, putithere)
2156 /* FIXME: Shouldn't these be unsigned? We don't deal with negative values
2157 here, and we do kind of silly things like cast to unsigned. */
2164 int base = input_radix;
2167 /* Number of "L" suffixes encountered. */
2170 /* We have found a "L" or "U" suffix. */
2171 int found_suffix = 0;
2174 struct type *signed_type;
2175 struct type *unsigned_type;
2179 /* It's a float since it contains a point or an exponent. */
2181 int num = 0; /* number of tokens scanned by scanf */
2182 char saved_char = p[len];
2184 p[len] = 0; /* null-terminate the token */
2185 num = sscanf (p, "%" DOUBLEST_SCAN_FORMAT "%c",
2186 &putithere->typed_val_float.dval, &c);
2187 p[len] = saved_char; /* restore the input stream */
2188 if (num != 1) /* check scanf found ONLY a float ... */
2190 /* See if it has `f' or `l' suffix (float or long double). */
2192 c = tolower (p[len - 1]);
2195 putithere->typed_val_float.type = parse_type->builtin_float;
2197 putithere->typed_val_float.type = parse_type->builtin_long_double;
2198 else if (isdigit (c) || c == '.')
2199 putithere->typed_val_float.type = parse_type->builtin_double;
2206 /* Handle base-switching prefixes 0x, 0t, 0d, 0 */
2240 if (c >= 'A' && c <= 'Z')
2242 if (c != 'l' && c != 'u')
2244 if (c >= '0' && c <= '9')
2252 if (base > 10 && c >= 'a' && c <= 'f')
2256 n += i = c - 'a' + 10;
2269 return ERROR; /* Char not a digit */
2272 return ERROR; /* Invalid digit in this base */
2274 /* Portably test for overflow (only works for nonzero values, so make
2275 a second check for zero). FIXME: Can't we just make n and prevn
2276 unsigned and avoid this? */
2277 if (c != 'l' && c != 'u' && (prevn >= n) && n != 0)
2278 unsigned_p = 1; /* Try something unsigned */
2280 /* Portably test for unsigned overflow.
2281 FIXME: This check is wrong; for example it doesn't find overflow
2282 on 0x123456789 when LONGEST is 32 bits. */
2283 if (c != 'l' && c != 'u' && n != 0)
2285 if ((unsigned_p && (ULONGEST) prevn >= (ULONGEST) n))
2286 error ("Numeric constant too large.");
2291 /* An integer constant is an int, a long, or a long long. An L
2292 suffix forces it to be long; an LL suffix forces it to be long
2293 long. If not forced to a larger size, it gets the first type of
2294 the above that it fits in. To figure out whether it fits, we
2295 shift it right and see whether anything remains. Note that we
2296 can't shift sizeof (LONGEST) * HOST_CHAR_BIT bits or more in one
2297 operation, because many compilers will warn about such a shift
2298 (which always produces a zero result). Sometimes gdbarch_int_bit
2299 or gdbarch_long_bit will be that big, sometimes not. To deal with
2300 the case where it is we just always shift the value more than
2301 once, with fewer bits each time. */
2303 un = (ULONGEST)n >> 2;
2305 && (un >> (gdbarch_int_bit (parse_gdbarch) - 2)) == 0)
2307 high_bit = ((ULONGEST)1) << (gdbarch_int_bit (parse_gdbarch) - 1);
2309 /* A large decimal (not hex or octal) constant (between INT_MAX
2310 and UINT_MAX) is a long or unsigned long, according to ANSI,
2311 never an unsigned int, but this code treats it as unsigned
2312 int. This probably should be fixed. GCC gives a warning on
2315 unsigned_type = parse_type->builtin_unsigned_int;
2316 signed_type = parse_type->builtin_int;
2318 else if (long_p <= 1
2319 && (un >> (gdbarch_long_bit (parse_gdbarch) - 2)) == 0)
2321 high_bit = ((ULONGEST)1) << (gdbarch_long_bit (parse_gdbarch) - 1);
2322 unsigned_type = parse_type->builtin_unsigned_long;
2323 signed_type = parse_type->builtin_long;
2328 if (sizeof (ULONGEST) * HOST_CHAR_BIT
2329 < gdbarch_long_long_bit (parse_gdbarch))
2330 /* A long long does not fit in a LONGEST. */
2331 shift = (sizeof (ULONGEST) * HOST_CHAR_BIT - 1);
2333 shift = (gdbarch_long_long_bit (parse_gdbarch) - 1);
2334 high_bit = (ULONGEST) 1 << shift;
2335 unsigned_type = parse_type->builtin_unsigned_long_long;
2336 signed_type = parse_type->builtin_long_long;
2339 putithere->typed_val_int.val = n;
2341 /* If the high bit of the worked out type is set then this number
2342 has to be unsigned. */
2344 if (unsigned_p || (n & high_bit))
2346 putithere->typed_val_int.type = unsigned_type;
2350 putithere->typed_val_int.type = signed_type;
2359 struct type *stored;
2360 struct type_push *next;
2363 static struct type_push *tp_top = NULL;
2366 push_current_type (void)
2368 struct type_push *tpnew;
2369 tpnew = (struct type_push *) xmalloc (sizeof (struct type_push));
2370 tpnew->next = tp_top;
2371 tpnew->stored = current_type;
2372 current_type = NULL;
2377 pop_current_type (void)
2379 struct type_push *tp = tp_top;
2382 current_type = tp->stored;
2392 enum exp_opcode opcode;
2395 static const struct token tokentab3[] =
2397 {"shr", RSH, BINOP_END},
2398 {"shl", LSH, BINOP_END},
2399 {"and", ANDAND, BINOP_END},
2400 {"div", DIV, BINOP_END},
2401 {"not", NOT, BINOP_END},
2402 {"mod", MOD, BINOP_END},
2403 {"inc", INCREMENT, BINOP_END},
2404 {"dec", DECREMENT, BINOP_END},
2405 {"xor", XOR, BINOP_END}
2408 static const struct token tokentab2[] =
2410 {"or", OR, BINOP_END},
2411 {"<>", NOTEQUAL, BINOP_END},
2412 {"<=", LEQ, BINOP_END},
2413 {">=", GEQ, BINOP_END},
2414 {":=", ASSIGN, BINOP_END},
2415 {"::", COLONCOLON, BINOP_END} };
2417 /* Allocate uppercased var */
2418 /* make an uppercased copy of tokstart */
2419 static char * uptok (tokstart, namelen)
2424 char *uptokstart = (char *)xmalloc(namelen+1);
2425 for (i = 0;i <= namelen;i++)
2427 if ((tokstart[i]>='a' && tokstart[i]<='z'))
2428 uptokstart[i] = tokstart[i]-('a'-'A');
2430 uptokstart[i] = tokstart[i];
2432 uptokstart[namelen]='\0';
2435 /* Read one token, getting characters through lexptr. */
2447 int explen, tempbufindex;
2448 static char *tempbuf;
2449 static int tempbufsize;
2453 prev_lexptr = lexptr;
2456 explen = strlen (lexptr);
2457 /* See if it is a special token of length 3. */
2459 for (i = 0; i < sizeof (tokentab3) / sizeof (tokentab3[0]); i++)
2460 if (strncasecmp (tokstart, tokentab3[i].operator, 3) == 0
2461 && (!isalpha (tokentab3[i].operator[0]) || explen == 3
2462 || (!isalpha (tokstart[3]) && !isdigit (tokstart[3]) && tokstart[3] != '_')))
2465 yylval.opcode = tokentab3[i].opcode;
2466 return tokentab3[i].token;
2469 /* See if it is a special token of length 2. */
2471 for (i = 0; i < sizeof (tokentab2) / sizeof (tokentab2[0]); i++)
2472 if (strncasecmp (tokstart, tokentab2[i].operator, 2) == 0
2473 && (!isalpha (tokentab2[i].operator[0]) || explen == 2
2474 || (!isalpha (tokstart[2]) && !isdigit (tokstart[2]) && tokstart[2] != '_')))
2477 yylval.opcode = tokentab2[i].opcode;
2478 return tokentab2[i].token;
2481 switch (c = *tokstart)
2493 /* We either have a character constant ('0' or '\177' for example)
2494 or we have a quoted symbol reference ('foo(int,int)' in object pascal
2499 c = parse_escape (parse_gdbarch, &lexptr);
2501 error ("Empty character constant.");
2503 yylval.typed_val_int.val = c;
2504 yylval.typed_val_int.type = parse_type->builtin_char;
2509 namelen = skip_quoted (tokstart) - tokstart;
2512 lexptr = tokstart + namelen;
2513 if (lexptr[-1] != '\'')
2514 error ("Unmatched single quote.");
2517 uptokstart = uptok(tokstart,namelen);
2520 error ("Invalid character constant.");
2530 if (paren_depth == 0)
2537 if (comma_terminates && paren_depth == 0)
2543 /* Might be a floating point number. */
2544 if (lexptr[1] < '0' || lexptr[1] > '9')
2545 goto symbol; /* Nope, must be a symbol. */
2546 /* FALL THRU into number case. */
2559 /* It's a number. */
2560 int got_dot = 0, got_e = 0, toktype;
2562 int hex = input_radix > 10;
2564 if (c == '0' && (p[1] == 'x' || p[1] == 'X'))
2569 else if (c == '0' && (p[1]=='t' || p[1]=='T' || p[1]=='d' || p[1]=='D'))
2577 /* This test includes !hex because 'e' is a valid hex digit
2578 and thus does not indicate a floating point number when
2579 the radix is hex. */
2580 if (!hex && !got_e && (*p == 'e' || *p == 'E'))
2581 got_dot = got_e = 1;
2582 /* This test does not include !hex, because a '.' always indicates
2583 a decimal floating point number regardless of the radix. */
2584 else if (!got_dot && *p == '.')
2586 else if (got_e && (p[-1] == 'e' || p[-1] == 'E')
2587 && (*p == '-' || *p == '+'))
2588 /* This is the sign of the exponent, not the end of the
2591 /* We will take any letters or digits. parse_number will
2592 complain if past the radix, or if L or U are not final. */
2593 else if ((*p < '0' || *p > '9')
2594 && ((*p < 'a' || *p > 'z')
2595 && (*p < 'A' || *p > 'Z')))
2598 toktype = parse_number (tokstart, p - tokstart, got_dot|got_e, &yylval);
2599 if (toktype == ERROR)
2601 char *err_copy = (char *) alloca (p - tokstart + 1);
2603 memcpy (err_copy, tokstart, p - tokstart);
2604 err_copy[p - tokstart] = 0;
2605 error ("Invalid number \"%s\".", err_copy);
2636 /* Build the gdb internal form of the input string in tempbuf,
2637 translating any standard C escape forms seen. Note that the
2638 buffer is null byte terminated *only* for the convenience of
2639 debugging gdb itself and printing the buffer contents when
2640 the buffer contains no embedded nulls. Gdb does not depend
2641 upon the buffer being null byte terminated, it uses the length
2642 string instead. This allows gdb to handle C strings (as well
2643 as strings in other languages) with embedded null bytes */
2645 tokptr = ++tokstart;
2649 /* Grow the static temp buffer if necessary, including allocating
2650 the first one on demand. */
2651 if (tempbufindex + 1 >= tempbufsize)
2653 tempbuf = (char *) xrealloc (tempbuf, tempbufsize += 64);
2660 /* Do nothing, loop will terminate. */
2664 c = parse_escape (parse_gdbarch, &tokptr);
2669 tempbuf[tempbufindex++] = c;
2672 tempbuf[tempbufindex++] = *tokptr++;
2675 } while ((*tokptr != '"') && (*tokptr != '\0'));
2676 if (*tokptr++ != '"')
2678 error ("Unterminated string in expression.");
2680 tempbuf[tempbufindex] = '\0'; /* See note above */
2681 yylval.sval.ptr = tempbuf;
2682 yylval.sval.length = tempbufindex;
2687 if (!(c == '_' || c == '$'
2688 || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')))
2689 /* We must have come across a bad character (e.g. ';'). */
2690 error ("Invalid character '%c' in expression.", c);
2692 /* It's a name. See how long it is. */
2694 for (c = tokstart[namelen];
2695 (c == '_' || c == '$' || (c >= '0' && c <= '9')
2696 || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '<');)
2698 /* Template parameter lists are part of the name.
2699 FIXME: This mishandles `print $a<4&&$a>3'. */
2703 int nesting_level = 1;
2704 while (tokstart[++i])
2706 if (tokstart[i] == '<')
2708 else if (tokstart[i] == '>')
2710 if (--nesting_level == 0)
2714 if (tokstart[i] == '>')
2720 /* do NOT uppercase internals because of registers !!! */
2721 c = tokstart[++namelen];
2724 uptokstart = uptok(tokstart,namelen);
2726 /* The token "if" terminates the expression and is NOT
2727 removed from the input stream. */
2728 if (namelen == 2 && uptokstart[0] == 'I' && uptokstart[1] == 'F')
2738 /* Catch specific keywords. Should be done with a data structure. */
2742 if (strcmp (uptokstart, "OBJECT") == 0)
2747 if (strcmp (uptokstart, "RECORD") == 0)
2752 if (strcmp (uptokstart, "SIZEOF") == 0)
2759 if (strcmp (uptokstart, "CLASS") == 0)
2764 if (strcmp (uptokstart, "FALSE") == 0)
2768 return FALSEKEYWORD;
2772 if (strcmp (uptokstart, "TRUE") == 0)
2778 if (strcmp (uptokstart, "SELF") == 0)
2780 /* here we search for 'this' like
2781 inserted in FPC stabs debug info */
2782 static const char this_name[] = "this";
2784 if (lookup_symbol (this_name, expression_context_block,
2785 VAR_DOMAIN, (int *) NULL))
2796 yylval.sval.ptr = tokstart;
2797 yylval.sval.length = namelen;
2799 if (*tokstart == '$')
2801 /* $ is the normal prefix for pascal hexadecimal values
2802 but this conflicts with the GDB use for debugger variables
2803 so in expression to enter hexadecimal values
2804 we still need to use C syntax with 0xff */
2805 write_dollar_variable (yylval.sval);
2810 /* Use token-type BLOCKNAME for symbols that happen to be defined as
2811 functions or symtabs. If this is not so, then ...
2812 Use token-type TYPENAME for symbols that happen to be defined
2813 currently as names of types; NAME for other symbols.
2814 The caller is not constrained to care about the distinction. */
2816 char *tmp = copy_name (yylval.sval);
2818 int is_a_field_of_this = 0;
2823 if (search_field && current_type)
2824 is_a_field = (lookup_struct_elt_type (current_type, tmp, 1) != NULL);
2828 sym = lookup_symbol (tmp, expression_context_block,
2829 VAR_DOMAIN, &is_a_field_of_this);
2830 /* second chance uppercased (as Free Pascal does). */
2831 if (!sym && !is_a_field_of_this && !is_a_field)
2833 for (i = 0; i <= namelen; i++)
2835 if ((tmp[i] >= 'a' && tmp[i] <= 'z'))
2836 tmp[i] -= ('a'-'A');
2838 if (search_field && current_type)
2839 is_a_field = (lookup_struct_elt_type (current_type, tmp, 1) != NULL);
2843 sym = lookup_symbol (tmp, expression_context_block,
2844 VAR_DOMAIN, &is_a_field_of_this);
2845 if (sym || is_a_field_of_this || is_a_field)
2846 for (i = 0; i <= namelen; i++)
2848 if ((tokstart[i] >= 'a' && tokstart[i] <= 'z'))
2849 tokstart[i] -= ('a'-'A');
2852 /* Third chance Capitalized (as GPC does). */
2853 if (!sym && !is_a_field_of_this && !is_a_field)
2855 for (i = 0; i <= namelen; i++)
2859 if ((tmp[i] >= 'a' && tmp[i] <= 'z'))
2860 tmp[i] -= ('a'-'A');
2863 if ((tmp[i] >= 'A' && tmp[i] <= 'Z'))
2864 tmp[i] -= ('A'-'a');
2866 if (search_field && current_type)
2867 is_a_field = (lookup_struct_elt_type (current_type, tmp, 1) != NULL);
2871 sym = lookup_symbol (tmp, expression_context_block,
2872 VAR_DOMAIN, &is_a_field_of_this);
2873 if (sym || is_a_field_of_this || is_a_field)
2874 for (i = 0; i <= namelen; i++)
2878 if ((tokstart[i] >= 'a' && tokstart[i] <= 'z'))
2879 tokstart[i] -= ('a'-'A');
2882 if ((tokstart[i] >= 'A' && tokstart[i] <= 'Z'))
2883 tokstart[i] -= ('A'-'a');
2889 tempbuf = (char *) xrealloc (tempbuf, namelen + 1);
2890 strncpy (tempbuf, tokstart, namelen); tempbuf [namelen] = 0;
2891 yylval.sval.ptr = tempbuf;
2892 yylval.sval.length = namelen;
2896 /* Call lookup_symtab, not lookup_partial_symtab, in case there are
2897 no psymtabs (coff, xcoff, or some future change to blow away the
2898 psymtabs once once symbols are read). */
2899 if ((sym && SYMBOL_CLASS (sym) == LOC_BLOCK)
2900 || lookup_symtab (tmp))
2902 yylval.ssym.sym = sym;
2903 yylval.ssym.is_a_field_of_this = is_a_field_of_this;
2907 if (sym && SYMBOL_CLASS (sym) == LOC_TYPEDEF)
2910 /* Despite the following flaw, we need to keep this code enabled.
2911 Because we can get called from check_stub_method, if we don't
2912 handle nested types then it screws many operations in any
2913 program which uses nested types. */
2914 /* In "A::x", if x is a member function of A and there happens
2915 to be a type (nested or not, since the stabs don't make that
2916 distinction) named x, then this code incorrectly thinks we
2917 are dealing with nested types rather than a member function. */
2921 struct symbol *best_sym;
2923 /* Look ahead to detect nested types. This probably should be
2924 done in the grammar, but trying seemed to introduce a lot
2925 of shift/reduce and reduce/reduce conflicts. It's possible
2926 that it could be done, though. Or perhaps a non-grammar, but
2927 less ad hoc, approach would work well. */
2929 /* Since we do not currently have any way of distinguishing
2930 a nested type from a non-nested one (the stabs don't tell
2931 us whether a type is nested), we just ignore the
2938 /* Skip whitespace. */
2939 while (*p == ' ' || *p == '\t' || *p == '\n')
2941 if (*p == ':' && p[1] == ':')
2943 /* Skip the `::'. */
2945 /* Skip whitespace. */
2946 while (*p == ' ' || *p == '\t' || *p == '\n')
2949 while (*p == '_' || *p == '$' || (*p >= '0' && *p <= '9')
2950 || (*p >= 'a' && *p <= 'z')
2951 || (*p >= 'A' && *p <= 'Z'))
2955 struct symbol *cur_sym;
2956 /* As big as the whole rest of the expression, which is
2957 at least big enough. */
2958 char *ncopy = alloca (strlen (tmp)+strlen (namestart)+3);
2962 memcpy (tmp1, tmp, strlen (tmp));
2963 tmp1 += strlen (tmp);
2964 memcpy (tmp1, "::", 2);
2966 memcpy (tmp1, namestart, p - namestart);
2967 tmp1[p - namestart] = '\0';
2968 cur_sym = lookup_symbol (ncopy, expression_context_block,
2969 VAR_DOMAIN, (int *) NULL);
2972 if (SYMBOL_CLASS (cur_sym) == LOC_TYPEDEF)
2990 yylval.tsym.type = SYMBOL_TYPE (best_sym);
2992 yylval.tsym.type = SYMBOL_TYPE (sym);
2998 = language_lookup_primitive_type_by_name (parse_language,
2999 parse_gdbarch, tmp);
3000 if (yylval.tsym.type != NULL)
3006 /* Input names that aren't symbols but ARE valid hex numbers,
3007 when the input radix permits them, can be names or numbers
3008 depending on the parse. Note we support radixes > 16 here. */
3010 && ((tokstart[0] >= 'a' && tokstart[0] < 'a' + input_radix - 10)
3011 || (tokstart[0] >= 'A' && tokstart[0] < 'A' + input_radix - 10)))
3013 YYSTYPE newlval; /* Its value is ignored. */
3014 hextype = parse_number (tokstart, namelen, 0, &newlval);
3017 yylval.ssym.sym = sym;
3018 yylval.ssym.is_a_field_of_this = is_a_field_of_this;
3025 /* Any other kind of symbol */
3026 yylval.ssym.sym = sym;
3027 yylval.ssym.is_a_field_of_this = is_a_field_of_this;
3037 lexptr = prev_lexptr;
3039 error ("A %s in expression, near `%s'.", (msg ? msg : "error"), lexptr);