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