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