1 /* A Bison parser, made by GNU Bison 1.875c. */
3 /* Skeleton parser for Yacc-like parsing with Bison,
4 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
21 /* As a special exception, when this file is copied by Bison into a
22 Bison output file, you may use that output file without restriction.
23 This special exception was added by the Free Software Foundation
24 in version 1.24 of Bison. */
26 /* Written by Richard Stallman by simplifying the original so called
27 ``semantic'' parser. */
29 /* All symbols defined below should begin with yy or YY, to avoid
30 infringing on user name space. This should be done even for local
31 variables, as they might otherwise be expanded by user macros.
32 There are some unavoidable exceptions within include files to
33 define necessary library symbols; they are noted "INFRINGES ON
34 USER NAME SPACE" below. */
36 /* Identify Bison output. */
40 #define YYSKELETON_NAME "yacc.c"
45 /* Using locations. */
46 #define YYLSP_NEEDED 0
53 /* Put the tokens into the symbol table, so that GDB and other debuggers
56 INTEGER_LITERAL
= 258,
57 FLOATING_POINT_LITERAL
= 259,
60 BOOLEAN_LITERAL
= 262,
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
94 #define NAME_OR_INT 264
105 #define ASSIGN_MODIFY 275
116 #define DECREMENT 286
117 #define INCREMENT 287
122 /* Copy the first part of user declarations. */
127 #include "gdb_string.h"
129 #include "expression.h"
131 #include "parser-defs.h"
132 #include "language.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 */
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. */
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
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
166 #define yy_yys java_yys
167 #define yystate java_state
168 #define yytmp java_tmp
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
188 #define YYDEBUG 1 /* Default to yydebug support */
191 #define YYFPRINTF parser_fprintf
195 static int yylex (void);
197 void yyerror (char *);
199 static struct type
*java_type_from_name (struct stoken
);
200 static void push_expression_name (struct stoken
);
201 static void push_fieldnames (struct stoken
);
203 static struct expression
*copy_exp (struct expression
*, int);
204 static void insert_exp (int, struct expression
*);
208 /* Enabling traces. */
213 /* Enabling verbose error messages. */
214 #ifdef YYERROR_VERBOSE
215 # undef YYERROR_VERBOSE
216 # define YYERROR_VERBOSE 1
218 # define YYERROR_VERBOSE 0
221 #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
223 typedef union YYSTYPE
{
237 struct symtoken ssym
;
239 enum exp_opcode opcode
;
240 struct internalvar
*ivar
;
243 /* Line 191 of yacc.c. */
244 #line 245 "jv-exp.c.tmp"
245 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
246 # define YYSTYPE_IS_DECLARED 1
247 # define YYSTYPE_IS_TRIVIAL 1
252 /* Copy the second part of user declarations. */
255 /* YYSTYPE gets defined by %union */
256 static int parse_number (char *, int, int, YYSTYPE
*);
259 /* Line 214 of yacc.c. */
260 #line 261 "jv-exp.c.tmp"
262 #if ! defined (yyoverflow) || YYERROR_VERBOSE
268 # define YYMALLOC xmalloc
271 /* The parser invokes alloca or xmalloc; define the necessary symbols. */
273 # ifdef YYSTACK_USE_ALLOCA
274 # if YYSTACK_USE_ALLOCA
275 # define YYSTACK_ALLOC alloca
278 # if defined (alloca) || defined (_ALLOCA_H)
279 # define YYSTACK_ALLOC alloca
282 # define YYSTACK_ALLOC __builtin_alloca
287 # ifdef YYSTACK_ALLOC
288 /* Pacify GCC's `empty if-body' warning. */
289 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
291 # if defined (__STDC__) || defined (__cplusplus)
292 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
293 # define YYSIZE_T size_t
295 # define YYSTACK_ALLOC YYMALLOC
296 # define YYSTACK_FREE YYFREE
298 #endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
301 #if (! defined (yyoverflow) \
302 && (! defined (__cplusplus) \
303 || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL)))
305 /* A type that is properly aligned for any stack member. */
312 /* The size of the maximum gap between one aligned stack and the next. */
313 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
315 /* The size of an array large to enough to hold all stacks, each with
317 # define YYSTACK_BYTES(N) \
318 ((N) * (sizeof (short) + sizeof (YYSTYPE)) \
319 + YYSTACK_GAP_MAXIMUM)
321 /* Copy COUNT objects from FROM to TO. The source and destination do
324 # if defined (__GNUC__) && 1 < __GNUC__
325 # define YYCOPY(To, From, Count) \
326 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
328 # define YYCOPY(To, From, Count) \
331 register YYSIZE_T yyi; \
332 for (yyi = 0; yyi < (Count); yyi++) \
333 (To)[yyi] = (From)[yyi]; \
339 /* Relocate STACK from its old location to the new one. The
340 local variables YYSIZE and YYSTACKSIZE give the old and new number of
341 elements in the stack, and YYPTR gives the new location of the
342 stack. Advance YYPTR to a properly aligned location for the next
344 # define YYSTACK_RELOCATE(Stack) \
347 YYSIZE_T yynewbytes; \
348 YYCOPY (&yyptr->Stack, Stack, yysize); \
349 Stack = &yyptr->Stack; \
350 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
351 yyptr += yynewbytes / sizeof (*yyptr); \
357 #if defined (__STDC__) || defined (__cplusplus)
358 typedef signed char yysigned_char
;
360 typedef short yysigned_char
;
363 /* YYFINAL -- State number of the termination state. */
365 /* YYLAST -- Last index in YYTABLE. */
368 /* YYNTOKENS -- Number of terminals. */
370 /* YYNNTS -- Number of nonterminals. */
372 /* YYNRULES -- Number of rules. */
374 /* YYNRULES -- Number of states. */
375 #define YYNSTATES 209
377 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
379 #define YYMAXUTOK 287
381 #define YYTRANSLATE(YYX) \
382 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
384 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
385 static const unsigned char yytranslate
[] =
387 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
388 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
389 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
390 2, 2, 2, 54, 2, 2, 2, 43, 30, 2,
391 48, 49, 41, 39, 23, 40, 46, 42, 2, 2,
392 2, 2, 2, 2, 2, 2, 2, 2, 55, 2,
393 33, 24, 34, 25, 2, 2, 2, 2, 2, 2,
394 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
395 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
396 2, 47, 2, 52, 29, 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, 2, 2, 50, 28, 51, 53, 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, 2, 2, 2, 2,
411 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
412 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
413 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
414 15, 16, 17, 18, 19, 20, 21, 22, 26, 27,
415 31, 32, 35, 36, 37, 38, 44, 45
419 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
421 static const unsigned short yyprhs
[] =
423 0, 0, 3, 5, 7, 9, 11, 13, 15, 17,
424 19, 21, 23, 25, 27, 29, 31, 33, 35, 37,
425 39, 41, 43, 45, 47, 49, 51, 54, 57, 59,
426 61, 63, 65, 67, 69, 73, 75, 79, 81, 83,
427 85, 89, 91, 93, 95, 97, 101, 103, 105, 111,
428 113, 117, 118, 120, 125, 130, 132, 135, 139, 142,
429 146, 148, 149, 153, 157, 160, 161, 166, 173, 180,
430 185, 190, 195, 197, 199, 201, 203, 205, 208, 211,
431 213, 215, 218, 221, 224, 226, 229, 232, 234, 237,
432 240, 242, 248, 253, 259, 261, 265, 269, 273, 275,
433 279, 283, 285, 289, 293, 295, 299, 303, 307, 311,
434 313, 317, 321, 323, 327, 329, 333, 335, 339, 341,
435 345, 347, 351, 353, 359, 361, 363, 367, 371, 373,
439 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
440 static const yysigned_char yyrhs
[] =
442 57, 0, -1, 73, -1, 58, -1, 59, -1, 62,
443 -1, 68, -1, 6, -1, 3, -1, 9, -1, 4,
444 -1, 7, -1, 60, -1, 63, -1, 16, -1, 64,
445 -1, 65, -1, 13, -1, 12, -1, 14, -1, 11,
446 -1, 15, -1, 18, -1, 17, -1, 69, -1, 66,
447 -1, 62, 84, -1, 69, 84, -1, 5, -1, 72,
448 -1, 71, -1, 72, -1, 5, -1, 9, -1, 69,
449 46, 71, -1, 113, -1, 73, 23, 113, -1, 75,
450 -1, 81, -1, 61, -1, 48, 113, 49, -1, 78,
451 -1, 86, -1, 88, -1, 90, -1, 76, 79, 77,
452 -1, 50, -1, 51, -1, 22, 67, 48, 80, 49,
453 -1, 113, -1, 79, 23, 113, -1, -1, 79, -1,
454 22, 62, 82, 85, -1, 22, 66, 82, 85, -1,
455 83, -1, 82, 83, -1, 47, 113, 52, -1, 47,
456 52, -1, 84, 47, 52, -1, 84, -1, -1, 74,
457 46, 71, -1, 19, 46, 71, -1, 69, 48, -1,
458 -1, 87, 89, 80, 49, -1, 74, 46, 71, 48,
459 80, 49, -1, 21, 46, 71, 48, 80, 49, -1,
460 69, 47, 113, 52, -1, 19, 47, 113, 52, -1,
461 75, 47, 113, 52, -1, 74, -1, 69, -1, 19,
462 -1, 92, -1, 93, -1, 91, 45, -1, 91, 44,
463 -1, 95, -1, 96, -1, 39, 94, -1, 40, 94,
464 -1, 41, 94, -1, 97, -1, 45, 94, -1, 44,
465 94, -1, 91, -1, 53, 94, -1, 54, 94, -1,
466 98, -1, 48, 62, 85, 49, 94, -1, 48, 113,
467 49, 97, -1, 48, 69, 84, 49, 97, -1, 94,
468 -1, 99, 41, 94, -1, 99, 42, 94, -1, 99,
469 43, 94, -1, 99, -1, 100, 39, 99, -1, 100,
470 40, 99, -1, 100, -1, 101, 38, 100, -1, 101,
471 37, 100, -1, 101, -1, 102, 33, 101, -1, 102,
472 34, 101, -1, 102, 36, 101, -1, 102, 35, 101,
473 -1, 102, -1, 103, 32, 102, -1, 103, 31, 102,
474 -1, 103, -1, 104, 30, 103, -1, 104, -1, 105,
475 29, 104, -1, 105, -1, 106, 28, 105, -1, 106,
476 -1, 107, 27, 106, -1, 107, -1, 108, 26, 107,
477 -1, 108, -1, 108, 25, 113, 55, 109, -1, 109,
478 -1, 111, -1, 112, 24, 109, -1, 112, 20, 109,
479 -1, 70, -1, 19, -1, 86, -1, 90, -1, 110,
483 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
484 static const unsigned short yyrline
[] =
486 0, 205, 205, 206, 209, 218, 219, 223, 232, 237,
487 245, 250, 255, 266, 267, 272, 273, 277, 279, 281,
488 283, 285, 290, 292, 304, 309, 313, 315, 320, 321,
489 325, 326, 330, 331, 335, 358, 359, 364, 365, 369,
490 370, 371, 372, 373, 374, 375, 383, 388, 393, 399,
491 401, 407, 408, 412, 415, 421, 422, 426, 430, 432,
492 437, 439, 443, 445, 451, 457, 456, 462, 464, 469,
493 486, 488, 493, 494, 496, 498, 499, 503, 508, 513,
494 514, 515, 516, 518, 520, 524, 529, 534, 535, 537,
495 539, 543, 547, 568, 576, 577, 579, 581, 586, 587,
496 589, 594, 595, 597, 603, 604, 606, 608, 610, 616,
497 617, 619, 624, 625, 630, 631, 635, 636, 641, 642,
498 647, 648, 653, 654, 659, 660, 664, 666, 673, 675,
503 #if YYDEBUG || YYERROR_VERBOSE
504 /* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
505 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
506 static const char *const yytname
[] =
508 "$end", "error", "$undefined", "INTEGER_LITERAL",
509 "FLOATING_POINT_LITERAL", "IDENTIFIER", "STRING_LITERAL",
510 "BOOLEAN_LITERAL", "TYPENAME", "NAME_OR_INT", "ERROR", "LONG", "SHORT",
511 "BYTE", "INT", "CHAR", "BOOLEAN", "DOUBLE", "FLOAT", "VARIABLE",
512 "ASSIGN_MODIFY", "SUPER", "NEW", "','", "'='", "'?'", "OROR", "ANDAND",
513 "'|'", "'^'", "'&'", "NOTEQUAL", "EQUAL", "'<'", "'>'", "GEQ", "LEQ",
514 "RSH", "LSH", "'+'", "'-'", "'*'", "'/'", "'%'", "DECREMENT",
515 "INCREMENT", "'.'", "'['", "'('", "')'", "'{'", "'}'", "']'", "'~'",
516 "'!'", "':'", "$accept", "start", "type_exp", "PrimitiveOrArrayType",
517 "StringLiteral", "Literal", "PrimitiveType", "NumericType",
518 "IntegralType", "FloatingPointType", "ClassOrInterfaceType", "ClassType",
519 "ArrayType", "Name", "ForcedName", "SimpleName", "QualifiedName", "exp1",
520 "Primary", "PrimaryNoNewArray", "lcurly", "rcurly",
521 "ClassInstanceCreationExpression", "ArgumentList", "ArgumentList_opt",
522 "ArrayCreationExpression", "DimExprs", "DimExpr", "Dims", "Dims_opt",
523 "FieldAccess", "FuncStart", "MethodInvocation", "@1", "ArrayAccess",
524 "PostfixExpression", "PostIncrementExpression",
525 "PostDecrementExpression", "UnaryExpression", "PreIncrementExpression",
526 "PreDecrementExpression", "UnaryExpressionNotPlusMinus",
527 "CastExpression", "MultiplicativeExpression", "AdditiveExpression",
528 "ShiftExpression", "RelationalExpression", "EqualityExpression",
529 "AndExpression", "ExclusiveOrExpression", "InclusiveOrExpression",
530 "ConditionalAndExpression", "ConditionalOrExpression",
531 "ConditionalExpression", "AssignmentExpression", "Assignment",
532 "LeftHandSide", "Expression", 0
537 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
539 static const unsigned short yytoknum
[] =
541 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
542 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
543 275, 276, 277, 44, 61, 63, 278, 279, 124, 94,
544 38, 280, 281, 60, 62, 282, 283, 284, 285, 43,
545 45, 42, 47, 37, 286, 287, 46, 91, 40, 41,
546 123, 125, 93, 126, 33, 58
550 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
551 static const unsigned char yyr1
[] =
553 0, 56, 57, 57, 58, 59, 59, 60, 61, 61,
554 61, 61, 61, 62, 62, 63, 63, 64, 64, 64,
555 64, 64, 65, 65, 66, 67, 68, 68, 69, 69,
556 70, 70, 71, 71, 72, 73, 73, 74, 74, 75,
557 75, 75, 75, 75, 75, 75, 76, 77, 78, 79,
558 79, 80, 80, 81, 81, 82, 82, 83, 84, 84,
559 85, 85, 86, 86, 87, 89, 88, 88, 88, 90,
560 90, 90, 91, 91, 91, 91, 91, 92, 93, 94,
561 94, 94, 94, 94, 94, 95, 96, 97, 97, 97,
562 97, 98, 98, 98, 99, 99, 99, 99, 100, 100,
563 100, 101, 101, 101, 102, 102, 102, 102, 102, 103,
564 103, 103, 104, 104, 105, 105, 106, 106, 107, 107,
565 108, 108, 109, 109, 110, 110, 111, 111, 112, 112,
569 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
570 static const unsigned char yyr2
[] =
572 0, 2, 1, 1, 1, 1, 1, 1, 1, 1,
573 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
574 1, 1, 1, 1, 1, 1, 2, 2, 1, 1,
575 1, 1, 1, 1, 3, 1, 3, 1, 1, 1,
576 3, 1, 1, 1, 1, 3, 1, 1, 5, 1,
577 3, 0, 1, 4, 4, 1, 2, 3, 2, 3,
578 1, 0, 3, 3, 2, 0, 4, 6, 6, 4,
579 4, 4, 1, 1, 1, 1, 1, 2, 2, 1,
580 1, 2, 2, 2, 1, 2, 2, 1, 2, 2,
581 1, 5, 4, 5, 1, 3, 3, 3, 1, 3,
582 3, 1, 3, 3, 1, 3, 3, 3, 3, 1,
583 3, 3, 1, 3, 1, 3, 1, 3, 1, 3,
584 1, 3, 1, 5, 1, 1, 3, 3, 1, 1,
588 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
589 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
590 means the default is an error. */
591 static const unsigned char yydefact
[] =
593 0, 8, 10, 28, 7, 11, 9, 20, 18, 17,
594 19, 21, 14, 23, 22, 74, 0, 0, 0, 0,
595 0, 0, 0, 0, 46, 0, 0, 0, 3, 4,
596 12, 39, 5, 13, 15, 16, 6, 73, 128, 30,
597 29, 2, 72, 37, 0, 41, 38, 42, 65, 43,
598 44, 87, 75, 76, 94, 79, 80, 84, 90, 98,
599 101, 104, 109, 112, 114, 116, 118, 120, 122, 124,
600 132, 125, 0, 35, 0, 0, 0, 28, 0, 25,
601 0, 24, 29, 9, 74, 73, 42, 44, 81, 82,
602 83, 86, 85, 61, 73, 0, 88, 89, 1, 0,
603 26, 0, 0, 64, 27, 0, 0, 0, 0, 49,
604 51, 78, 77, 0, 0, 0, 0, 0, 0, 0,
605 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
606 0, 0, 0, 0, 32, 33, 63, 0, 0, 0,
607 61, 55, 61, 51, 0, 60, 0, 0, 40, 58,
608 0, 34, 0, 36, 62, 0, 0, 47, 45, 52,
609 0, 95, 96, 97, 99, 100, 103, 102, 105, 106,
610 108, 107, 111, 110, 113, 115, 117, 119, 0, 121,
611 127, 126, 70, 51, 0, 0, 56, 53, 54, 0,
612 0, 0, 92, 59, 69, 51, 71, 50, 66, 0,
613 0, 57, 48, 91, 93, 0, 123, 68, 67
616 /* YYDEFGOTO[NTERM-NUM]. */
617 static const short yydefgoto
[] =
619 -1, 27, 28, 29, 30, 31, 32, 33, 34, 35,
620 79, 80, 36, 85, 38, 39, 82, 41, 42, 43,
621 44, 158, 45, 159, 160, 46, 140, 141, 145, 146,
622 86, 48, 49, 110, 87, 51, 52, 53, 54, 55,
623 56, 57, 58, 59, 60, 61, 62, 63, 64, 65,
624 66, 67, 68, 69, 70, 71, 72, 109
627 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
629 #define YYPACT_NINF -145
630 static const short yypact
[] =
632 215, -145, -145, -5, -145, -145, 1, -145, -145, -145,
633 -145, -145, -145, -145, -145, -7, -19, 279, 50, 50,
634 50, 50, 50, 215, -145, 50, 50, 46, -145, -145,
635 -145, -145, -9, -145, -145, -145, -145, 87, -145, -145,
636 12, 44, 5, 16, 319, -145, -145, 28, -145, -145,
637 38, 29, -145, -145, -145, -145, -145, -145, -145, 99,
638 53, 85, 52, 94, 66, 41, 71, 74, 122, -145,
639 -145, -145, 40, -145, 26, 319, 26, -145, 59, 59,
640 67, 82, -145, -145, 111, 107, -145, -145, -145, -145,
641 -145, -145, -145, -9, 87, 68, -145, -145, -145, 79,
642 91, 26, 267, -145, 91, 319, 26, 319, -18, -145,
643 319, -145, -145, 50, 50, 50, 50, 50, 50, 50,
644 50, 50, 50, 50, 50, 50, 50, 50, 50, 50,
645 319, 50, 50, 50, -145, -145, -145, 112, 126, 319,
646 128, -145, 128, 319, 319, 91, 127, -31, 193, -145,
647 125, -145, 129, -145, 131, 130, 319, -145, -145, 157,
648 135, -145, -145, -145, 99, 99, 53, 53, 85, 85,
649 85, 85, 52, 52, 94, 66, 41, 71, 132, 74,
650 -145, -145, -145, 319, 134, 267, -145, -145, -145, 139,
651 50, 193, -145, -145, -145, 319, -145, -145, -145, 50,
652 141, -145, -145, -145, -145, 144, -145, -145, -145
655 /* YYPGOTO[NTERM-NUM]. */
656 static const short yypgoto
[] =
658 -145, -145, -145, -145, -145, -145, -3, -145, -145, -145,
659 -145, -145, -145, 11, -145, -64, 0, -145, -145, -145,
660 -145, -145, -145, 150, -134, -145, 124, -116, -29, -99,
661 6, -145, -145, -145, 22, -145, -145, -145, 58, -145,
662 -145, -144, -145, 43, 49, -2, 45, 78, 81, 83,
663 77, 92, -145, -131, -145, -145, -145, 7
666 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
667 positive, shift that token. If negative, reduce the rule which
668 number is the opposite. If zero, do what YYDEFACT says.
669 If YYTABLE_NINF, syntax error. */
670 #define YYTABLE_NINF -132
671 static const short yytable
[] =
673 40, 180, 181, 100, 192, 156, 47, 73, 104, 189,
674 136, 37, 138, -129, 78, -32, 150, -129, 191, -32,
675 93, -33, 50, 40, 186, -33, 186, 76, 81, 47,
676 95, 134, -31, 157, 94, 135, -31, 151, 99, 74,
677 75, 187, 154, 188, 40, 50, 98, 204, -130, 200,
678 47, 106, -130, 1, 2, 77, 4, 5, -131, 83,
679 132, 205, -131, 107, 133, 147, 50, 105, 206, 84,
680 127, 16, 17, 111, 112, 40, 88, 89, 90, 91,
681 92, 47, 137, 96, 97, 120, 121, 122, 123, 18,
682 19, 20, 116, 117, 21, 22, 126, 50, 23, 128,
683 24, 129, 40, 25, 26, 40, 139, 40, 47, 152,
684 40, 47, 153, 47, 155, 143, 47, 148, 168, 169,
685 170, 171, 118, 119, 50, 124, 125, 50, 101, 50,
686 40, 149, 50, 101, 102, 103, 47, 178, 150, 40,
687 113, 114, 115, 40, 40, 47, 184, 130, 131, 47,
688 47, 152, 50, 101, 144, 103, 40, 74, 75, 164,
689 165, 50, 47, 197, 182, 50, 50, 166, 167, 172,
690 173, 161, 162, 163, 183, 185, 190, 193, 50, 195,
691 156, 194, 196, 40, 198, 40, 201, 199, 202, 47,
692 207, 47, 184, 208, 108, 40, 1, 2, 77, 4,
693 5, 47, 83, 142, 174, 50, 177, 50, 175, 0,
694 0, 176, 84, 0, 16, 17, 0, 50, 1, 2,
695 3, 4, 5, 179, 6, 0, 7, 8, 9, 10,
696 11, 12, 13, 14, 15, 0, 16, 17, 0, 0,
697 0, 23, 0, 24, 0, 0, 25, 26, 203, 0,
698 0, 0, 0, 0, 18, 19, 20, 0, 0, 21,
699 22, 0, 0, 23, 0, 24, 0, 0, 25, 26,
700 1, 2, 3, 4, 5, 0, 6, 0, 0, 0,
701 0, 0, 0, 0, 77, 0, 15, 0, 16, 17,
702 7, 8, 9, 10, 11, 12, 13, 14, 0, 0,
703 0, 0, 0, 0, 0, 0, 18, 19, 20, 0,
704 0, 21, 22, 0, 0, 23, 0, 24, 0, 149,
705 25, 26, 1, 2, 3, 4, 5, 0, 6, 0,
706 0, 0, 0, 0, 0, 0, 0, 0, 15, 0,
707 16, 17, 0, 0, 0, 0, 0, 0, 0, 0,
708 0, 0, 0, 0, 0, 0, 0, 0, 18, 19,
709 20, 0, 0, 21, 22, 0, 0, 23, 0, 24,
713 static const short yycheck
[] =
715 0, 132, 133, 32, 148, 23, 0, 0, 37, 143,
716 74, 0, 76, 20, 17, 20, 47, 24, 49, 24,
717 23, 20, 0, 23, 140, 24, 142, 46, 17, 23,
718 23, 5, 20, 51, 23, 9, 24, 101, 47, 46,
719 47, 140, 106, 142, 44, 23, 0, 191, 20, 183,
720 44, 46, 24, 3, 4, 5, 6, 7, 20, 9,
721 20, 195, 24, 47, 24, 94, 44, 23, 199, 19,
722 29, 21, 22, 44, 45, 75, 18, 19, 20, 21,
723 22, 75, 75, 25, 26, 33, 34, 35, 36, 39,
724 40, 41, 39, 40, 44, 45, 30, 75, 48, 28,
725 50, 27, 102, 53, 54, 105, 47, 107, 102, 102,
726 110, 105, 105, 107, 107, 48, 110, 49, 120, 121,
727 122, 123, 37, 38, 102, 31, 32, 105, 46, 107,
728 130, 52, 110, 46, 47, 48, 130, 130, 47, 139,
729 41, 42, 43, 143, 144, 139, 139, 25, 26, 143,
730 144, 144, 130, 46, 47, 48, 156, 46, 47, 116,
731 117, 139, 156, 156, 52, 143, 144, 118, 119, 124,
732 125, 113, 114, 115, 48, 47, 49, 52, 156, 48,
733 23, 52, 52, 183, 49, 185, 52, 55, 49, 183,
734 49, 185, 185, 49, 44, 195, 3, 4, 5, 6,
735 7, 195, 9, 79, 126, 183, 129, 185, 127, -1,
736 -1, 128, 19, -1, 21, 22, -1, 195, 3, 4,
737 5, 6, 7, 131, 9, -1, 11, 12, 13, 14,
738 15, 16, 17, 18, 19, -1, 21, 22, -1, -1,
739 -1, 48, -1, 50, -1, -1, 53, 54, 190, -1,
740 -1, -1, -1, -1, 39, 40, 41, -1, -1, 44,
741 45, -1, -1, 48, -1, 50, -1, -1, 53, 54,
742 3, 4, 5, 6, 7, -1, 9, -1, -1, -1,
743 -1, -1, -1, -1, 5, -1, 19, -1, 21, 22,
744 11, 12, 13, 14, 15, 16, 17, 18, -1, -1,
745 -1, -1, -1, -1, -1, -1, 39, 40, 41, -1,
746 -1, 44, 45, -1, -1, 48, -1, 50, -1, 52,
747 53, 54, 3, 4, 5, 6, 7, -1, 9, -1,
748 -1, -1, -1, -1, -1, -1, -1, -1, 19, -1,
749 21, 22, -1, -1, -1, -1, -1, -1, -1, -1,
750 -1, -1, -1, -1, -1, -1, -1, -1, 39, 40,
751 41, -1, -1, 44, 45, -1, -1, 48, -1, 50,
755 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
756 symbol of state STATE-NUM. */
757 static const unsigned char yystos
[] =
759 0, 3, 4, 5, 6, 7, 9, 11, 12, 13,
760 14, 15, 16, 17, 18, 19, 21, 22, 39, 40,
761 41, 44, 45, 48, 50, 53, 54, 57, 58, 59,
762 60, 61, 62, 63, 64, 65, 68, 69, 70, 71,
763 72, 73, 74, 75, 76, 78, 81, 86, 87, 88,
764 90, 91, 92, 93, 94, 95, 96, 97, 98, 99,
765 100, 101, 102, 103, 104, 105, 106, 107, 108, 109,
766 110, 111, 112, 113, 46, 47, 46, 5, 62, 66,
767 67, 69, 72, 9, 19, 69, 86, 90, 94, 94,
768 94, 94, 94, 62, 69, 113, 94, 94, 0, 47,
769 84, 46, 47, 48, 84, 23, 46, 47, 79, 113,
770 89, 44, 45, 41, 42, 43, 39, 40, 37, 38,
771 33, 34, 35, 36, 31, 32, 30, 29, 28, 27,
772 25, 26, 20, 24, 5, 9, 71, 113, 71, 47,
773 82, 83, 82, 48, 47, 84, 85, 84, 49, 52,
774 47, 71, 113, 113, 71, 113, 23, 51, 77, 79,
775 80, 94, 94, 94, 99, 99, 100, 100, 101, 101,
776 101, 101, 102, 102, 103, 104, 105, 106, 113, 107,
777 109, 109, 52, 48, 113, 47, 83, 85, 85, 80,
778 49, 49, 97, 52, 52, 48, 52, 113, 49, 55,
779 80, 52, 49, 94, 97, 80, 109, 49, 49
782 #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
783 # define YYSIZE_T __SIZE_TYPE__
785 #if ! defined (YYSIZE_T) && defined (size_t)
786 # define YYSIZE_T size_t
788 #if ! defined (YYSIZE_T)
789 # if defined (__STDC__) || defined (__cplusplus)
790 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
791 # define YYSIZE_T size_t
794 #if ! defined (YYSIZE_T)
795 # define YYSIZE_T unsigned int
798 #define yyerrok (yyerrstatus = 0)
799 #define yyclearin (yychar = YYEMPTY)
803 #define YYACCEPT goto yyacceptlab
804 #define YYABORT goto yyabortlab
805 #define YYERROR goto yyerrorlab
808 /* Like YYERROR except do call yyerror. This remains here temporarily
809 to ease the transition to the new meaning of YYERROR, for GCC.
810 Once GCC version 2 has supplanted version 1, this can go. */
812 #define YYFAIL goto yyerrlab
814 #define YYRECOVERING() (!!yyerrstatus)
816 #define YYBACKUP(Token, Value) \
818 if (yychar == YYEMPTY && yylen == 1) \
822 yytoken = YYTRANSLATE (yychar); \
828 yyerror ("syntax error: cannot back up");\
834 #define YYERRCODE 256
836 /* YYLLOC_DEFAULT -- Compute the default location (before the actions
839 #ifndef YYLLOC_DEFAULT
840 # define YYLLOC_DEFAULT(Current, Rhs, N) \
841 ((Current).first_line = (Rhs)[1].first_line, \
842 (Current).first_column = (Rhs)[1].first_column, \
843 (Current).last_line = (Rhs)[N].last_line, \
844 (Current).last_column = (Rhs)[N].last_column)
847 /* YYLEX -- calling `yylex' with the right arguments. */
850 # define YYLEX yylex (YYLEX_PARAM)
852 # define YYLEX yylex ()
855 /* Enable debugging if requested. */
859 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
860 # define YYFPRINTF fprintf
863 # define YYDPRINTF(Args) \
869 # define YYDSYMPRINT(Args) \
875 # define YYDSYMPRINTF(Title, Token, Value, Location) \
879 YYFPRINTF (stderr, "%s ", Title); \
880 yysymprint (stderr, \
882 YYFPRINTF (stderr, "\n"); \
886 /*------------------------------------------------------------------.
887 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
889 `------------------------------------------------------------------*/
891 #if defined (__STDC__) || defined (__cplusplus)
893 yy_stack_print (short *bottom
, short *top
)
896 yy_stack_print (bottom
, top
)
901 YYFPRINTF (stderr
, "Stack now");
902 for (/* Nothing. */; bottom
<= top
; ++bottom
)
903 YYFPRINTF (stderr
, " %d", *bottom
);
904 YYFPRINTF (stderr
, "\n");
907 # define YY_STACK_PRINT(Bottom, Top) \
910 yy_stack_print ((Bottom), (Top)); \
914 /*------------------------------------------------.
915 | Report that the YYRULE is going to be reduced. |
916 `------------------------------------------------*/
918 #if defined (__STDC__) || defined (__cplusplus)
920 yy_reduce_print (int yyrule
)
923 yy_reduce_print (yyrule
)
928 unsigned int yylno
= yyrline
[yyrule
];
929 YYFPRINTF (stderr
, "Reducing stack by rule %d (line %u), ",
931 /* Print the symbols being reduced, and their result. */
932 for (yyi
= yyprhs
[yyrule
]; 0 <= yyrhs
[yyi
]; yyi
++)
933 YYFPRINTF (stderr
, "%s ", yytname
[yyrhs
[yyi
]]);
934 YYFPRINTF (stderr
, "-> %s\n", yytname
[yyr1
[yyrule
]]);
937 # define YY_REDUCE_PRINT(Rule) \
940 yy_reduce_print (Rule); \
943 /* Nonzero means print parse trace. It is left uninitialized so that
944 multiple parsers can coexist. */
947 # define YYDPRINTF(Args)
948 # define YYDSYMPRINT(Args)
949 # define YYDSYMPRINTF(Title, Token, Value, Location)
950 # define YY_STACK_PRINT(Bottom, Top)
951 # define YY_REDUCE_PRINT(Rule)
952 #endif /* !YYDEBUG */
955 /* YYINITDEPTH -- initial size of the parser's stacks. */
957 # define YYINITDEPTH 200
960 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
961 if the built-in stack extension method is used).
963 Do not make this value too large; the results are undefined if
964 SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
965 evaluated with infinite-precision integer arithmetic. */
967 #if defined (YYMAXDEPTH) && YYMAXDEPTH == 0
972 # define YYMAXDEPTH 10000
980 # if defined (__GLIBC__) && defined (_STRING_H)
981 # define yystrlen strlen
983 /* Return the length of YYSTR. */
985 # if defined (__STDC__) || defined (__cplusplus)
986 yystrlen (const char *yystr
)
992 register const char *yys
= yystr
;
994 while (*yys
++ != '\0')
997 return yys
- yystr
- 1;
1003 # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
1004 # define yystpcpy stpcpy
1006 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
1009 # if defined (__STDC__) || defined (__cplusplus)
1010 yystpcpy (char *yydest
, const char *yysrc
)
1012 yystpcpy (yydest
, yysrc
)
1017 register char *yyd
= yydest
;
1018 register const char *yys
= yysrc
;
1020 while ((*yyd
++ = *yys
++) != '\0')
1028 #endif /* !YYERROR_VERBOSE */
1033 /*--------------------------------.
1034 | Print this symbol on YYOUTPUT. |
1035 `--------------------------------*/
1037 #if defined (__STDC__) || defined (__cplusplus)
1039 yysymprint (FILE *yyoutput
, int yytype
, YYSTYPE
*yyvaluep
)
1042 yysymprint (yyoutput
, yytype
, yyvaluep
)
1048 /* Pacify ``unused variable'' warnings. */
1051 if (yytype
< YYNTOKENS
)
1053 YYFPRINTF (yyoutput
, "token %s (", yytname
[yytype
]);
1055 YYPRINT (yyoutput
, yytoknum
[yytype
], *yyvaluep
);
1059 YYFPRINTF (yyoutput
, "nterm %s (", yytname
[yytype
]);
1066 YYFPRINTF (yyoutput
, ")");
1069 #endif /* ! YYDEBUG */
1070 /*-----------------------------------------------.
1071 | Release the memory associated to this symbol. |
1072 `-----------------------------------------------*/
1074 #if defined (__STDC__) || defined (__cplusplus)
1076 yydestruct (int yytype
, YYSTYPE
*yyvaluep
)
1079 yydestruct (yytype
, yyvaluep
)
1084 /* Pacify ``unused variable'' warnings. */
1096 /* Prevent warnings from -Wmissing-prototypes. */
1098 #ifdef YYPARSE_PARAM
1099 # if defined (__STDC__) || defined (__cplusplus)
1100 int yyparse (void *YYPARSE_PARAM
);
1104 #else /* ! YYPARSE_PARAM */
1105 #if defined (__STDC__) || defined (__cplusplus)
1110 #endif /* ! YYPARSE_PARAM */
1114 /* The lookahead symbol. */
1117 /* The semantic value of the lookahead symbol. */
1120 /* Number of syntax errors so far. */
1129 #ifdef YYPARSE_PARAM
1130 # if defined (__STDC__) || defined (__cplusplus)
1131 int yyparse (void *YYPARSE_PARAM
)
1133 int yyparse (YYPARSE_PARAM
)
1134 void *YYPARSE_PARAM
;
1136 #else /* ! YYPARSE_PARAM */
1137 #if defined (__STDC__) || defined (__cplusplus)
1148 register int yystate
;
1151 /* Number of tokens to shift before error messages enabled. */
1153 /* Lookahead token as an internal (translated) token number. */
1156 /* Three stacks and their tools:
1157 `yyss': related to states,
1158 `yyvs': related to semantic values,
1159 `yyls': related to locations.
1161 Refer to the stacks thru separate pointers, to allow yyoverflow
1162 to xreallocate them elsewhere. */
1164 /* The state stack. */
1165 short yyssa
[YYINITDEPTH
];
1166 short *yyss
= yyssa
;
1167 register short *yyssp
;
1169 /* The semantic value stack. */
1170 YYSTYPE yyvsa
[YYINITDEPTH
];
1171 YYSTYPE
*yyvs
= yyvsa
;
1172 register YYSTYPE
*yyvsp
;
1176 #define YYPOPSTACK (yyvsp--, yyssp--)
1178 YYSIZE_T yystacksize
= YYINITDEPTH
;
1180 /* The variables used to return semantic value and location from the
1185 /* When reducing, the number of symbols on the RHS of the reduced
1189 YYDPRINTF ((stderr
, "Starting parse\n"));
1194 yychar
= YYEMPTY
; /* Cause a token to be read. */
1196 /* Initialize stack pointers.
1197 Waste one element of value and location stack
1198 so that they stay on the same level as the state stack.
1199 The wasted elements are never initialized. */
1206 /*------------------------------------------------------------.
1207 | yynewstate -- Push a new state, which is found in yystate. |
1208 `------------------------------------------------------------*/
1210 /* In all cases, when you get here, the value and location stacks
1211 have just been pushed. so pushing a state here evens the stacks.
1218 if (yyss
+ yystacksize
- 1 <= yyssp
)
1220 /* Get the current used size of the three stacks, in elements. */
1221 YYSIZE_T yysize
= yyssp
- yyss
+ 1;
1225 /* Give user a chance to xreallocate the stack. Use copies of
1226 these so that the &'s don't force the real ones into
1228 YYSTYPE
*yyvs1
= yyvs
;
1229 short *yyss1
= yyss
;
1232 /* Each stack pointer address is followed by the size of the
1233 data in use in that stack, in bytes. This used to be a
1234 conditional around just the two extra args, but that might
1235 be undefined if yyoverflow is a macro. */
1236 yyoverflow ("parser stack overflow",
1237 &yyss1
, yysize
* sizeof (*yyssp
),
1238 &yyvs1
, yysize
* sizeof (*yyvsp
),
1245 #else /* no yyoverflow */
1246 # ifndef YYSTACK_RELOCATE
1249 /* Extend the stack our own way. */
1250 if (YYMAXDEPTH
<= yystacksize
)
1253 if (YYMAXDEPTH
< yystacksize
)
1254 yystacksize
= YYMAXDEPTH
;
1257 short *yyss1
= yyss
;
1258 union yyalloc
*yyptr
=
1259 (union yyalloc
*) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize
));
1262 YYSTACK_RELOCATE (yyss
);
1263 YYSTACK_RELOCATE (yyvs
);
1265 # undef YYSTACK_RELOCATE
1267 YYSTACK_FREE (yyss1
);
1270 #endif /* no yyoverflow */
1272 yyssp
= yyss
+ yysize
- 1;
1273 yyvsp
= yyvs
+ yysize
- 1;
1276 YYDPRINTF ((stderr
, "Stack size increased to %lu\n",
1277 (unsigned long int) yystacksize
));
1279 if (yyss
+ yystacksize
- 1 <= yyssp
)
1283 YYDPRINTF ((stderr
, "Entering state %d\n", yystate
));
1292 /* Do appropriate processing given the current state. */
1293 /* Read a lookahead token if we need one and don't already have one. */
1296 /* First try to decide what to do without reference to lookahead token. */
1298 yyn
= yypact
[yystate
];
1299 if (yyn
== YYPACT_NINF
)
1302 /* Not known => get a lookahead token if don't already have one. */
1304 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1305 if (yychar
== YYEMPTY
)
1307 YYDPRINTF ((stderr
, "Reading a token: "));
1311 if (yychar
<= YYEOF
)
1313 yychar
= yytoken
= YYEOF
;
1314 YYDPRINTF ((stderr
, "Now at end of input.\n"));
1318 yytoken
= YYTRANSLATE (yychar
);
1319 YYDSYMPRINTF ("Next token is", yytoken
, &yylval
, &yylloc
);
1322 /* If the proper action on seeing token YYTOKEN is to reduce or to
1323 detect an error, take that action. */
1325 if (yyn
< 0 || YYLAST
< yyn
|| yycheck
[yyn
] != yytoken
)
1330 if (yyn
== 0 || yyn
== YYTABLE_NINF
)
1339 /* Shift the lookahead token. */
1340 YYDPRINTF ((stderr
, "Shifting token %s, ", yytname
[yytoken
]));
1342 /* Discard the token being shifted unless it is eof. */
1343 if (yychar
!= YYEOF
)
1349 /* Count tokens shifted since error; after three, turn off error
1358 /*-----------------------------------------------------------.
1359 | yydefault -- do the default action for the current state. |
1360 `-----------------------------------------------------------*/
1362 yyn
= yydefact
[yystate
];
1368 /*-----------------------------.
1369 | yyreduce -- Do a reduction. |
1370 `-----------------------------*/
1372 /* yyn is the number of a rule to reduce with. */
1375 /* If YYLEN is nonzero, implement the default value of the action:
1378 Otherwise, the following line sets YYVAL to garbage.
1379 This behavior is undocumented and Bison
1380 users should not rely upon it. Assigning to YYVAL
1381 unconditionally makes the parser a bit smaller, and it avoids a
1382 GCC warning that YYVAL may be used uninitialized. */
1383 yyval
= yyvsp
[1-yylen
];
1386 YY_REDUCE_PRINT (yyn
);
1390 #line 210 "jv-exp.y"
1392 write_exp_elt_opcode(OP_TYPE
);
1393 write_exp_elt_type(yyvsp
[0].tval
);
1394 write_exp_elt_opcode(OP_TYPE
);
1399 #line 224 "jv-exp.y"
1401 write_exp_elt_opcode (OP_STRING
);
1402 write_exp_string (yyvsp
[0].sval
);
1403 write_exp_elt_opcode (OP_STRING
);
1408 #line 233 "jv-exp.y"
1409 { write_exp_elt_opcode (OP_LONG
);
1410 write_exp_elt_type (yyvsp
[0].typed_val_int
.type
);
1411 write_exp_elt_longcst ((LONGEST
)(yyvsp
[0].typed_val_int
.val
));
1412 write_exp_elt_opcode (OP_LONG
); }
1416 #line 238 "jv-exp.y"
1418 parse_number (yyvsp
[0].sval
.ptr
, yyvsp
[0].sval
.length
, 0, &val
);
1419 write_exp_elt_opcode (OP_LONG
);
1420 write_exp_elt_type (val
.typed_val_int
.type
);
1421 write_exp_elt_longcst ((LONGEST
)val
.typed_val_int
.val
);
1422 write_exp_elt_opcode (OP_LONG
);
1427 #line 246 "jv-exp.y"
1428 { write_exp_elt_opcode (OP_DOUBLE
);
1429 write_exp_elt_type (yyvsp
[0].typed_val_float
.type
);
1430 write_exp_elt_dblcst (yyvsp
[0].typed_val_float
.dval
);
1431 write_exp_elt_opcode (OP_DOUBLE
); }
1435 #line 251 "jv-exp.y"
1436 { write_exp_elt_opcode (OP_LONG
);
1437 write_exp_elt_type (java_boolean_type
);
1438 write_exp_elt_longcst ((LONGEST
)yyvsp
[0].lval
);
1439 write_exp_elt_opcode (OP_LONG
); }
1443 #line 268 "jv-exp.y"
1444 { yyval
.tval
= java_boolean_type
; }
1448 #line 278 "jv-exp.y"
1449 { yyval
.tval
= java_byte_type
; }
1453 #line 280 "jv-exp.y"
1454 { yyval
.tval
= java_short_type
; }
1458 #line 282 "jv-exp.y"
1459 { yyval
.tval
= java_int_type
; }
1463 #line 284 "jv-exp.y"
1464 { yyval
.tval
= java_long_type
; }
1468 #line 286 "jv-exp.y"
1469 { yyval
.tval
= java_char_type
; }
1473 #line 291 "jv-exp.y"
1474 { yyval
.tval
= java_float_type
; }
1478 #line 293 "jv-exp.y"
1479 { yyval
.tval
= java_double_type
; }
1483 #line 305 "jv-exp.y"
1484 { yyval
.tval
= java_type_from_name (yyvsp
[0].sval
); }
1488 #line 314 "jv-exp.y"
1489 { yyval
.tval
= java_array_type (yyvsp
[-1].tval
, yyvsp
[0].lval
); }
1493 #line 316 "jv-exp.y"
1494 { yyval
.tval
= java_array_type (java_type_from_name (yyvsp
[-1].sval
), yyvsp
[0].lval
); }
1498 #line 336 "jv-exp.y"
1499 { yyval
.sval
.length
= yyvsp
[-2].sval
.length
+ yyvsp
[0].sval
.length
+ 1;
1500 if (yyvsp
[-2].sval
.ptr
+ yyvsp
[-2].sval
.length
+ 1 == yyvsp
[0].sval
.ptr
1501 && yyvsp
[-2].sval
.ptr
[yyvsp
[-2].sval
.length
] == '.')
1502 yyval
.sval
.ptr
= yyvsp
[-2].sval
.ptr
; /* Optimization. */
1505 yyval
.sval
.ptr
= (char *) xmalloc (yyval
.sval
.length
+ 1);
1506 make_cleanup (free
, yyval
.sval
.ptr
);
1507 sprintf (yyval
.sval
.ptr
, "%.*s.%.*s",
1508 yyvsp
[-2].sval
.length
, yyvsp
[-2].sval
.ptr
, yyvsp
[0].sval
.length
, yyvsp
[0].sval
.ptr
);
1513 #line 360 "jv-exp.y"
1514 { write_exp_elt_opcode (BINOP_COMMA
); }
1518 #line 376 "jv-exp.y"
1519 { write_exp_elt_opcode (OP_ARRAY
);
1520 write_exp_elt_longcst ((LONGEST
) 0);
1521 write_exp_elt_longcst ((LONGEST
) yyvsp
[0].lval
);
1522 write_exp_elt_opcode (OP_ARRAY
); }
1526 #line 384 "jv-exp.y"
1527 { start_arglist (); }
1531 #line 389 "jv-exp.y"
1532 { yyval
.lval
= end_arglist () - 1; }
1536 #line 394 "jv-exp.y"
1537 { internal_error (__FILE__
, __LINE__
,
1538 _("FIXME - ClassInstanceCreationExpression")); }
1542 #line 400 "jv-exp.y"
1543 { arglist_len
= 1; }
1547 #line 402 "jv-exp.y"
1552 #line 407 "jv-exp.y"
1553 { arglist_len
= 0; }
1557 #line 413 "jv-exp.y"
1558 { internal_error (__FILE__
, __LINE__
,
1559 _("FIXME - ArrayCreationExpression")); }
1563 #line 416 "jv-exp.y"
1564 { internal_error (__FILE__
, __LINE__
,
1565 _("FIXME - ArrayCreationExpression")); }
1569 #line 431 "jv-exp.y"
1574 #line 433 "jv-exp.y"
1575 { yyval
.lval
= yyvsp
[-2].lval
+ 1; }
1579 #line 439 "jv-exp.y"
1584 #line 444 "jv-exp.y"
1585 { push_fieldnames (yyvsp
[0].sval
); }
1589 #line 446 "jv-exp.y"
1590 { push_fieldnames (yyvsp
[0].sval
); }
1594 #line 452 "jv-exp.y"
1595 { push_expression_name (yyvsp
[-1].sval
); }
1599 #line 457 "jv-exp.y"
1600 { start_arglist(); }
1604 #line 459 "jv-exp.y"
1605 { write_exp_elt_opcode (OP_FUNCALL
);
1606 write_exp_elt_longcst ((LONGEST
) end_arglist ());
1607 write_exp_elt_opcode (OP_FUNCALL
); }
1611 #line 463 "jv-exp.y"
1612 { error (_("Form of method invocation not implemented")); }
1616 #line 465 "jv-exp.y"
1617 { error (_("Form of method invocation not implemented")); }
1621 #line 470 "jv-exp.y"
1623 /* Emit code for the Name now, then exchange it in the
1624 expout array with the Expression's code. We could
1625 introduce a OP_SWAP code or a reversed version of
1626 BINOP_SUBSCRIPT, but that makes the rest of GDB pay
1627 for our parsing kludges. */
1628 struct expression
*name_expr
;
1630 push_expression_name (yyvsp
[-3].sval
);
1631 name_expr
= copy_exp (expout
, expout_ptr
);
1632 expout_ptr
-= name_expr
->nelts
;
1633 insert_exp (expout_ptr
-length_of_subexp (expout
, expout_ptr
),
1636 write_exp_elt_opcode (BINOP_SUBSCRIPT
);
1641 #line 487 "jv-exp.y"
1642 { write_exp_elt_opcode (BINOP_SUBSCRIPT
); }
1646 #line 489 "jv-exp.y"
1647 { write_exp_elt_opcode (BINOP_SUBSCRIPT
); }
1651 #line 495 "jv-exp.y"
1652 { push_expression_name (yyvsp
[0].sval
); }
1656 #line 504 "jv-exp.y"
1657 { write_exp_elt_opcode (UNOP_POSTINCREMENT
); }
1661 #line 509 "jv-exp.y"
1662 { write_exp_elt_opcode (UNOP_POSTDECREMENT
); }
1666 #line 517 "jv-exp.y"
1667 { write_exp_elt_opcode (UNOP_NEG
); }
1671 #line 519 "jv-exp.y"
1672 { write_exp_elt_opcode (UNOP_IND
); }
1676 #line 525 "jv-exp.y"
1677 { write_exp_elt_opcode (UNOP_PREINCREMENT
); }
1681 #line 530 "jv-exp.y"
1682 { write_exp_elt_opcode (UNOP_PREDECREMENT
); }
1686 #line 536 "jv-exp.y"
1687 { write_exp_elt_opcode (UNOP_COMPLEMENT
); }
1691 #line 538 "jv-exp.y"
1692 { write_exp_elt_opcode (UNOP_LOGICAL_NOT
); }
1696 #line 544 "jv-exp.y"
1697 { write_exp_elt_opcode (UNOP_CAST
);
1698 write_exp_elt_type (java_array_type (yyvsp
[-3].tval
, yyvsp
[-2].lval
));
1699 write_exp_elt_opcode (UNOP_CAST
); }
1703 #line 548 "jv-exp.y"
1705 int exp_size
= expout_ptr
;
1706 int last_exp_size
= length_of_subexp(expout
, expout_ptr
);
1709 int base
= expout_ptr
- last_exp_size
- 3;
1710 if (base
< 0 || expout
->elts
[base
+2].opcode
!= OP_TYPE
)
1711 error (_("Invalid cast expression"));
1712 type
= expout
->elts
[base
+1].type
;
1713 /* Remove the 'Expression' and slide the
1714 UnaryExpressionNotPlusMinus down to replace it. */
1715 for (i
= 0; i
< last_exp_size
; i
++)
1716 expout
->elts
[base
+ i
] = expout
->elts
[base
+ i
+ 3];
1718 if (TYPE_CODE (type
) == TYPE_CODE_STRUCT
)
1719 type
= lookup_pointer_type (type
);
1720 write_exp_elt_opcode (UNOP_CAST
);
1721 write_exp_elt_type (type
);
1722 write_exp_elt_opcode (UNOP_CAST
);
1727 #line 569 "jv-exp.y"
1728 { write_exp_elt_opcode (UNOP_CAST
);
1729 write_exp_elt_type (java_array_type (java_type_from_name (yyvsp
[-3].sval
), yyvsp
[-2].lval
));
1730 write_exp_elt_opcode (UNOP_CAST
); }
1734 #line 578 "jv-exp.y"
1735 { write_exp_elt_opcode (BINOP_MUL
); }
1739 #line 580 "jv-exp.y"
1740 { write_exp_elt_opcode (BINOP_DIV
); }
1744 #line 582 "jv-exp.y"
1745 { write_exp_elt_opcode (BINOP_REM
); }
1749 #line 588 "jv-exp.y"
1750 { write_exp_elt_opcode (BINOP_ADD
); }
1754 #line 590 "jv-exp.y"
1755 { write_exp_elt_opcode (BINOP_SUB
); }
1759 #line 596 "jv-exp.y"
1760 { write_exp_elt_opcode (BINOP_LSH
); }
1764 #line 598 "jv-exp.y"
1765 { write_exp_elt_opcode (BINOP_RSH
); }
1769 #line 605 "jv-exp.y"
1770 { write_exp_elt_opcode (BINOP_LESS
); }
1774 #line 607 "jv-exp.y"
1775 { write_exp_elt_opcode (BINOP_GTR
); }
1779 #line 609 "jv-exp.y"
1780 { write_exp_elt_opcode (BINOP_LEQ
); }
1784 #line 611 "jv-exp.y"
1785 { write_exp_elt_opcode (BINOP_GEQ
); }
1789 #line 618 "jv-exp.y"
1790 { write_exp_elt_opcode (BINOP_EQUAL
); }
1794 #line 620 "jv-exp.y"
1795 { write_exp_elt_opcode (BINOP_NOTEQUAL
); }
1799 #line 626 "jv-exp.y"
1800 { write_exp_elt_opcode (BINOP_BITWISE_AND
); }
1804 #line 632 "jv-exp.y"
1805 { write_exp_elt_opcode (BINOP_BITWISE_XOR
); }
1809 #line 637 "jv-exp.y"
1810 { write_exp_elt_opcode (BINOP_BITWISE_IOR
); }
1814 #line 643 "jv-exp.y"
1815 { write_exp_elt_opcode (BINOP_LOGICAL_AND
); }
1819 #line 649 "jv-exp.y"
1820 { write_exp_elt_opcode (BINOP_LOGICAL_OR
); }
1824 #line 655 "jv-exp.y"
1825 { write_exp_elt_opcode (TERNOP_COND
); }
1829 #line 665 "jv-exp.y"
1830 { write_exp_elt_opcode (BINOP_ASSIGN
); }
1834 #line 667 "jv-exp.y"
1835 { write_exp_elt_opcode (BINOP_ASSIGN_MODIFY
);
1836 write_exp_elt_opcode (yyvsp
[-1].opcode
);
1837 write_exp_elt_opcode (BINOP_ASSIGN_MODIFY
); }
1841 #line 674 "jv-exp.y"
1842 { push_expression_name (yyvsp
[0].sval
); }
1848 /* Line 1000 of yacc.c. */
1849 #line 1850 "jv-exp.c.tmp"
1855 YY_STACK_PRINT (yyss
, yyssp
);
1860 /* Now `shift' the result of the reduction. Determine what state
1861 that goes to, based on the state we popped back to and the rule
1862 number reduced by. */
1866 yystate
= yypgoto
[yyn
- YYNTOKENS
] + *yyssp
;
1867 if (0 <= yystate
&& yystate
<= YYLAST
&& yycheck
[yystate
] == *yyssp
)
1868 yystate
= yytable
[yystate
];
1870 yystate
= yydefgoto
[yyn
- YYNTOKENS
];
1875 /*------------------------------------.
1876 | yyerrlab -- here on detecting error |
1877 `------------------------------------*/
1879 /* If not already recovering from an error, report this error. */
1884 yyn
= yypact
[yystate
];
1886 if (YYPACT_NINF
< yyn
&& yyn
< YYLAST
)
1888 YYSIZE_T yysize
= 0;
1889 int yytype
= YYTRANSLATE (yychar
);
1890 const char* yyprefix
;
1894 /* Start YYX at -YYN if negative to avoid negative indexes in
1896 int yyxbegin
= yyn
< 0 ? -yyn
: 0;
1898 /* Stay within bounds of both yycheck and yytname. */
1899 int yychecklim
= YYLAST
- yyn
;
1900 int yyxend
= yychecklim
< YYNTOKENS
? yychecklim
: YYNTOKENS
;
1903 yyprefix
= ", expecting ";
1904 for (yyx
= yyxbegin
; yyx
< yyxend
; ++yyx
)
1905 if (yycheck
[yyx
+ yyn
] == yyx
&& yyx
!= YYTERROR
)
1907 yysize
+= yystrlen (yyprefix
) + yystrlen (yytname
[yyx
]);
1915 yysize
+= (sizeof ("syntax error, unexpected ")
1916 + yystrlen (yytname
[yytype
]));
1917 yymsg
= (char *) YYSTACK_ALLOC (yysize
);
1920 char *yyp
= yystpcpy (yymsg
, "syntax error, unexpected ");
1921 yyp
= yystpcpy (yyp
, yytname
[yytype
]);
1925 yyprefix
= ", expecting ";
1926 for (yyx
= yyxbegin
; yyx
< yyxend
; ++yyx
)
1927 if (yycheck
[yyx
+ yyn
] == yyx
&& yyx
!= YYTERROR
)
1929 yyp
= yystpcpy (yyp
, yyprefix
);
1930 yyp
= yystpcpy (yyp
, yytname
[yyx
]);
1935 YYSTACK_FREE (yymsg
);
1938 yyerror ("syntax error; also virtual memory exhausted");
1941 #endif /* YYERROR_VERBOSE */
1942 yyerror ("syntax error");
1947 if (yyerrstatus
== 3)
1949 /* If just tried and failed to reuse lookahead token after an
1950 error, discard it. */
1952 if (yychar
<= YYEOF
)
1954 /* If at end of input, pop the error token,
1955 then the rest of the stack, then return failure. */
1956 if (yychar
== YYEOF
)
1962 YYDSYMPRINTF ("Error: popping", yystos
[*yyssp
], yyvsp
, yylsp
);
1963 yydestruct (yystos
[*yyssp
], yyvsp
);
1968 YYDSYMPRINTF ("Error: discarding", yytoken
, &yylval
, &yylloc
);
1969 yydestruct (yytoken
, &yylval
);
1975 /* Else will try to reuse lookahead token after shifting the error
1980 /*---------------------------------------------------.
1981 | yyerrorlab -- error raised explicitly by YYERROR. |
1982 `---------------------------------------------------*/
1986 /* Pacify GCC when the user code never invokes YYERROR and the label
1987 yyerrorlab therefore never appears in user code. */
1998 /*-------------------------------------------------------------.
1999 | yyerrlab1 -- common code for both syntax error and YYERROR. |
2000 `-------------------------------------------------------------*/
2002 yyerrstatus
= 3; /* Each real token shifted decrements this. */
2006 yyn
= yypact
[yystate
];
2007 if (yyn
!= YYPACT_NINF
)
2010 if (0 <= yyn
&& yyn
<= YYLAST
&& yycheck
[yyn
] == YYTERROR
)
2018 /* Pop the current state because it cannot handle the error token. */
2022 YYDSYMPRINTF ("Error: popping", yystos
[*yyssp
], yyvsp
, yylsp
);
2023 yydestruct (yystos
[yystate
], yyvsp
);
2026 YY_STACK_PRINT (yyss
, yyssp
);
2032 YYDPRINTF ((stderr
, "Shifting error token, "));
2041 /*-------------------------------------.
2042 | yyacceptlab -- YYACCEPT comes here. |
2043 `-------------------------------------*/
2048 /*-----------------------------------.
2049 | yyabortlab -- YYABORT comes here. |
2050 `-----------------------------------*/
2056 /*----------------------------------------------.
2057 | yyoverflowlab -- parser overflow comes here. |
2058 `----------------------------------------------*/
2060 yyerror ("parser stack overflow");
2068 YYSTACK_FREE (yyss
);
2074 #line 686 "jv-exp.y"
2076 /* Take care of parsing a number (anything that starts with a digit).
2077 Set yylval and return the token type; update lexptr.
2078 LEN is the number of characters in it. */
2080 /*** Needs some error checking for the float case ***/
2083 parse_number (p
, len
, parsed_float
, putithere
)
2090 ULONGEST limit
, limit_div_base
;
2093 int base
= input_radix
;
2099 /* It's a float since it contains a point or an exponent. */
2101 int num
= 0; /* number of tokens scanned by scanf */
2102 char saved_char
= p
[len
];
2104 p
[len
] = 0; /* null-terminate the token */
2105 num
= sscanf (p
, DOUBLEST_SCAN_FORMAT
"%c",
2106 &putithere
->typed_val_float
.dval
, &c
);
2107 p
[len
] = saved_char
; /* restore the input stream */
2108 if (num
!= 1) /* check scanf found ONLY a float ... */
2110 /* See if it has `f' or `d' suffix (float or double). */
2112 c
= tolower (p
[len
- 1]);
2114 if (c
== 'f' || c
== 'F')
2115 putithere
->typed_val_float
.type
= builtin_type_float
;
2116 else if (isdigit (c
) || c
== '.' || c
== 'd' || c
== 'D')
2117 putithere
->typed_val_float
.type
= builtin_type_double
;
2121 return FLOATING_POINT_LITERAL
;
2124 /* Handle base-switching prefixes 0x, 0t, 0d, 0 */
2156 /* A paranoid calculation of (1<<64)-1. */
2157 limit
= (ULONGEST
)0xffffffff;
2158 limit
= ((limit
<< 16) << 16) | limit
;
2159 if (c
== 'l' || c
== 'L')
2161 type
= java_long_type
;
2166 type
= java_int_type
;
2168 limit_div_base
= limit
/ (ULONGEST
) base
;
2173 if (c
>= '0' && c
<= '9')
2175 else if (c
>= 'A' && c
<= 'Z')
2177 else if (c
>= 'a' && c
<= 'z')
2180 return ERROR
; /* Char not a digit */
2183 if (n
> limit_div_base
2184 || (n
*= base
) > limit
- c
)
2185 error (_("Numeric constant too large"));
2189 /* If the type is bigger than a 32-bit signed integer can be, implicitly
2190 promote to long. Java does not do this, so mark it as builtin_type_uint64
2191 rather than java_long_type. 0x80000000 will become -0x80000000 instead
2192 of 0x80000000L, because we don't know the sign at this point.
2194 if (type
== java_int_type
&& n
> (ULONGEST
)0x80000000)
2195 type
= builtin_type_uint64
;
2197 putithere
->typed_val_int
.val
= n
;
2198 putithere
->typed_val_int
.type
= type
;
2200 return INTEGER_LITERAL
;
2207 enum exp_opcode opcode
;
2210 static const struct token tokentab3
[] =
2212 {">>=", ASSIGN_MODIFY
, BINOP_RSH
},
2213 {"<<=", ASSIGN_MODIFY
, BINOP_LSH
}
2216 static const struct token tokentab2
[] =
2218 {"+=", ASSIGN_MODIFY
, BINOP_ADD
},
2219 {"-=", ASSIGN_MODIFY
, BINOP_SUB
},
2220 {"*=", ASSIGN_MODIFY
, BINOP_MUL
},
2221 {"/=", ASSIGN_MODIFY
, BINOP_DIV
},
2222 {"%=", ASSIGN_MODIFY
, BINOP_REM
},
2223 {"|=", ASSIGN_MODIFY
, BINOP_BITWISE_IOR
},
2224 {"&=", ASSIGN_MODIFY
, BINOP_BITWISE_AND
},
2225 {"^=", ASSIGN_MODIFY
, BINOP_BITWISE_XOR
},
2226 {"++", INCREMENT
, BINOP_END
},
2227 {"--", DECREMENT
, BINOP_END
},
2228 {"&&", ANDAND
, BINOP_END
},
2229 {"||", OROR
, BINOP_END
},
2230 {"<<", LSH
, BINOP_END
},
2231 {">>", RSH
, BINOP_END
},
2232 {"==", EQUAL
, BINOP_END
},
2233 {"!=", NOTEQUAL
, BINOP_END
},
2234 {"<=", LEQ
, BINOP_END
},
2235 {">=", GEQ
, BINOP_END
}
2238 /* Read one token, getting characters through lexptr. */
2249 static char *tempbuf
;
2250 static int tempbufsize
;
2254 prev_lexptr
= lexptr
;
2257 /* See if it is a special token of length 3. */
2258 for (i
= 0; i
< sizeof tokentab3
/ sizeof tokentab3
[0]; i
++)
2259 if (strncmp (tokstart
, tokentab3
[i
].operator, 3) == 0)
2262 yylval
.opcode
= tokentab3
[i
].opcode
;
2263 return tokentab3
[i
].token
;
2266 /* See if it is a special token of length 2. */
2267 for (i
= 0; i
< sizeof tokentab2
/ sizeof tokentab2
[0]; i
++)
2268 if (strncmp (tokstart
, tokentab2
[i
].operator, 2) == 0)
2271 yylval
.opcode
= tokentab2
[i
].opcode
;
2272 return tokentab2
[i
].token
;
2275 switch (c
= *tokstart
)
2287 /* We either have a character constant ('0' or '\177' for example)
2288 or we have a quoted symbol reference ('foo(int,int)' in C++
2293 c
= parse_escape (&lexptr
);
2295 error (_("Empty character constant"));
2297 yylval
.typed_val_int
.val
= c
;
2298 yylval
.typed_val_int
.type
= java_char_type
;
2303 namelen
= skip_quoted (tokstart
) - tokstart
;
2306 lexptr
= tokstart
+ namelen
;
2307 if (lexptr
[-1] != '\'')
2308 error (_("Unmatched single quote"));
2313 error (_("Invalid character constant"));
2315 return INTEGER_LITERAL
;
2323 if (paren_depth
== 0)
2330 if (comma_terminates
&& paren_depth
== 0)
2336 /* Might be a floating point number. */
2337 if (lexptr
[1] < '0' || lexptr
[1] > '9')
2338 goto symbol
; /* Nope, must be a symbol. */
2339 /* FALL THRU into number case. */
2352 /* It's a number. */
2353 int got_dot
= 0, got_e
= 0, toktype
;
2355 int hex
= input_radix
> 10;
2357 if (c
== '0' && (p
[1] == 'x' || p
[1] == 'X'))
2362 else if (c
== '0' && (p
[1]=='t' || p
[1]=='T' || p
[1]=='d' || p
[1]=='D'))
2370 /* This test includes !hex because 'e' is a valid hex digit
2371 and thus does not indicate a floating point number when
2372 the radix is hex. */
2373 if (!hex
&& !got_e
&& (*p
== 'e' || *p
== 'E'))
2374 got_dot
= got_e
= 1;
2375 /* This test does not include !hex, because a '.' always indicates
2376 a decimal floating point number regardless of the radix. */
2377 else if (!got_dot
&& *p
== '.')
2379 else if (got_e
&& (p
[-1] == 'e' || p
[-1] == 'E')
2380 && (*p
== '-' || *p
== '+'))
2381 /* This is the sign of the exponent, not the end of the
2384 /* We will take any letters or digits. parse_number will
2385 complain if past the radix, or if L or U are not final. */
2386 else if ((*p
< '0' || *p
> '9')
2387 && ((*p
< 'a' || *p
> 'z')
2388 && (*p
< 'A' || *p
> 'Z')))
2391 toktype
= parse_number (tokstart
, p
- tokstart
, got_dot
|got_e
, &yylval
);
2392 if (toktype
== ERROR
)
2394 char *err_copy
= (char *) alloca (p
- tokstart
+ 1);
2396 memcpy (err_copy
, tokstart
, p
- tokstart
);
2397 err_copy
[p
- tokstart
] = 0;
2398 error (_("Invalid number \"%s\""), err_copy
);
2429 /* Build the gdb internal form of the input string in tempbuf,
2430 translating any standard C escape forms seen. Note that the
2431 buffer is null byte terminated *only* for the convenience of
2432 debugging gdb itself and printing the buffer contents when
2433 the buffer contains no embedded nulls. Gdb does not depend
2434 upon the buffer being null byte terminated, it uses the length
2435 string instead. This allows gdb to handle C strings (as well
2436 as strings in other languages) with embedded null bytes */
2438 tokptr
= ++tokstart
;
2442 /* Grow the static temp buffer if necessary, including allocating
2443 the first one on demand. */
2444 if (tempbufindex
+ 1 >= tempbufsize
)
2446 tempbuf
= (char *) xrealloc (tempbuf
, tempbufsize
+= 64);
2452 /* Do nothing, loop will terminate. */
2456 c
= parse_escape (&tokptr
);
2461 tempbuf
[tempbufindex
++] = c
;
2464 tempbuf
[tempbufindex
++] = *tokptr
++;
2467 } while ((*tokptr
!= '"') && (*tokptr
!= '\0'));
2468 if (*tokptr
++ != '"')
2470 error (_("Unterminated string in expression"));
2472 tempbuf
[tempbufindex
] = '\0'; /* See note above */
2473 yylval
.sval
.ptr
= tempbuf
;
2474 yylval
.sval
.length
= tempbufindex
;
2476 return (STRING_LITERAL
);
2479 if (!(c
== '_' || c
== '$'
2480 || (c
>= 'a' && c
<= 'z') || (c
>= 'A' && c
<= 'Z')))
2481 /* We must have come across a bad character (e.g. ';'). */
2482 error (_("Invalid character '%c' in expression"), c
);
2484 /* It's a name. See how long it is. */
2486 for (c
= tokstart
[namelen
];
2489 || (c
>= '0' && c
<= '9')
2490 || (c
>= 'a' && c
<= 'z')
2491 || (c
>= 'A' && c
<= 'Z')
2498 while (tokstart
[++i
] && tokstart
[i
] != '>');
2499 if (tokstart
[i
] == '>')
2502 c
= tokstart
[++namelen
];
2505 /* The token "if" terminates the expression and is NOT
2506 removed from the input stream. */
2507 if (namelen
== 2 && tokstart
[0] == 'i' && tokstart
[1] == 'f')
2516 /* Catch specific keywords. Should be done with a data structure. */
2520 if (DEPRECATED_STREQN (tokstart
, "boolean", 7))
2524 if (DEPRECATED_STREQN (tokstart
, "double", 6))
2528 if (DEPRECATED_STREQN (tokstart
, "short", 5))
2530 if (DEPRECATED_STREQN (tokstart
, "false", 5))
2533 return BOOLEAN_LITERAL
;
2535 if (DEPRECATED_STREQN (tokstart
, "super", 5))
2537 if (DEPRECATED_STREQN (tokstart
, "float", 5))
2541 if (DEPRECATED_STREQN (tokstart
, "long", 4))
2543 if (DEPRECATED_STREQN (tokstart
, "byte", 4))
2545 if (DEPRECATED_STREQN (tokstart
, "char", 4))
2547 if (DEPRECATED_STREQN (tokstart
, "true", 4))
2550 return BOOLEAN_LITERAL
;
2554 if (strncmp (tokstart
, "int", 3) == 0)
2556 if (strncmp (tokstart
, "new", 3) == 0)
2563 yylval
.sval
.ptr
= tokstart
;
2564 yylval
.sval
.length
= namelen
;
2566 if (*tokstart
== '$')
2568 write_dollar_variable (yylval
.sval
);
2572 /* Input names that aren't symbols but ARE valid hex numbers,
2573 when the input radix permits them, can be names or numbers
2574 depending on the parse. Note we support radixes > 16 here. */
2575 if (((tokstart
[0] >= 'a' && tokstart
[0] < 'a' + input_radix
- 10) ||
2576 (tokstart
[0] >= 'A' && tokstart
[0] < 'A' + input_radix
- 10)))
2578 YYSTYPE newlval
; /* Its value is ignored. */
2579 int hextype
= parse_number (tokstart
, namelen
, 0, &newlval
);
2580 if (hextype
== INTEGER_LITERAL
)
2591 lexptr
= prev_lexptr
;
2594 error (_("%s: near `%s'"), msg
, lexptr
);
2596 error (_("error in expression, near `%s'"), lexptr
);
2599 static struct type
*
2600 java_type_from_name (name
)
2604 char *tmp
= copy_name (name
);
2605 struct type
*typ
= java_lookup_class (tmp
);
2606 if (typ
== NULL
|| TYPE_CODE (typ
) != TYPE_CODE_STRUCT
)
2607 error (_("No class named `%s'"), tmp
);
2611 /* If NAME is a valid variable name in this scope, push it and return 1.
2612 Otherwise, return 0. */
2615 push_variable (struct stoken name
)
2617 char *tmp
= copy_name (name
);
2618 int is_a_field_of_this
= 0;
2620 sym
= lookup_symbol (tmp
, expression_context_block
, VAR_DOMAIN
,
2621 &is_a_field_of_this
, (struct symtab
**) NULL
);
2622 if (sym
&& SYMBOL_CLASS (sym
) != LOC_TYPEDEF
)
2624 if (symbol_read_needs_frame (sym
))
2626 if (innermost_block
== 0 ||
2627 contained_in (block_found
, innermost_block
))
2628 innermost_block
= block_found
;
2631 write_exp_elt_opcode (OP_VAR_VALUE
);
2632 /* We want to use the selected frame, not another more inner frame
2633 which happens to be in the same block. */
2634 write_exp_elt_block (NULL
);
2635 write_exp_elt_sym (sym
);
2636 write_exp_elt_opcode (OP_VAR_VALUE
);
2639 if (is_a_field_of_this
)
2641 /* it hangs off of `this'. Must not inadvertently convert from a
2642 method call to data ref. */
2643 if (innermost_block
== 0 ||
2644 contained_in (block_found
, innermost_block
))
2645 innermost_block
= block_found
;
2646 write_exp_elt_opcode (OP_THIS
);
2647 write_exp_elt_opcode (OP_THIS
);
2648 write_exp_elt_opcode (STRUCTOP_PTR
);
2649 write_exp_string (name
);
2650 write_exp_elt_opcode (STRUCTOP_PTR
);
2656 /* Assuming a reference expression has been pushed, emit the
2657 STRUCTOP_STRUCT ops to access the field named NAME. If NAME is a
2658 qualified name (has '.'), generate a field access for each part. */
2661 push_fieldnames (name
)
2665 struct stoken token
;
2666 token
.ptr
= name
.ptr
;
2669 if (i
== name
.length
|| name
.ptr
[i
] == '.')
2671 /* token.ptr is start of current field name. */
2672 token
.length
= &name
.ptr
[i
] - token
.ptr
;
2673 write_exp_elt_opcode (STRUCTOP_STRUCT
);
2674 write_exp_string (token
);
2675 write_exp_elt_opcode (STRUCTOP_STRUCT
);
2676 token
.ptr
+= token
.length
+ 1;
2678 if (i
>= name
.length
)
2683 /* Helper routine for push_expression_name.
2684 Handle a qualified name, where DOT_INDEX is the index of the first '.' */
2687 push_qualified_expression_name (struct stoken name
, int dot_index
)
2689 struct stoken token
;
2693 token
.ptr
= name
.ptr
;
2694 token
.length
= dot_index
;
2696 if (push_variable (token
))
2698 token
.ptr
= name
.ptr
+ dot_index
+ 1;
2699 token
.length
= name
.length
- dot_index
- 1;
2700 push_fieldnames (token
);
2704 token
.ptr
= name
.ptr
;
2707 token
.length
= dot_index
;
2708 tmp
= copy_name (token
);
2709 typ
= java_lookup_class (tmp
);
2712 if (dot_index
== name
.length
)
2714 write_exp_elt_opcode(OP_TYPE
);
2715 write_exp_elt_type(typ
);
2716 write_exp_elt_opcode(OP_TYPE
);
2719 dot_index
++; /* Skip '.' */
2720 name
.ptr
+= dot_index
;
2721 name
.length
-= dot_index
;
2723 while (dot_index
< name
.length
&& name
.ptr
[dot_index
] != '.')
2725 token
.ptr
= name
.ptr
;
2726 token
.length
= dot_index
;
2727 write_exp_elt_opcode (OP_SCOPE
);
2728 write_exp_elt_type (typ
);
2729 write_exp_string (token
);
2730 write_exp_elt_opcode (OP_SCOPE
);
2731 if (dot_index
< name
.length
)
2734 name
.ptr
+= dot_index
;
2735 name
.length
-= dot_index
;
2736 push_fieldnames (name
);
2740 else if (dot_index
>= name
.length
)
2742 dot_index
++; /* Skip '.' */
2743 while (dot_index
< name
.length
&& name
.ptr
[dot_index
] != '.')
2746 error (_("unknown type `%.*s'"), name
.length
, name
.ptr
);
2749 /* Handle Name in an expression (or LHS).
2750 Handle VAR, TYPE, TYPE.FIELD1....FIELDN and VAR.FIELD1....FIELDN. */
2753 push_expression_name (name
)
2761 for (i
= 0; i
< name
.length
; i
++)
2763 if (name
.ptr
[i
] == '.')
2765 /* It's a Qualified Expression Name. */
2766 push_qualified_expression_name (name
, i
);
2771 /* It's a Simple Expression Name. */
2773 if (push_variable (name
))
2775 tmp
= copy_name (name
);
2776 typ
= java_lookup_class (tmp
);
2779 write_exp_elt_opcode(OP_TYPE
);
2780 write_exp_elt_type(typ
);
2781 write_exp_elt_opcode(OP_TYPE
);
2785 struct minimal_symbol
*msymbol
;
2787 msymbol
= lookup_minimal_symbol (tmp
, NULL
, NULL
);
2788 if (msymbol
!= NULL
)
2790 write_exp_msymbol (msymbol
,
2791 lookup_function_type (builtin_type_int
),
2794 else if (!have_full_symbols () && !have_partial_symbols ())
2795 error (_("No symbol table is loaded. Use the \"file\" command"));
2797 error (_("No symbol \"%s\" in current context"), tmp
);
2803 /* The following two routines, copy_exp and insert_exp, aren't specific to
2804 Java, so they could go in parse.c, but their only purpose is to support
2805 the parsing kludges we use in this file, so maybe it's best to isolate
2808 /* Copy the expression whose last element is at index ENDPOS - 1 in EXPR
2809 into a freshly xmalloc'ed struct expression. Its language_defn is set
2811 static struct expression
*
2812 copy_exp (expr
, endpos
)
2813 struct expression
*expr
;
2816 int len
= length_of_subexp (expr
, endpos
);
2817 struct expression
*new
2818 = (struct expression
*) xmalloc (sizeof (*new) + EXP_ELEM_TO_BYTES (len
));
2820 memcpy (new->elts
, expr
->elts
+ endpos
- len
, EXP_ELEM_TO_BYTES (len
));
2821 new->language_defn
= 0;
2826 /* Insert the expression NEW into the current expression (expout) at POS. */
2828 insert_exp (pos
, new)
2830 struct expression
*new;
2832 int newlen
= new->nelts
;
2834 /* Grow expout if necessary. In this function's only use at present,
2835 this should never be necessary. */
2836 if (expout_ptr
+ newlen
> expout_size
)
2838 expout_size
= max (expout_size
* 2, expout_ptr
+ newlen
+ 10);
2839 expout
= (struct expression
*)
2840 xrealloc ((char *) expout
, (sizeof (struct expression
)
2841 + EXP_ELEM_TO_BYTES (expout_size
)));
2847 for (i
= expout_ptr
- 1; i
>= pos
; i
--)
2848 expout
->elts
[i
+ newlen
] = expout
->elts
[i
];
2851 memcpy (expout
->elts
+ pos
, new->elts
, EXP_ELEM_TO_BYTES (newlen
));
2852 expout_ptr
+= newlen
;