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