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