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