OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [gnu-src/] [gdb-7.1/] [gdb/] [p-exp.c] - Blame information for rev 634

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.