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