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