OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [gdb/] [p-exp.tab.c] - Blame information for rev 1774

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

Line No. Rev Author Line
1 578 markom
 
2
/*  A Bison parser, made from p-exp.y
3
 by  GNU Bison version 1.27
4
  */
5
 
6
#define YYBISON 1  /* Identify Bison output.  */
7
 
8
#define INT     257
9
#define FLOAT   258
10
#define STRING  259
11
#define NAME    260
12
#define TYPENAME        261
13
#define NAME_OR_INT     262
14
#define STRUCT  263
15
#define CLASS   264
16
#define SIZEOF  265
17
#define COLONCOLON      266
18
#define ERROR   267
19
#define VARIABLE        268
20
#define THIS    269
21
#define TRUE    270
22
#define FALSE   271
23
#define ABOVE_COMMA     272
24
#define ASSIGN  273
25
#define NOT     274
26
#define OR      275
27
#define XOR     276
28
#define ANDAND  277
29
#define NOTEQUAL        278
30
#define LEQ     279
31
#define GEQ     280
32
#define LSH     281
33
#define RSH     282
34
#define DIV     283
35
#define MOD     284
36
#define UNARY   285
37
#define INCREMENT       286
38
#define DECREMENT       287
39
#define ARROW   288
40
#define BLOCKNAME       289
41
 
42
#line 47 "p-exp.y"
43
 
44
 
45
#include "defs.h"
46
#include "gdb_string.h"
47
#include <ctype.h>
48
#include "expression.h"
49
#include "value.h"
50
#include "parser-defs.h"
51
#include "language.h"
52
#include "p-lang.h"
53
#include "bfd.h" /* Required by objfiles.h.  */
54
#include "symfile.h" /* Required by objfiles.h.  */
55
#include "objfiles.h" /* For have_full_symbols and have_partial_symbols */
56
 
57
/* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc),
58
   as well as gratuitiously global symbol names, so we can have multiple
59
   yacc generated parsers in gdb.  Note that these are only the variables
60
   produced by yacc.  If other parser generators (bison, byacc, etc) produce
61
   additional global names that conflict at link time, then those parser
62
   generators need to be fixed instead of adding those names to this list. */
63
 
64
#define yymaxdepth pascal_maxdepth
65
#define yyparse pascal_parse
66
#define yylex   pascal_lex
67
#define yyerror pascal_error
68
#define yylval  pascal_lval
69
#define yychar  pascal_char
70
#define yydebug pascal_debug
71
#define yypact  pascal_pact     
72
#define yyr1    pascal_r1                       
73
#define yyr2    pascal_r2                       
74
#define yydef   pascal_def              
75
#define yychk   pascal_chk              
76
#define yypgo   pascal_pgo              
77
#define yyact   pascal_act
78
#define yyexca  pascal_exca
79
#define yyerrflag pascal_errflag
80
#define yynerrs pascal_nerrs
81
#define yyps    pascal_ps
82
#define yypv    pascal_pv
83
#define yys     pascal_s
84
#define yy_yys  pascal_yys
85
#define yystate pascal_state
86
#define yytmp   pascal_tmp
87
#define yyv     pascal_v
88
#define yy_yyv  pascal_yyv
89
#define yyval   pascal_val
90
#define yylloc  pascal_lloc
91
#define yyreds  pascal_reds             /* With YYDEBUG defined */
92
#define yytoks  pascal_toks             /* With YYDEBUG defined */
93
#define yylhs   pascal_yylhs
94
#define yylen   pascal_yylen
95
#define yydefred pascal_yydefred
96
#define yydgoto pascal_yydgoto
97
#define yysindex pascal_yysindex
98
#define yyrindex pascal_yyrindex
99
#define yygindex pascal_yygindex
100
#define yytable  pascal_yytable
101
#define yycheck  pascal_yycheck
102
 
103
#ifndef YYDEBUG
104
#define YYDEBUG 0                /* Default to no yydebug support */
105
#endif
106
 
107
int yyparse (void);
108
 
109
static int yylex (void);
110
 
111
void
112
yyerror (char *);
113
 
114
static char * uptok (char *, int);
115
 
116
#line 125 "p-exp.y"
117
typedef union
118
  {
119
    LONGEST lval;
120
    struct {
121
      LONGEST val;
122
      struct type *type;
123
    } typed_val_int;
124
    struct {
125
      DOUBLEST dval;
126
      struct type *type;
127
    } typed_val_float;
128
    struct symbol *sym;
129
    struct type *tval;
130
    struct stoken sval;
131
    struct ttype tsym;
132
    struct symtoken ssym;
133
    int voidval;
134
    struct block *bval;
135
    enum exp_opcode opcode;
136
    struct internalvar *ivar;
137
 
138
    struct type **tvec;
139
    int *ivec;
140
  } YYSTYPE;
141
#line 150 "p-exp.y"
142
 
143
/* YYSTYPE gets defined by %union */
144
static int
145
parse_number (char *, int, int, YYSTYPE *);
146
#include <stdio.h>
147
 
148
#ifndef __cplusplus
149
#ifndef __STDC__
150
#define const
151
#endif
152
#endif
153
 
154
 
155
 
156
#define YYFINAL         117
157
#define YYFLAG          -32768
158
#define YYNTBASE        51
159
 
160
#define YYTRANSLATE(x) ((unsigned)(x) <= 289 ? yytranslate[x] : 65)
161
 
162
static const char yytranslate[] = {     0,
163
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
164
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
165
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
166
     2,     2,     2,     2,     2,     2,     2,     2,     2,    46,
167
    49,    38,    36,    18,    37,    44,    39,     2,     2,     2,
168
     2,     2,     2,     2,     2,     2,     2,     2,     2,    27,
169
    25,    28,     2,    35,     2,     2,     2,     2,     2,     2,
170
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
171
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
172
    45,     2,    50,    48,     2,     2,     2,     2,     2,     2,
173
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
174
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
175
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
176
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
177
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
178
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
179
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
180
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
181
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
182
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
183
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
184
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
185
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
186
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
187
     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
188
     2,     2,     2,     2,     2,     1,     3,     4,     5,     6,
189
     7,     8,     9,    10,    11,    12,    13,    14,    15,    16,
190
    17,    19,    20,    21,    22,    23,    24,    26,    29,    30,
191
    31,    32,    33,    34,    40,    41,    42,    43,    47
192
};
193
 
194
#if YYDEBUG != 0
195
static const short yyprhs[] = {     0,
196
     0,     2,     4,     6,     8,    12,    15,    18,    21,    24,
197
    29,    34,    38,    43,    44,    50,    51,    53,    57,    62,
198
    66,    70,    74,    78,    82,    86,    90,    94,    98,   102,
199
   106,   110,   114,   118,   122,   126,   130,   134,   138,   140,
200
   142,   144,   146,   148,   150,   152,   157,   159,   161,   163,
201
   167,   171,   175,   177,   180,   182,   184,   186,   190,   192,
202
   195,   198,   200,   202,   204,   206,   208
203
};
204
 
205
static const short yyrhs[] = {    53,
206
     0,    52,     0,    61,     0,    54,     0,    53,    18,    54,
207
     0,    54,    48,     0,    35,    54,     0,    37,    54,     0,
208
    21,    54,     0,    41,    46,    54,    49,     0,    42,    46,
209
    54,    49,     0,    54,    44,    63,     0,    54,    45,    53,
210
    50,     0,     0,    54,    46,    55,    56,    49,     0,     0,
211
    54,     0,    56,    18,    54,     0,    61,    46,    54,    49,
212
     0,    46,    53,    49,     0,    54,    38,    54,     0,    54,
213
    39,    54,     0,    54,    33,    54,     0,    54,    34,    54,
214
     0,    54,    36,    54,     0,    54,    37,    54,     0,    54,
215
    31,    54,     0,    54,    32,    54,     0,    54,    25,    54,
216
     0,    54,    26,    54,     0,    54,    29,    54,     0,    54,
217
    30,    54,     0,    54,    27,    54,     0,    54,    28,    54,
218
     0,    54,    24,    54,     0,    54,    23,    54,     0,    54,
219
    22,    54,     0,    54,    20,    54,     0,    16,     0,    17,
220
     0,     3,     0,     8,     0,     4,     0,    58,     0,    14,
221
     0,    11,    46,    61,    49,     0,     5,     0,    15,     0,
222
    47,     0,    57,    12,    63,     0,    57,    12,    63,     0,
223
    62,    12,    63,     0,    59,     0,    12,    63,     0,    64,
224
     0,    62,     0,    60,     0,    62,    12,    38,     0,     7,
225
     0,     9,    63,     0,    10,    63,     0,     6,     0,    47,
226
     0,     7,     0,     8,     0,     6,     0,    47,     0
227
};
228
 
229
#endif
230
 
231
#if YYDEBUG != 0
232
static const short yyrline[] = { 0,
233
   222,   223,   226,   233,   234,   239,   242,   245,   249,   253,
234
   257,   261,   267,   271,   275,   281,   282,   284,   288,   294,
235
   300,   304,   308,   312,   316,   320,   324,   328,   332,   336,
236
   340,   344,   348,   352,   356,   360,   364,   368,   372,   378,
237
   384,   391,   402,   409,   412,   416,   424,   449,   456,   473,
238
   484,   500,   515,   516,   550,   608,   619,   620,   625,   627,
239
   630,   638,   639,   640,   641,   644,   645
240
};
241
#endif
242
 
243
 
244
#if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
245
 
246
static const char * const yytname[] = {   "$","error","$undefined.","INT","FLOAT",
247
"STRING","NAME","TYPENAME","NAME_OR_INT","STRUCT","CLASS","SIZEOF","COLONCOLON",
248
"ERROR","VARIABLE","THIS","TRUE","FALSE","','","ABOVE_COMMA","ASSIGN","NOT",
249
"OR","XOR","ANDAND","'='","NOTEQUAL","'<'","'>'","LEQ","GEQ","LSH","RSH","DIV",
250
"MOD","'@'","'+'","'-'","'*'","'/'","UNARY","INCREMENT","DECREMENT","ARROW",
251
"'.'","'['","'('","BLOCKNAME","'^'","')'","']'","start","type_exp","exp1","exp",
252
"@1","arglist","block","variable","qualified_name","ptype","type","typebase",
253
"name","name_not_typename", NULL
254
};
255
#endif
256
 
257
static const short yyr1[] = {     0,
258
    51,    51,    52,    53,    53,    54,    54,    54,    54,    54,
259
    54,    54,    54,    55,    54,    56,    56,    56,    54,    54,
260
    54,    54,    54,    54,    54,    54,    54,    54,    54,    54,
261
    54,    54,    54,    54,    54,    54,    54,    54,    54,    54,
262
    54,    54,    54,    54,    54,    54,    54,    54,    57,    57,
263
    58,    59,    58,    58,    58,    60,    61,    61,    62,    62,
264
    62,    63,    63,    63,    63,    64,    64
265
};
266
 
267
static const short yyr2[] = {     0,
268
     1,     1,     1,     1,     3,     2,     2,     2,     2,     4,
269
     4,     3,     4,     0,     5,     0,     1,     3,     4,     3,
270
     3,     3,     3,     3,     3,     3,     3,     3,     3,     3,
271
     3,     3,     3,     3,     3,     3,     3,     3,     1,     1,
272
     1,     1,     1,     1,     1,     4,     1,     1,     1,     3,
273
     3,     3,     1,     2,     1,     1,     1,     3,     1,     2,
274
     2,     1,     1,     1,     1,     1,     1
275
};
276
 
277
static const short yydefact[] = {     0,
278
    41,    43,    47,    66,    59,    42,     0,     0,     0,     0,
279
    45,    48,    39,    40,     0,     0,     0,     0,     0,     0,
280
    67,     2,     1,     4,     0,    44,    53,    57,     3,    56,
281
    55,    62,    64,    65,    63,    60,    61,     0,    54,     9,
282
     0,     7,     8,     0,     0,     0,     0,     0,     0,     0,
283
     0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
284
     0,     0,     0,     0,     0,     0,     0,    14,     6,     0,
285
     0,     0,     0,    56,     0,     0,    20,     5,    38,    37,
286
    36,    35,    29,    30,    33,    34,    31,    32,    27,    28,
287
    23,    24,    25,    26,    21,    22,    12,     0,    16,    51,
288
     0,    58,    52,    46,     0,    10,    11,    13,    17,     0,
289
    19,     0,    15,    18,     0,     0,     0
290
};
291
 
292
static const short yydefgoto[] = {   115,
293
    22,    23,    24,    99,   110,    25,    26,    27,    28,    41,
294
    30,    36,    31
295
};
296
 
297
static const short yypact[] = {    65,
298
-32768,-32768,-32768,-32768,-32768,-32768,     5,     5,   -37,     5,
299
-32768,-32768,-32768,-32768,    65,    65,    65,   -32,   -27,    65,
300
    14,-32768,     2,   183,    19,-32768,-32768,-32768,   -18,    47,
301
-32768,-32768,-32768,-32768,-32768,-32768,-32768,     8,-32768,   -38,
302
   -18,   -38,   -38,    65,    65,     6,    65,    65,    65,    65,
303
    65,    65,    65,    65,    65,    65,    65,    65,    65,    65,
304
    65,    65,    65,    65,    65,     5,    65,-32768,-32768,     5,
305
    65,    15,    11,    51,    93,   123,-32768,   183,   183,   209,
306
   234,   258,   280,   280,   298,   298,   298,   298,   311,   311,
307
   311,   311,    50,    50,   -38,   -38,-32768,     7,    65,    52,
308
   153,-32768,-32768,-32768,    28,-32768,-32768,-32768,   183,     9,
309
-32768,    65,-32768,   183,    78,    83,-32768
310
};
311
 
312
static const short yypgoto[] = {-32768,
313
-32768,   -16,   -15,-32768,-32768,-32768,-32768,-32768,-32768,    16,
314
    49,    -5,-32768
315
};
316
 
317
 
318
#define YYLAST          359
319
 
320
 
321
static const short yytable[] = {    40,
322
    42,    43,    37,    46,    39,    66,    67,    68,    38,    69,
323
    32,    33,    34,    44,     5,    29,     7,     8,    45,    47,
324
    32,    33,    34,    47,    47,   -49,   112,    71,    75,    76,
325
    70,    78,    79,    80,    81,    82,    83,    84,    85,    86,
326
    87,    88,    89,    90,    91,    92,    93,    94,    95,    96,
327
    98,    35,   102,    73,    77,   101,   108,   113,    72,   104,
328
    97,    35,   105,   -50,   100,   102,   103,     1,     2,     3,
329
     4,     5,     6,     7,     8,     9,    10,   116,    11,    12,
330
    13,    14,   117,   109,     0,    15,    74,    64,    65,     0,
331
     0,     0,     0,    66,    67,    68,   114,    69,     0,    16,
332
     0,    17,     0,     0,     0,    18,    19,     0,     0,     0,
333
    20,    21,    48,     0,    49,    50,    51,    52,    53,    54,
334
    55,    56,    57,    58,    59,    60,    61,     0,    62,    63,
335
    64,    65,     0,     0,     0,     0,    66,    67,    68,     0,
336
    69,   106,    48,     0,    49,    50,    51,    52,    53,    54,
337
    55,    56,    57,    58,    59,    60,    61,     0,    62,    63,
338
    64,    65,     0,     0,     0,     0,    66,    67,    68,     0,
339
    69,   107,    48,     0,    49,    50,    51,    52,    53,    54,
340
    55,    56,    57,    58,    59,    60,    61,     0,    62,    63,
341
    64,    65,     0,     0,     0,     0,    66,    67,    68,     0,
342
    69,   111,    48,     0,    49,    50,    51,    52,    53,    54,
343
    55,    56,    57,    58,    59,    60,    61,     0,    62,    63,
344
    64,    65,     0,     0,     0,     0,    66,    67,    68,     0,
345
    69,    50,    51,    52,    53,    54,    55,    56,    57,    58,
346
    59,    60,    61,     0,    62,    63,    64,    65,     0,     0,
347
     0,     0,    66,    67,    68,     0,    69,    51,    52,    53,
348
    54,    55,    56,    57,    58,    59,    60,    61,     0,    62,
349
    63,    64,    65,     0,     0,     0,     0,    66,    67,    68,
350
     0,    69,    52,    53,    54,    55,    56,    57,    58,    59,
351
    60,    61,     0,    62,    63,    64,    65,     0,     0,     0,
352
     0,    66,    67,    68,     0,    69,    54,    55,    56,    57,
353
    58,    59,    60,    61,     0,    62,    63,    64,    65,     0,
354
     0,     0,     0,    66,    67,    68,     0,    69,    58,    59,
355
    60,    61,     0,    62,    63,    64,    65,     0,     0,     0,
356
     0,    66,    67,    68,     0,    69,    62,    63,    64,    65,
357
     0,     0,     0,     0,    66,    67,    68,     0,    69
358
};
359
 
360
static const short yycheck[] = {    15,
361
    16,    17,     8,    20,    10,    44,    45,    46,    46,    48,
362
     6,     7,     8,    46,     7,     0,     9,    10,    46,    18,
363
     6,     7,     8,    18,    18,    12,    18,    46,    44,    45,
364
    12,    47,    48,    49,    50,    51,    52,    53,    54,    55,
365
    56,    57,    58,    59,    60,    61,    62,    63,    64,    65,
366
    67,    47,    38,    38,    49,    71,    50,    49,    12,    49,
367
    66,    47,    12,    12,    70,    38,    72,     3,     4,     5,
368
     6,     7,     8,     9,    10,    11,    12,     0,    14,    15,
369
    16,    17,     0,    99,    -1,    21,    38,    38,    39,    -1,
370
    -1,    -1,    -1,    44,    45,    46,   112,    48,    -1,    35,
371
    -1,    37,    -1,    -1,    -1,    41,    42,    -1,    -1,    -1,
372
    46,    47,    20,    -1,    22,    23,    24,    25,    26,    27,
373
    28,    29,    30,    31,    32,    33,    34,    -1,    36,    37,
374
    38,    39,    -1,    -1,    -1,    -1,    44,    45,    46,    -1,
375
    48,    49,    20,    -1,    22,    23,    24,    25,    26,    27,
376
    28,    29,    30,    31,    32,    33,    34,    -1,    36,    37,
377
    38,    39,    -1,    -1,    -1,    -1,    44,    45,    46,    -1,
378
    48,    49,    20,    -1,    22,    23,    24,    25,    26,    27,
379
    28,    29,    30,    31,    32,    33,    34,    -1,    36,    37,
380
    38,    39,    -1,    -1,    -1,    -1,    44,    45,    46,    -1,
381
    48,    49,    20,    -1,    22,    23,    24,    25,    26,    27,
382
    28,    29,    30,    31,    32,    33,    34,    -1,    36,    37,
383
    38,    39,    -1,    -1,    -1,    -1,    44,    45,    46,    -1,
384
    48,    23,    24,    25,    26,    27,    28,    29,    30,    31,
385
    32,    33,    34,    -1,    36,    37,    38,    39,    -1,    -1,
386
    -1,    -1,    44,    45,    46,    -1,    48,    24,    25,    26,
387
    27,    28,    29,    30,    31,    32,    33,    34,    -1,    36,
388
    37,    38,    39,    -1,    -1,    -1,    -1,    44,    45,    46,
389
    -1,    48,    25,    26,    27,    28,    29,    30,    31,    32,
390
    33,    34,    -1,    36,    37,    38,    39,    -1,    -1,    -1,
391
    -1,    44,    45,    46,    -1,    48,    27,    28,    29,    30,
392
    31,    32,    33,    34,    -1,    36,    37,    38,    39,    -1,
393
    -1,    -1,    -1,    44,    45,    46,    -1,    48,    31,    32,
394
    33,    34,    -1,    36,    37,    38,    39,    -1,    -1,    -1,
395
    -1,    44,    45,    46,    -1,    48,    36,    37,    38,    39,
396
    -1,    -1,    -1,    -1,    44,    45,    46,    -1,    48
397
};
398
/* -*-C-*-  Note some compilers choke on comments on `#line' lines.  */
399
#line 3 "/usr/lib/bison.simple"
400
/* This file comes from bison-1.27.  */
401
 
402
/* Skeleton output parser for bison,
403
   Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
404
 
405
   This program is free software; you can redistribute it and/or modify
406
   it under the terms of the GNU General Public License as published by
407
   the Free Software Foundation; either version 2, or (at your option)
408
   any later version.
409
 
410
   This program is distributed in the hope that it will be useful,
411
   but WITHOUT ANY WARRANTY; without even the implied warranty of
412
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
413
   GNU General Public License for more details.
414
 
415
   You should have received a copy of the GNU General Public License
416
   along with this program; if not, write to the Free Software
417
   Foundation, Inc., 59 Temple Place - Suite 330,
418
   Boston, MA 02111-1307, USA.  */
419
 
420
/* As a special exception, when this file is copied by Bison into a
421
   Bison output file, you may use that output file without restriction.
422
   This special exception was added by the Free Software Foundation
423
   in version 1.24 of Bison.  */
424
 
425
/* This is the parser code that is written into each bison parser
426
  when the %semantic_parser declaration is not specified in the grammar.
427
  It was written by Richard Stallman by simplifying the hairy parser
428
  used when %semantic_parser is specified.  */
429
 
430
#ifndef YYSTACK_USE_ALLOCA
431
#ifdef alloca
432
#define YYSTACK_USE_ALLOCA
433
#else /* alloca not defined */
434
#ifdef __GNUC__
435
#define YYSTACK_USE_ALLOCA
436
#define alloca __builtin_alloca
437
#else /* not GNU C.  */
438
#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
439
#define YYSTACK_USE_ALLOCA
440
#include <alloca.h>
441
#else /* not sparc */
442
/* We think this test detects Watcom and Microsoft C.  */
443
/* This used to test MSDOS, but that is a bad idea
444
   since that symbol is in the user namespace.  */
445
#if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
446
#if 0 /* No need for xmalloc.h, which pollutes the namespace;
447
         instead, just don't use alloca.  */
448
#endif
449
#else /* not MSDOS, or __TURBOC__ */
450
#if defined(_AIX)
451
/* I don't know what this was needed for, but it pollutes the namespace.
452
   So I turned it off.   rms, 2 May 1997.  */
453
 #pragma alloca
454
#define YYSTACK_USE_ALLOCA
455
#else /* not MSDOS, or __TURBOC__, or _AIX */
456
#if 0
457
#ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
458
                 and on HPUX 10.  Eventually we can turn this on.  */
459
#define YYSTACK_USE_ALLOCA
460
#define alloca __builtin_alloca
461
#endif /* __hpux */
462
#endif
463
#endif /* not _AIX */
464
#endif /* not MSDOS, or __TURBOC__ */
465
#endif /* not sparc */
466
#endif /* not GNU C */
467
#endif /* alloca not defined */
468
#endif /* YYSTACK_USE_ALLOCA not defined */
469
 
470
#ifdef YYSTACK_USE_ALLOCA
471
#define YYSTACK_ALLOC alloca
472
#else
473
#define YYSTACK_ALLOC xmalloc
474
#endif
475
 
476
/* Note: there must be only one dollar sign in this file.
477
   It is replaced by the list of actions, each action
478
   as one case of the switch.  */
479
 
480
#define yyerrok         (yyerrstatus = 0)
481
#define yyclearin       (yychar = YYEMPTY)
482
#define YYEMPTY         -2
483
#define YYEOF           0
484
#define YYACCEPT        goto yyacceptlab
485
#define YYABORT         goto yyabortlab
486
#define YYERROR         goto yyerrlab1
487
/* Like YYERROR except do call yyerror.
488
   This remains here temporarily to ease the
489
   transition to the new meaning of YYERROR, for GCC.
490
   Once GCC version 2 has supplanted version 1, this can go.  */
491
#define YYFAIL          goto yyerrlab
492
#define YYRECOVERING()  (!!yyerrstatus)
493
#define YYBACKUP(token, value) \
494
do                                                              \
495
  if (yychar == YYEMPTY && yylen == 1)                          \
496
    { yychar = (token), yylval = (value);                       \
497
      yychar1 = YYTRANSLATE (yychar);                           \
498
      YYPOPSTACK;                                               \
499
      goto yybackup;                                            \
500
    }                                                           \
501
  else                                                          \
502
    { yyerror ("syntax error: cannot back up"); YYERROR; }      \
503
while (0)
504
 
505
#define YYTERROR        1
506
#define YYERRCODE       256
507
 
508
#ifndef YYPURE
509
#define YYLEX           yylex()
510
#endif
511
 
512
#ifdef YYPURE
513
#ifdef YYLSP_NEEDED
514
#ifdef YYLEX_PARAM
515
#define YYLEX           yylex(&yylval, &yylloc, YYLEX_PARAM)
516
#else
517
#define YYLEX           yylex(&yylval, &yylloc)
518
#endif
519
#else /* not YYLSP_NEEDED */
520
#ifdef YYLEX_PARAM
521
#define YYLEX           yylex(&yylval, YYLEX_PARAM)
522
#else
523
#define YYLEX           yylex(&yylval)
524
#endif
525
#endif /* not YYLSP_NEEDED */
526
#endif
527
 
528
/* If nonreentrant, generate the variables here */
529
 
530
#ifndef YYPURE
531
 
532
int     yychar;                 /*  the lookahead symbol                */
533
YYSTYPE yylval;                 /*  the semantic value of the           */
534
                                /*  lookahead symbol                    */
535
 
536
#ifdef YYLSP_NEEDED
537
YYLTYPE yylloc;                 /*  location data for the lookahead     */
538
                                /*  symbol                              */
539
#endif
540
 
541
int yynerrs;                    /*  number of parse errors so far       */
542
#endif  /* not YYPURE */
543
 
544
#if YYDEBUG != 0
545
int yydebug;                    /*  nonzero means print parse trace     */
546
/* Since this is uninitialized, it does not stop multiple parsers
547
   from coexisting.  */
548
#endif
549
 
550
/*  YYINITDEPTH indicates the initial size of the parser's stacks       */
551
 
552
#ifndef YYINITDEPTH
553
#define YYINITDEPTH 200
554
#endif
555
 
556
/*  YYMAXDEPTH is the maximum size the stacks can grow to
557
    (effective only if the built-in stack extension method is used).  */
558
 
559
#if YYMAXDEPTH == 0
560
#undef YYMAXDEPTH
561
#endif
562
 
563
#ifndef YYMAXDEPTH
564
#define YYMAXDEPTH 10000
565
#endif
566
 
567
/* Define __yy_memcpy.  Note that the size argument
568
   should be passed with type unsigned int, because that is what the non-GCC
569
   definitions require.  With GCC, __builtin_memcpy takes an arg
570
   of type size_t, but it can handle unsigned int.  */
571
 
572
#if __GNUC__ > 1                /* GNU C and GNU C++ define this.  */
573
#define __yy_memcpy(TO,FROM,COUNT)      __builtin_memcpy(TO,FROM,COUNT)
574
#else                           /* not GNU C or C++ */
575
#ifndef __cplusplus
576
 
577
/* This is the most reliable way to avoid incompatibilities
578
   in available built-in functions on various systems.  */
579
static void
580
__yy_memcpy (to, from, count)
581
     char *to;
582
     char *from;
583
     unsigned int count;
584
{
585
  register char *f = from;
586
  register char *t = to;
587
  register int i = count;
588
 
589
  while (i-- > 0)
590
    *t++ = *f++;
591
}
592
 
593
#else /* __cplusplus */
594
 
595
/* This is the most reliable way to avoid incompatibilities
596
   in available built-in functions on various systems.  */
597
static void
598
__yy_memcpy (char *to, char *from, unsigned int count)
599
{
600
  register char *t = to;
601
  register char *f = from;
602
  register int i = count;
603
 
604
  while (i-- > 0)
605
    *t++ = *f++;
606
}
607
 
608
#endif
609
#endif
610
 
611
#line 216 "/usr/lib/bison.simple"
612
 
613
/* The user can define YYPARSE_PARAM as the name of an argument to be passed
614
   into yyparse.  The argument should have type void *.
615
   It should actually point to an object.
616
   Grammar actions can access the variable by casting it
617
   to the proper pointer type.  */
618
 
619
#ifdef YYPARSE_PARAM
620
#ifdef __cplusplus
621
#define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
622
#define YYPARSE_PARAM_DECL
623
#else /* not __cplusplus */
624
#define YYPARSE_PARAM_ARG YYPARSE_PARAM
625
#define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
626
#endif /* not __cplusplus */
627
#else /* not YYPARSE_PARAM */
628
#define YYPARSE_PARAM_ARG
629
#define YYPARSE_PARAM_DECL
630
#endif /* not YYPARSE_PARAM */
631
 
632
/* Prevent warning if -Wstrict-prototypes.  */
633
#ifdef __GNUC__
634
#ifdef YYPARSE_PARAM
635
int yyparse (void *);
636
#else
637
int yyparse (void);
638
#endif
639
#endif
640
 
641
int
642
yyparse(YYPARSE_PARAM_ARG)
643
     YYPARSE_PARAM_DECL
644
{
645
  register int yystate;
646
  register int yyn;
647
  register short *yyssp;
648
  register YYSTYPE *yyvsp;
649
  int yyerrstatus;      /*  number of tokens to shift before error messages enabled */
650
  int yychar1 = 0;               /*  lookahead token as an internal (translated) token number */
651
 
652
  short yyssa[YYINITDEPTH];     /*  the state stack                     */
653
  YYSTYPE yyvsa[YYINITDEPTH];   /*  the semantic value stack            */
654
 
655
  short *yyss = yyssa;          /*  refer to the stacks thru separate pointers */
656
  YYSTYPE *yyvs = yyvsa;        /*  to allow yyoverflow to xreallocate them elsewhere */
657
 
658
#ifdef YYLSP_NEEDED
659
  YYLTYPE yylsa[YYINITDEPTH];   /*  the location stack                  */
660
  YYLTYPE *yyls = yylsa;
661
  YYLTYPE *yylsp;
662
 
663
#define YYPOPSTACK   (yyvsp--, yyssp--, yylsp--)
664
#else
665
#define YYPOPSTACK   (yyvsp--, yyssp--)
666
#endif
667
 
668
  int yystacksize = YYINITDEPTH;
669
  int yyfree_stacks = 0;
670
 
671
#ifdef YYPURE
672
  int yychar;
673
  YYSTYPE yylval;
674
  int yynerrs;
675
#ifdef YYLSP_NEEDED
676
  YYLTYPE yylloc;
677
#endif
678
#endif
679
 
680
  YYSTYPE yyval;                /*  the variable used to return         */
681
                                /*  semantic values from the action     */
682
                                /*  routines                            */
683
 
684
  int yylen;
685
 
686
#if YYDEBUG != 0
687
  if (yydebug)
688
    fprintf(stderr, "Starting parse\n");
689
#endif
690
 
691
  yystate = 0;
692
  yyerrstatus = 0;
693
  yynerrs = 0;
694
  yychar = YYEMPTY;             /* Cause a token to be read.  */
695
 
696
  /* Initialize stack pointers.
697
     Waste one element of value and location stack
698
     so that they stay on the same level as the state stack.
699
     The wasted elements are never initialized.  */
700
 
701
  yyssp = yyss - 1;
702
  yyvsp = yyvs;
703
#ifdef YYLSP_NEEDED
704
  yylsp = yyls;
705
#endif
706
 
707
/* Push a new state, which is found in  yystate  .  */
708
/* In all cases, when you get here, the value and location stacks
709
   have just been pushed. so pushing a state here evens the stacks.  */
710
yynewstate:
711
 
712
  *++yyssp = yystate;
713
 
714
  if (yyssp >= yyss + yystacksize - 1)
715
    {
716
      /* Give user a chance to xreallocate the stack */
717
      /* Use copies of these so that the &'s don't force the real ones into memory. */
718
      YYSTYPE *yyvs1 = yyvs;
719
      short *yyss1 = yyss;
720
#ifdef YYLSP_NEEDED
721
      YYLTYPE *yyls1 = yyls;
722
#endif
723
 
724
      /* Get the current used size of the three stacks, in elements.  */
725
      int size = yyssp - yyss + 1;
726
 
727
#ifdef yyoverflow
728
      /* Each stack pointer address is followed by the size of
729
         the data in use in that stack, in bytes.  */
730
#ifdef YYLSP_NEEDED
731
      /* This used to be a conditional around just the two extra args,
732
         but that might be undefined if yyoverflow is a macro.  */
733
      yyoverflow("parser stack overflow",
734
                 &yyss1, size * sizeof (*yyssp),
735
                 &yyvs1, size * sizeof (*yyvsp),
736
                 &yyls1, size * sizeof (*yylsp),
737
                 &yystacksize);
738
#else
739
      yyoverflow("parser stack overflow",
740
                 &yyss1, size * sizeof (*yyssp),
741
                 &yyvs1, size * sizeof (*yyvsp),
742
                 &yystacksize);
743
#endif
744
 
745
      yyss = yyss1; yyvs = yyvs1;
746
#ifdef YYLSP_NEEDED
747
      yyls = yyls1;
748
#endif
749
#else /* no yyoverflow */
750
      /* Extend the stack our own way.  */
751
      if (yystacksize >= YYMAXDEPTH)
752
        {
753
          yyerror("parser stack overflow");
754
          if (yyfree_stacks)
755
            {
756
              free (yyss);
757
              free (yyvs);
758
#ifdef YYLSP_NEEDED
759
              free (yyls);
760
#endif
761
            }
762
          return 2;
763
        }
764
      yystacksize *= 2;
765
      if (yystacksize > YYMAXDEPTH)
766
        yystacksize = YYMAXDEPTH;
767
#ifndef YYSTACK_USE_ALLOCA
768
      yyfree_stacks = 1;
769
#endif
770
      yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
771
      __yy_memcpy ((char *)yyss, (char *)yyss1,
772
                   size * (unsigned int) sizeof (*yyssp));
773
      yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
774
      __yy_memcpy ((char *)yyvs, (char *)yyvs1,
775
                   size * (unsigned int) sizeof (*yyvsp));
776
#ifdef YYLSP_NEEDED
777
      yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
778
      __yy_memcpy ((char *)yyls, (char *)yyls1,
779
                   size * (unsigned int) sizeof (*yylsp));
780
#endif
781
#endif /* no yyoverflow */
782
 
783
      yyssp = yyss + size - 1;
784
      yyvsp = yyvs + size - 1;
785
#ifdef YYLSP_NEEDED
786
      yylsp = yyls + size - 1;
787
#endif
788
 
789
#if YYDEBUG != 0
790
      if (yydebug)
791
        fprintf(stderr, "Stack size increased to %d\n", yystacksize);
792
#endif
793
 
794
      if (yyssp >= yyss + yystacksize - 1)
795
        YYABORT;
796
    }
797
 
798
#if YYDEBUG != 0
799
  if (yydebug)
800
    fprintf(stderr, "Entering state %d\n", yystate);
801
#endif
802
 
803
  goto yybackup;
804
 yybackup:
805
 
806
/* Do appropriate processing given the current state.  */
807
/* Read a lookahead token if we need one and don't already have one.  */
808
/* yyresume: */
809
 
810
  /* First try to decide what to do without reference to lookahead token.  */
811
 
812
  yyn = yypact[yystate];
813
  if (yyn == YYFLAG)
814
    goto yydefault;
815
 
816
  /* Not known => get a lookahead token if don't already have one.  */
817
 
818
  /* yychar is either YYEMPTY or YYEOF
819
     or a valid token in external form.  */
820
 
821
  if (yychar == YYEMPTY)
822
    {
823
#if YYDEBUG != 0
824
      if (yydebug)
825
        fprintf(stderr, "Reading a token: ");
826
#endif
827
      yychar = YYLEX;
828
    }
829
 
830
  /* Convert token to internal form (in yychar1) for indexing tables with */
831
 
832
  if (yychar <= 0)               /* This means end of input. */
833
    {
834
      yychar1 = 0;
835
      yychar = YYEOF;           /* Don't call YYLEX any more */
836
 
837
#if YYDEBUG != 0
838
      if (yydebug)
839
        fprintf(stderr, "Now at end of input.\n");
840
#endif
841
    }
842
  else
843
    {
844
      yychar1 = YYTRANSLATE(yychar);
845
 
846
#if YYDEBUG != 0
847
      if (yydebug)
848
        {
849
          fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
850
          /* Give the individual parser a way to print the precise meaning
851
             of a token, for further debugging info.  */
852
#ifdef YYPRINT
853
          YYPRINT (stderr, yychar, yylval);
854
#endif
855
          fprintf (stderr, ")\n");
856
        }
857
#endif
858
    }
859
 
860
  yyn += yychar1;
861
  if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
862
    goto yydefault;
863
 
864
  yyn = yytable[yyn];
865
 
866
  /* yyn is what to do for this token type in this state.
867
     Negative => reduce, -yyn is rule number.
868
     Positive => shift, yyn is new state.
869
       New state is final state => don't bother to shift,
870
       just return success.
871
     0, or most negative number => error.  */
872
 
873
  if (yyn < 0)
874
    {
875
      if (yyn == YYFLAG)
876
        goto yyerrlab;
877
      yyn = -yyn;
878
      goto yyreduce;
879
    }
880
  else if (yyn == 0)
881
    goto yyerrlab;
882
 
883
  if (yyn == YYFINAL)
884
    YYACCEPT;
885
 
886
  /* Shift the lookahead token.  */
887
 
888
#if YYDEBUG != 0
889
  if (yydebug)
890
    fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
891
#endif
892
 
893
  /* Discard the token being shifted unless it is eof.  */
894
  if (yychar != YYEOF)
895
    yychar = YYEMPTY;
896
 
897
  *++yyvsp = yylval;
898
#ifdef YYLSP_NEEDED
899
  *++yylsp = yylloc;
900
#endif
901
 
902
  /* count tokens shifted since error; after three, turn off error status.  */
903
  if (yyerrstatus) yyerrstatus--;
904
 
905
  yystate = yyn;
906
  goto yynewstate;
907
 
908
/* Do the default action for the current state.  */
909
yydefault:
910
 
911
  yyn = yydefact[yystate];
912
  if (yyn == 0)
913
    goto yyerrlab;
914
 
915
/* Do a reduction.  yyn is the number of a rule to reduce with.  */
916
yyreduce:
917
  yylen = yyr2[yyn];
918
  if (yylen > 0)
919
    yyval = yyvsp[1-yylen]; /* implement default value of the action */
920
 
921
#if YYDEBUG != 0
922
  if (yydebug)
923
    {
924
      int i;
925
 
926
      fprintf (stderr, "Reducing via rule %d (line %d), ",
927
               yyn, yyrline[yyn]);
928
 
929
      /* Print the symbols being reduced, and their result.  */
930
      for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
931
        fprintf (stderr, "%s ", yytname[yyrhs[i]]);
932
      fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
933
    }
934
#endif
935
 
936
 
937
  switch (yyn) {
938
 
939
case 3:
940
#line 227 "p-exp.y"
941
{ write_exp_elt_opcode(OP_TYPE);
942
                          write_exp_elt_type(yyvsp[0].tval);
943
                          write_exp_elt_opcode(OP_TYPE);;
944
    break;}
945
case 5:
946
#line 235 "p-exp.y"
947
{ write_exp_elt_opcode (BINOP_COMMA); ;
948
    break;}
949
case 6:
950
#line 240 "p-exp.y"
951
{ write_exp_elt_opcode (UNOP_IND); ;
952
    break;}
953
case 7:
954
#line 243 "p-exp.y"
955
{ write_exp_elt_opcode (UNOP_ADDR); ;
956
    break;}
957
case 8:
958
#line 246 "p-exp.y"
959
{ write_exp_elt_opcode (UNOP_NEG); ;
960
    break;}
961
case 9:
962
#line 250 "p-exp.y"
963
{ write_exp_elt_opcode (UNOP_LOGICAL_NOT); ;
964
    break;}
965
case 10:
966
#line 254 "p-exp.y"
967
{ write_exp_elt_opcode (UNOP_PREINCREMENT); ;
968
    break;}
969
case 11:
970
#line 258 "p-exp.y"
971
{ write_exp_elt_opcode (UNOP_PREDECREMENT); ;
972
    break;}
973
case 12:
974
#line 262 "p-exp.y"
975
{ write_exp_elt_opcode (STRUCTOP_STRUCT);
976
                          write_exp_string (yyvsp[0].sval);
977
                          write_exp_elt_opcode (STRUCTOP_STRUCT); ;
978
    break;}
979
case 13:
980
#line 268 "p-exp.y"
981
{ write_exp_elt_opcode (BINOP_SUBSCRIPT); ;
982
    break;}
983
case 14:
984
#line 274 "p-exp.y"
985
{ start_arglist (); ;
986
    break;}
987
case 15:
988
#line 276 "p-exp.y"
989
{ write_exp_elt_opcode (OP_FUNCALL);
990
                          write_exp_elt_longcst ((LONGEST) end_arglist ());
991
                          write_exp_elt_opcode (OP_FUNCALL); ;
992
    break;}
993
case 17:
994
#line 283 "p-exp.y"
995
{ arglist_len = 1; ;
996
    break;}
997
case 18:
998
#line 285 "p-exp.y"
999
{ arglist_len++; ;
1000
    break;}
1001
case 19:
1002
#line 289 "p-exp.y"
1003
{ write_exp_elt_opcode (UNOP_CAST);
1004
                          write_exp_elt_type (yyvsp[-3].tval);
1005
                          write_exp_elt_opcode (UNOP_CAST); ;
1006
    break;}
1007
case 20:
1008
#line 295 "p-exp.y"
1009
{ ;
1010
    break;}
1011
case 21:
1012
#line 301 "p-exp.y"
1013
{ write_exp_elt_opcode (BINOP_MUL); ;
1014
    break;}
1015
case 22:
1016
#line 305 "p-exp.y"
1017
{ write_exp_elt_opcode (BINOP_DIV); ;
1018
    break;}
1019
case 23:
1020
#line 309 "p-exp.y"
1021
{ write_exp_elt_opcode (BINOP_INTDIV); ;
1022
    break;}
1023
case 24:
1024
#line 313 "p-exp.y"
1025
{ write_exp_elt_opcode (BINOP_REM); ;
1026
    break;}
1027
case 25:
1028
#line 317 "p-exp.y"
1029
{ write_exp_elt_opcode (BINOP_ADD); ;
1030
    break;}
1031
case 26:
1032
#line 321 "p-exp.y"
1033
{ write_exp_elt_opcode (BINOP_SUB); ;
1034
    break;}
1035
case 27:
1036
#line 325 "p-exp.y"
1037
{ write_exp_elt_opcode (BINOP_LSH); ;
1038
    break;}
1039
case 28:
1040
#line 329 "p-exp.y"
1041
{ write_exp_elt_opcode (BINOP_RSH); ;
1042
    break;}
1043
case 29:
1044
#line 333 "p-exp.y"
1045
{ write_exp_elt_opcode (BINOP_EQUAL); ;
1046
    break;}
1047
case 30:
1048
#line 337 "p-exp.y"
1049
{ write_exp_elt_opcode (BINOP_NOTEQUAL); ;
1050
    break;}
1051
case 31:
1052
#line 341 "p-exp.y"
1053
{ write_exp_elt_opcode (BINOP_LEQ); ;
1054
    break;}
1055
case 32:
1056
#line 345 "p-exp.y"
1057
{ write_exp_elt_opcode (BINOP_GEQ); ;
1058
    break;}
1059
case 33:
1060
#line 349 "p-exp.y"
1061
{ write_exp_elt_opcode (BINOP_LESS); ;
1062
    break;}
1063
case 34:
1064
#line 353 "p-exp.y"
1065
{ write_exp_elt_opcode (BINOP_GTR); ;
1066
    break;}
1067
case 35:
1068
#line 357 "p-exp.y"
1069
{ write_exp_elt_opcode (BINOP_BITWISE_AND); ;
1070
    break;}
1071
case 36:
1072
#line 361 "p-exp.y"
1073
{ write_exp_elt_opcode (BINOP_BITWISE_XOR); ;
1074
    break;}
1075
case 37:
1076
#line 365 "p-exp.y"
1077
{ write_exp_elt_opcode (BINOP_BITWISE_IOR); ;
1078
    break;}
1079
case 38:
1080
#line 369 "p-exp.y"
1081
{ write_exp_elt_opcode (BINOP_ASSIGN); ;
1082
    break;}
1083
case 39:
1084
#line 373 "p-exp.y"
1085
{ write_exp_elt_opcode (OP_BOOL);
1086
                          write_exp_elt_longcst ((LONGEST) yyvsp[0].lval);
1087
                          write_exp_elt_opcode (OP_BOOL); ;
1088
    break;}
1089
case 40:
1090
#line 379 "p-exp.y"
1091
{ write_exp_elt_opcode (OP_BOOL);
1092
                          write_exp_elt_longcst ((LONGEST) yyvsp[0].lval);
1093
                          write_exp_elt_opcode (OP_BOOL); ;
1094
    break;}
1095
case 41:
1096
#line 385 "p-exp.y"
1097
{ write_exp_elt_opcode (OP_LONG);
1098
                          write_exp_elt_type (yyvsp[0].typed_val_int.type);
1099
                          write_exp_elt_longcst ((LONGEST)(yyvsp[0].typed_val_int.val));
1100
                          write_exp_elt_opcode (OP_LONG); ;
1101
    break;}
1102
case 42:
1103
#line 392 "p-exp.y"
1104
{ YYSTYPE val;
1105
                          parse_number (yyvsp[0].ssym.stoken.ptr, yyvsp[0].ssym.stoken.length, 0, &val);
1106
                          write_exp_elt_opcode (OP_LONG);
1107
                          write_exp_elt_type (val.typed_val_int.type);
1108
                          write_exp_elt_longcst ((LONGEST)val.typed_val_int.val);
1109
                          write_exp_elt_opcode (OP_LONG);
1110
                        ;
1111
    break;}
1112
case 43:
1113
#line 403 "p-exp.y"
1114
{ write_exp_elt_opcode (OP_DOUBLE);
1115
                          write_exp_elt_type (yyvsp[0].typed_val_float.type);
1116
                          write_exp_elt_dblcst (yyvsp[0].typed_val_float.dval);
1117
                          write_exp_elt_opcode (OP_DOUBLE); ;
1118
    break;}
1119
case 46:
1120
#line 417 "p-exp.y"
1121
{ write_exp_elt_opcode (OP_LONG);
1122
                          write_exp_elt_type (builtin_type_int);
1123
                          CHECK_TYPEDEF (yyvsp[-1].tval);
1124
                          write_exp_elt_longcst ((LONGEST) TYPE_LENGTH (yyvsp[-1].tval));
1125
                          write_exp_elt_opcode (OP_LONG); ;
1126
    break;}
1127
case 47:
1128
#line 425 "p-exp.y"
1129
{ /* C strings are converted into array constants with
1130
                             an explicit null byte added at the end.  Thus
1131
                             the array upper bound is the string length.
1132
                             There is no such thing in C as a completely empty
1133
                             string. */
1134
                          char *sp = yyvsp[0].sval.ptr; int count = yyvsp[0].sval.length;
1135
                          while (count-- > 0)
1136
                            {
1137
                              write_exp_elt_opcode (OP_LONG);
1138
                              write_exp_elt_type (builtin_type_char);
1139
                              write_exp_elt_longcst ((LONGEST)(*sp++));
1140
                              write_exp_elt_opcode (OP_LONG);
1141
                            }
1142
                          write_exp_elt_opcode (OP_LONG);
1143
                          write_exp_elt_type (builtin_type_char);
1144
                          write_exp_elt_longcst ((LONGEST)'\0');
1145
                          write_exp_elt_opcode (OP_LONG);
1146
                          write_exp_elt_opcode (OP_ARRAY);
1147
                          write_exp_elt_longcst ((LONGEST) 0);
1148
                          write_exp_elt_longcst ((LONGEST) (yyvsp[0].sval.length));
1149
                          write_exp_elt_opcode (OP_ARRAY); ;
1150
    break;}
1151
case 48:
1152
#line 450 "p-exp.y"
1153
{ write_exp_elt_opcode (OP_THIS);
1154
                          write_exp_elt_opcode (OP_THIS); ;
1155
    break;}
1156
case 49:
1157
#line 457 "p-exp.y"
1158
{
1159
                          if (yyvsp[0].ssym.sym != 0)
1160
                              yyval.bval = SYMBOL_BLOCK_VALUE (yyvsp[0].ssym.sym);
1161
                          else
1162
                            {
1163
                              struct symtab *tem =
1164
                                  lookup_symtab (copy_name (yyvsp[0].ssym.stoken));
1165
                              if (tem)
1166
                                yyval.bval = BLOCKVECTOR_BLOCK (BLOCKVECTOR (tem), STATIC_BLOCK);
1167
                              else
1168
                                error ("No file or function \"%s\".",
1169
                                       copy_name (yyvsp[0].ssym.stoken));
1170
                            }
1171
                        ;
1172
    break;}
1173
case 50:
1174
#line 474 "p-exp.y"
1175
{ struct symbol *tem
1176
                            = lookup_symbol (copy_name (yyvsp[0].sval), yyvsp[-2].bval,
1177
                                             VAR_NAMESPACE, (int *) NULL,
1178
                                             (struct symtab **) NULL);
1179
                          if (!tem || SYMBOL_CLASS (tem) != LOC_BLOCK)
1180
                            error ("No function \"%s\" in specified context.",
1181
                                   copy_name (yyvsp[0].sval));
1182
                          yyval.bval = SYMBOL_BLOCK_VALUE (tem); ;
1183
    break;}
1184
case 51:
1185
#line 485 "p-exp.y"
1186
{ struct symbol *sym;
1187
                          sym = lookup_symbol (copy_name (yyvsp[0].sval), yyvsp[-2].bval,
1188
                                               VAR_NAMESPACE, (int *) NULL,
1189
                                               (struct symtab **) NULL);
1190
                          if (sym == 0)
1191
                            error ("No symbol \"%s\" in specified context.",
1192
                                   copy_name (yyvsp[0].sval));
1193
 
1194
                          write_exp_elt_opcode (OP_VAR_VALUE);
1195
                          /* block_found is set by lookup_symbol.  */
1196
                          write_exp_elt_block (block_found);
1197
                          write_exp_elt_sym (sym);
1198
                          write_exp_elt_opcode (OP_VAR_VALUE); ;
1199
    break;}
1200
case 52:
1201
#line 501 "p-exp.y"
1202
{
1203
                          struct type *type = yyvsp[-2].tval;
1204
                          if (TYPE_CODE (type) != TYPE_CODE_STRUCT
1205
                              && TYPE_CODE (type) != TYPE_CODE_UNION)
1206
                            error ("`%s' is not defined as an aggregate type.",
1207
                                   TYPE_NAME (type));
1208
 
1209
                          write_exp_elt_opcode (OP_SCOPE);
1210
                          write_exp_elt_type (type);
1211
                          write_exp_string (yyvsp[0].sval);
1212
                          write_exp_elt_opcode (OP_SCOPE);
1213
                        ;
1214
    break;}
1215
case 54:
1216
#line 517 "p-exp.y"
1217
{
1218
                          char *name = copy_name (yyvsp[0].sval);
1219
                          struct symbol *sym;
1220
                          struct minimal_symbol *msymbol;
1221
 
1222
                          sym =
1223
                            lookup_symbol (name, (const struct block *) NULL,
1224
                                           VAR_NAMESPACE, (int *) NULL,
1225
                                           (struct symtab **) NULL);
1226
                          if (sym)
1227
                            {
1228
                              write_exp_elt_opcode (OP_VAR_VALUE);
1229
                              write_exp_elt_block (NULL);
1230
                              write_exp_elt_sym (sym);
1231
                              write_exp_elt_opcode (OP_VAR_VALUE);
1232
                              break;
1233
                            }
1234
 
1235
                          msymbol = lookup_minimal_symbol (name, NULL, NULL);
1236
                          if (msymbol != NULL)
1237
                            {
1238
                              write_exp_msymbol (msymbol,
1239
                                                 lookup_function_type (builtin_type_int),
1240
                                                 builtin_type_int);
1241
                            }
1242
                          else
1243
                            if (!have_full_symbols () && !have_partial_symbols ())
1244
                              error ("No symbol table is loaded.  Use the \"file\" command.");
1245
                            else
1246
                              error ("No symbol \"%s\" in current context.", name);
1247
                        ;
1248
    break;}
1249
case 55:
1250
#line 551 "p-exp.y"
1251
{ struct symbol *sym = yyvsp[0].ssym.sym;
1252
 
1253
                          if (sym)
1254
                            {
1255
                              if (symbol_read_needs_frame (sym))
1256
                                {
1257
                                  if (innermost_block == 0 ||
1258
                                      contained_in (block_found,
1259
                                                    innermost_block))
1260
                                    innermost_block = block_found;
1261
                                }
1262
 
1263
                              write_exp_elt_opcode (OP_VAR_VALUE);
1264
                              /* We want to use the selected frame, not
1265
                                 another more inner frame which happens to
1266
                                 be in the same block.  */
1267
                              write_exp_elt_block (NULL);
1268
                              write_exp_elt_sym (sym);
1269
                              write_exp_elt_opcode (OP_VAR_VALUE);
1270
                            }
1271
                          else if (yyvsp[0].ssym.is_a_field_of_this)
1272
                            {
1273
                              /* Object pascal: it hangs off of `this'.  Must
1274
                                 not inadvertently convert from a method call
1275
                                 to data ref.  */
1276
                              if (innermost_block == 0 ||
1277
                                  contained_in (block_found, innermost_block))
1278
                                innermost_block = block_found;
1279
                              write_exp_elt_opcode (OP_THIS);
1280
                              write_exp_elt_opcode (OP_THIS);
1281
                              write_exp_elt_opcode (STRUCTOP_PTR);
1282
                              write_exp_string (yyvsp[0].ssym.stoken);
1283
                              write_exp_elt_opcode (STRUCTOP_PTR);
1284
                            }
1285
                          else
1286
                            {
1287
                              struct minimal_symbol *msymbol;
1288
                              register char *arg = copy_name (yyvsp[0].ssym.stoken);
1289
 
1290
                              msymbol =
1291
                                lookup_minimal_symbol (arg, NULL, NULL);
1292
                              if (msymbol != NULL)
1293
                                {
1294
                                  write_exp_msymbol (msymbol,
1295
                                                     lookup_function_type (builtin_type_int),
1296
                                                     builtin_type_int);
1297
                                }
1298
                              else if (!have_full_symbols () && !have_partial_symbols ())
1299
                                error ("No symbol table is loaded.  Use the \"file\" command.");
1300
                              else
1301
                                error ("No symbol \"%s\" in current context.",
1302
                                       copy_name (yyvsp[0].ssym.stoken));
1303
                            }
1304
                        ;
1305
    break;}
1306
case 58:
1307
#line 621 "p-exp.y"
1308
{ yyval.tval = lookup_member_type (builtin_type_int, yyvsp[-2].tval); ;
1309
    break;}
1310
case 59:
1311
#line 626 "p-exp.y"
1312
{ yyval.tval = yyvsp[0].tsym.type; ;
1313
    break;}
1314
case 60:
1315
#line 628 "p-exp.y"
1316
{ yyval.tval = lookup_struct (copy_name (yyvsp[0].sval),
1317
                                              expression_context_block); ;
1318
    break;}
1319
case 61:
1320
#line 631 "p-exp.y"
1321
{ yyval.tval = lookup_struct (copy_name (yyvsp[0].sval),
1322
                                              expression_context_block); ;
1323
    break;}
1324
case 62:
1325
#line 638 "p-exp.y"
1326
{ yyval.sval = yyvsp[0].ssym.stoken; ;
1327
    break;}
1328
case 63:
1329
#line 639 "p-exp.y"
1330
{ yyval.sval = yyvsp[0].ssym.stoken; ;
1331
    break;}
1332
case 64:
1333
#line 640 "p-exp.y"
1334
{ yyval.sval = yyvsp[0].tsym.stoken; ;
1335
    break;}
1336
case 65:
1337
#line 641 "p-exp.y"
1338
{ yyval.sval = yyvsp[0].ssym.stoken; ;
1339
    break;}
1340
}
1341
   /* the action file gets copied in in place of this dollarsign */
1342
#line 542 "/usr/lib/bison.simple"
1343
 
1344
  yyvsp -= yylen;
1345
  yyssp -= yylen;
1346
#ifdef YYLSP_NEEDED
1347
  yylsp -= yylen;
1348
#endif
1349
 
1350
#if YYDEBUG != 0
1351
  if (yydebug)
1352
    {
1353
      short *ssp1 = yyss - 1;
1354
      fprintf (stderr, "state stack now");
1355
      while (ssp1 != yyssp)
1356
        fprintf (stderr, " %d", *++ssp1);
1357
      fprintf (stderr, "\n");
1358
    }
1359
#endif
1360
 
1361
  *++yyvsp = yyval;
1362
 
1363
#ifdef YYLSP_NEEDED
1364
  yylsp++;
1365
  if (yylen == 0)
1366
    {
1367
      yylsp->first_line = yylloc.first_line;
1368
      yylsp->first_column = yylloc.first_column;
1369
      yylsp->last_line = (yylsp-1)->last_line;
1370
      yylsp->last_column = (yylsp-1)->last_column;
1371
      yylsp->text = 0;
1372
    }
1373
  else
1374
    {
1375
      yylsp->last_line = (yylsp+yylen-1)->last_line;
1376
      yylsp->last_column = (yylsp+yylen-1)->last_column;
1377
    }
1378
#endif
1379
 
1380
  /* Now "shift" the result of the reduction.
1381
     Determine what state that goes to,
1382
     based on the state we popped back to
1383
     and the rule number reduced by.  */
1384
 
1385
  yyn = yyr1[yyn];
1386
 
1387
  yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
1388
  if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1389
    yystate = yytable[yystate];
1390
  else
1391
    yystate = yydefgoto[yyn - YYNTBASE];
1392
 
1393
  goto yynewstate;
1394
 
1395
yyerrlab:   /* here on detecting error */
1396
 
1397
  if (! yyerrstatus)
1398
    /* If not already recovering from an error, report this error.  */
1399
    {
1400
      ++yynerrs;
1401
 
1402
#ifdef YYERROR_VERBOSE
1403
      yyn = yypact[yystate];
1404
 
1405
      if (yyn > YYFLAG && yyn < YYLAST)
1406
        {
1407
          int size = 0;
1408
          char *msg;
1409
          int x, count;
1410
 
1411
          count = 0;
1412
          /* Start X at -yyn if nec to avoid negative indexes in yycheck.  */
1413
          for (x = (yyn < 0 ? -yyn : 0);
1414
               x < (sizeof(yytname) / sizeof(char *)); x++)
1415
            if (yycheck[x + yyn] == x)
1416
              size += strlen(yytname[x]) + 15, count++;
1417
          msg = (char *) xmalloc(size + 15);
1418
          if (msg != 0)
1419
            {
1420
              strcpy(msg, "parse error");
1421
 
1422
              if (count < 5)
1423
                {
1424
                  count = 0;
1425
                  for (x = (yyn < 0 ? -yyn : 0);
1426
                       x < (sizeof(yytname) / sizeof(char *)); x++)
1427
                    if (yycheck[x + yyn] == x)
1428
                      {
1429
                        strcat(msg, count == 0 ? ", expecting `" : " or `");
1430
                        strcat(msg, yytname[x]);
1431
                        strcat(msg, "'");
1432
                        count++;
1433
                      }
1434
                }
1435
              yyerror(msg);
1436
              free(msg);
1437
            }
1438
          else
1439
            yyerror ("parse error; also virtual memory exceeded");
1440
        }
1441
      else
1442
#endif /* YYERROR_VERBOSE */
1443
        yyerror("parse error");
1444
    }
1445
 
1446
  goto yyerrlab1;
1447
yyerrlab1:   /* here on error raised explicitly by an action */
1448
 
1449
  if (yyerrstatus == 3)
1450
    {
1451
      /* if just tried and failed to reuse lookahead token after an error, discard it.  */
1452
 
1453
      /* return failure if at end of input */
1454
      if (yychar == YYEOF)
1455
        YYABORT;
1456
 
1457
#if YYDEBUG != 0
1458
      if (yydebug)
1459
        fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
1460
#endif
1461
 
1462
      yychar = YYEMPTY;
1463
    }
1464
 
1465
  /* Else will try to reuse lookahead token
1466
     after shifting the error token.  */
1467
 
1468
  yyerrstatus = 3;              /* Each real token shifted decrements this */
1469
 
1470
  goto yyerrhandle;
1471
 
1472
yyerrdefault:  /* current state does not do anything special for the error token. */
1473
 
1474
#if 0
1475
  /* This is wrong; only states that explicitly want error tokens
1476
     should shift them.  */
1477
  yyn = yydefact[yystate];  /* If its default is to accept any token, ok.  Otherwise pop it.*/
1478
  if (yyn) goto yydefault;
1479
#endif
1480
 
1481
yyerrpop:   /* pop the current state because it cannot handle the error token */
1482
 
1483
  if (yyssp == yyss) YYABORT;
1484
  yyvsp--;
1485
  yystate = *--yyssp;
1486
#ifdef YYLSP_NEEDED
1487
  yylsp--;
1488
#endif
1489
 
1490
#if YYDEBUG != 0
1491
  if (yydebug)
1492
    {
1493
      short *ssp1 = yyss - 1;
1494
      fprintf (stderr, "Error: state stack now");
1495
      while (ssp1 != yyssp)
1496
        fprintf (stderr, " %d", *++ssp1);
1497
      fprintf (stderr, "\n");
1498
    }
1499
#endif
1500
 
1501
yyerrhandle:
1502
 
1503
  yyn = yypact[yystate];
1504
  if (yyn == YYFLAG)
1505
    goto yyerrdefault;
1506
 
1507
  yyn += YYTERROR;
1508
  if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
1509
    goto yyerrdefault;
1510
 
1511
  yyn = yytable[yyn];
1512
  if (yyn < 0)
1513
    {
1514
      if (yyn == YYFLAG)
1515
        goto yyerrpop;
1516
      yyn = -yyn;
1517
      goto yyreduce;
1518
    }
1519
  else if (yyn == 0)
1520
    goto yyerrpop;
1521
 
1522
  if (yyn == YYFINAL)
1523
    YYACCEPT;
1524
 
1525
#if YYDEBUG != 0
1526
  if (yydebug)
1527
    fprintf(stderr, "Shifting error token, ");
1528
#endif
1529
 
1530
  *++yyvsp = yylval;
1531
#ifdef YYLSP_NEEDED
1532
  *++yylsp = yylloc;
1533
#endif
1534
 
1535
  yystate = yyn;
1536
  goto yynewstate;
1537
 
1538
 yyacceptlab:
1539
  /* YYACCEPT comes here.  */
1540
  if (yyfree_stacks)
1541
    {
1542
      free (yyss);
1543
      free (yyvs);
1544
#ifdef YYLSP_NEEDED
1545
      free (yyls);
1546
#endif
1547
    }
1548
  return 0;
1549
 
1550
 yyabortlab:
1551
  /* YYABORT comes here.  */
1552
  if (yyfree_stacks)
1553
    {
1554
      free (yyss);
1555
      free (yyvs);
1556
#ifdef YYLSP_NEEDED
1557
      free (yyls);
1558
#endif
1559
    }
1560
  return 1;
1561
}
1562
#line 655 "p-exp.y"
1563
 
1564
 
1565
/* Take care of parsing a number (anything that starts with a digit).
1566
   Set yylval and return the token type; update lexptr.
1567
   LEN is the number of characters in it.  */
1568
 
1569
/*** Needs some error checking for the float case ***/
1570
 
1571
static int
1572
parse_number (p, len, parsed_float, putithere)
1573
     register char *p;
1574
     register int len;
1575
     int parsed_float;
1576
     YYSTYPE *putithere;
1577
{
1578
  /* FIXME: Shouldn't these be unsigned?  We don't deal with negative values
1579
     here, and we do kind of silly things like cast to unsigned.  */
1580
  register LONGEST n = 0;
1581
  register LONGEST prevn = 0;
1582
  ULONGEST un;
1583
 
1584
  register int i = 0;
1585
  register int c;
1586
  register int base = input_radix;
1587
  int unsigned_p = 0;
1588
 
1589
  /* Number of "L" suffixes encountered.  */
1590
  int long_p = 0;
1591
 
1592
  /* We have found a "L" or "U" suffix.  */
1593
  int found_suffix = 0;
1594
 
1595
  ULONGEST high_bit;
1596
  struct type *signed_type;
1597
  struct type *unsigned_type;
1598
 
1599
  if (parsed_float)
1600
    {
1601
      /* It's a float since it contains a point or an exponent.  */
1602
      char c;
1603
      int num = 0;       /* number of tokens scanned by scanf */
1604
      char saved_char = p[len];
1605
 
1606
      p[len] = 0;        /* null-terminate the token */
1607
      if (sizeof (putithere->typed_val_float.dval) <= sizeof (float))
1608
        num = sscanf (p, "%g%c", (float *) &putithere->typed_val_float.dval,&c);
1609
      else if (sizeof (putithere->typed_val_float.dval) <= sizeof (double))
1610
        num = sscanf (p, "%lg%c", (double *) &putithere->typed_val_float.dval,&c);
1611
      else
1612
        {
1613
#ifdef SCANF_HAS_LONG_DOUBLE
1614
          num = sscanf (p, "%Lg%c", &putithere->typed_val_float.dval,&c);
1615
#else
1616
          /* Scan it into a double, then assign it to the long double.
1617
             This at least wins with values representable in the range
1618
             of doubles. */
1619
          double temp;
1620
          num = sscanf (p, "%lg%c", &temp,&c);
1621
          putithere->typed_val_float.dval = temp;
1622
#endif
1623
        }
1624
      p[len] = saved_char;      /* restore the input stream */
1625
      if (num != 1)             /* check scanf found ONLY a float ... */
1626
        return ERROR;
1627
      /* See if it has `f' or `l' suffix (float or long double).  */
1628
 
1629
      c = tolower (p[len - 1]);
1630
 
1631
      if (c == 'f')
1632
        putithere->typed_val_float.type = builtin_type_float;
1633
      else if (c == 'l')
1634
        putithere->typed_val_float.type = builtin_type_long_double;
1635
      else if (isdigit (c) || c == '.')
1636
        putithere->typed_val_float.type = builtin_type_double;
1637
      else
1638
        return ERROR;
1639
 
1640
      return FLOAT;
1641
    }
1642
 
1643
  /* Handle base-switching prefixes 0x, 0t, 0d, 0 */
1644
  if (p[0] == '0')
1645
    switch (p[1])
1646
      {
1647
      case 'x':
1648
      case 'X':
1649
        if (len >= 3)
1650
          {
1651
            p += 2;
1652
            base = 16;
1653
            len -= 2;
1654
          }
1655
        break;
1656
 
1657
      case 't':
1658
      case 'T':
1659
      case 'd':
1660
      case 'D':
1661
        if (len >= 3)
1662
          {
1663
            p += 2;
1664
            base = 10;
1665
            len -= 2;
1666
          }
1667
        break;
1668
 
1669
      default:
1670
        base = 8;
1671
        break;
1672
      }
1673
 
1674
  while (len-- > 0)
1675
    {
1676
      c = *p++;
1677
      if (c >= 'A' && c <= 'Z')
1678
        c += 'a' - 'A';
1679
      if (c != 'l' && c != 'u')
1680
        n *= base;
1681
      if (c >= '0' && c <= '9')
1682
        {
1683
          if (found_suffix)
1684
            return ERROR;
1685
          n += i = c - '0';
1686
        }
1687
      else
1688
        {
1689
          if (base > 10 && c >= 'a' && c <= 'f')
1690
            {
1691
              if (found_suffix)
1692
                return ERROR;
1693
              n += i = c - 'a' + 10;
1694
            }
1695
          else if (c == 'l')
1696
            {
1697
              ++long_p;
1698
              found_suffix = 1;
1699
            }
1700
          else if (c == 'u')
1701
            {
1702
              unsigned_p = 1;
1703
              found_suffix = 1;
1704
            }
1705
          else
1706
            return ERROR;       /* Char not a digit */
1707
        }
1708
      if (i >= base)
1709
        return ERROR;           /* Invalid digit in this base */
1710
 
1711
      /* Portably test for overflow (only works for nonzero values, so make
1712
         a second check for zero).  FIXME: Can't we just make n and prevn
1713
         unsigned and avoid this?  */
1714
      if (c != 'l' && c != 'u' && (prevn >= n) && n != 0)
1715
        unsigned_p = 1;         /* Try something unsigned */
1716
 
1717
      /* Portably test for unsigned overflow.
1718
         FIXME: This check is wrong; for example it doesn't find overflow
1719
         on 0x123456789 when LONGEST is 32 bits.  */
1720
      if (c != 'l' && c != 'u' && n != 0)
1721
        {
1722
          if ((unsigned_p && (ULONGEST) prevn >= (ULONGEST) n))
1723
            error ("Numeric constant too large.");
1724
        }
1725
      prevn = n;
1726
    }
1727
 
1728
  /* An integer constant is an int, a long, or a long long.  An L
1729
     suffix forces it to be long; an LL suffix forces it to be long
1730
     long.  If not forced to a larger size, it gets the first type of
1731
     the above that it fits in.  To figure out whether it fits, we
1732
     shift it right and see whether anything remains.  Note that we
1733
     can't shift sizeof (LONGEST) * HOST_CHAR_BIT bits or more in one
1734
     operation, because many compilers will warn about such a shift
1735
     (which always produces a zero result).  Sometimes TARGET_INT_BIT
1736
     or TARGET_LONG_BIT will be that big, sometimes not.  To deal with
1737
     the case where it is we just always shift the value more than
1738
     once, with fewer bits each time.  */
1739
 
1740
  un = (ULONGEST)n >> 2;
1741
  if (long_p == 0
1742
      && (un >> (TARGET_INT_BIT - 2)) == 0)
1743
    {
1744
      high_bit = ((ULONGEST)1) << (TARGET_INT_BIT-1);
1745
 
1746
      /* A large decimal (not hex or octal) constant (between INT_MAX
1747
         and UINT_MAX) is a long or unsigned long, according to ANSI,
1748
         never an unsigned int, but this code treats it as unsigned
1749
         int.  This probably should be fixed.  GCC gives a warning on
1750
         such constants.  */
1751
 
1752
      unsigned_type = builtin_type_unsigned_int;
1753
      signed_type = builtin_type_int;
1754
    }
1755
  else if (long_p <= 1
1756
           && (un >> (TARGET_LONG_BIT - 2)) == 0)
1757
    {
1758
      high_bit = ((ULONGEST)1) << (TARGET_LONG_BIT-1);
1759
      unsigned_type = builtin_type_unsigned_long;
1760
      signed_type = builtin_type_long;
1761
    }
1762
  else
1763
    {
1764
      int shift;
1765
      if (sizeof (ULONGEST) * HOST_CHAR_BIT < TARGET_LONG_LONG_BIT)
1766
        /* A long long does not fit in a LONGEST.  */
1767
        shift = (sizeof (ULONGEST) * HOST_CHAR_BIT - 1);
1768
      else
1769
        shift = (TARGET_LONG_LONG_BIT - 1);
1770
      high_bit = (ULONGEST) 1 << shift;
1771
      unsigned_type = builtin_type_unsigned_long_long;
1772
      signed_type = builtin_type_long_long;
1773
    }
1774
 
1775
   putithere->typed_val_int.val = n;
1776
 
1777
   /* If the high bit of the worked out type is set then this number
1778
      has to be unsigned. */
1779
 
1780
   if (unsigned_p || (n & high_bit))
1781
     {
1782
       putithere->typed_val_int.type = unsigned_type;
1783
     }
1784
   else
1785
     {
1786
       putithere->typed_val_int.type = signed_type;
1787
     }
1788
 
1789
   return INT;
1790
}
1791
 
1792
struct token
1793
{
1794
  char *operator;
1795
  int token;
1796
  enum exp_opcode opcode;
1797
};
1798
 
1799
static const struct token tokentab3[] =
1800
  {
1801
    {"shr", RSH, BINOP_END},
1802
    {"shl", LSH, BINOP_END},
1803
    {"and", ANDAND, BINOP_END},
1804
    {"div", DIV, BINOP_END},
1805
    {"not", NOT, BINOP_END},
1806
    {"mod", MOD, BINOP_END},
1807
    {"inc", INCREMENT, BINOP_END},
1808
    {"dec", DECREMENT, BINOP_END},
1809
    {"xor", XOR, BINOP_END}
1810
  };
1811
 
1812
static const struct token tokentab2[] =
1813
  {
1814
    {"or", OR, BINOP_END},
1815
    {"<>", NOTEQUAL, BINOP_END},
1816
    {"<=", LEQ, BINOP_END},
1817
    {">=", GEQ, BINOP_END},
1818
    {":=", ASSIGN, BINOP_END}
1819
  };
1820
 
1821
/* Allocate uppercased var */
1822
/* make an uppercased copy of tokstart */
1823
static char * uptok (tokstart, namelen)
1824
  char *tokstart;
1825
  int namelen;
1826
{
1827
  int i;
1828
  char *uptokstart = (char *)xmalloc(namelen+1);
1829
  for (i = 0;i <= namelen;i++)
1830
    {
1831
      if ((tokstart[i]>='a' && tokstart[i]<='z'))
1832
        uptokstart[i] = tokstart[i]-('a'-'A');
1833
      else
1834
        uptokstart[i] = tokstart[i];
1835
    }
1836
  uptokstart[namelen]='\0';
1837
  return uptokstart;
1838
}
1839
/* Read one token, getting characters through lexptr.  */
1840
 
1841
 
1842
static int
1843
yylex ()
1844
{
1845
  int c;
1846
  int namelen;
1847
  unsigned int i;
1848
  char *tokstart;
1849
  char *uptokstart;
1850
  char *tokptr;
1851
  char *p;
1852
  int explen, tempbufindex;
1853
  static char *tempbuf;
1854
  static int tempbufsize;
1855
 
1856
 retry:
1857
 
1858
  tokstart = lexptr;
1859
  explen = strlen (lexptr);
1860
  /* See if it is a special token of length 3.  */
1861
  if (explen > 2)
1862
    for (i = 0; i < sizeof (tokentab3) / sizeof (tokentab3[0]); i++)
1863
      if (strncasecmp (tokstart, tokentab3[i].operator, 3) == 0
1864
          && (!isalpha (tokentab3[i].operator[0]) || explen == 3
1865
              || (!isalpha (tokstart[3]) && !isdigit (tokstart[3]) && tokstart[3] != '_')))
1866
        {
1867
          lexptr += 3;
1868
          yylval.opcode = tokentab3[i].opcode;
1869
          return tokentab3[i].token;
1870
        }
1871
 
1872
  /* See if it is a special token of length 2.  */
1873
  if (explen > 1)
1874
  for (i = 0; i < sizeof (tokentab2) / sizeof (tokentab2[0]); i++)
1875
      if (strncasecmp (tokstart, tokentab2[i].operator, 2) == 0
1876
          && (!isalpha (tokentab2[i].operator[0]) || explen == 2
1877
              || (!isalpha (tokstart[2]) && !isdigit (tokstart[2]) && tokstart[2] != '_')))
1878
        {
1879
          lexptr += 2;
1880
          yylval.opcode = tokentab2[i].opcode;
1881
          return tokentab2[i].token;
1882
        }
1883
 
1884
  switch (c = *tokstart)
1885
    {
1886
    case 0:
1887
      return 0;
1888
 
1889
    case ' ':
1890
    case '\t':
1891
    case '\n':
1892
      lexptr++;
1893
      goto retry;
1894
 
1895
    case '\'':
1896
      /* We either have a character constant ('0' or '\177' for example)
1897
         or we have a quoted symbol reference ('foo(int,int)' in object pascal
1898
         for example). */
1899
      lexptr++;
1900
      c = *lexptr++;
1901
      if (c == '\\')
1902
        c = parse_escape (&lexptr);
1903
      else if (c == '\'')
1904
        error ("Empty character constant.");
1905
 
1906
      yylval.typed_val_int.val = c;
1907
      yylval.typed_val_int.type = builtin_type_char;
1908
 
1909
      c = *lexptr++;
1910
      if (c != '\'')
1911
        {
1912
          namelen = skip_quoted (tokstart) - tokstart;
1913
          if (namelen > 2)
1914
            {
1915
              lexptr = tokstart + namelen;
1916
              if (lexptr[-1] != '\'')
1917
                error ("Unmatched single quote.");
1918
              namelen -= 2;
1919
              tokstart++;
1920
              uptokstart = uptok(tokstart,namelen);
1921
              goto tryname;
1922
            }
1923
          error ("Invalid character constant.");
1924
        }
1925
      return INT;
1926
 
1927
    case '(':
1928
      paren_depth++;
1929
      lexptr++;
1930
      return c;
1931
 
1932
    case ')':
1933
      if (paren_depth == 0)
1934
        return 0;
1935
      paren_depth--;
1936
      lexptr++;
1937
      return c;
1938
 
1939
    case ',':
1940
      if (comma_terminates && paren_depth == 0)
1941
        return 0;
1942
      lexptr++;
1943
      return c;
1944
 
1945
    case '.':
1946
      /* Might be a floating point number.  */
1947
      if (lexptr[1] < '0' || lexptr[1] > '9')
1948
        goto symbol;            /* Nope, must be a symbol. */
1949
      /* FALL THRU into number case.  */
1950
 
1951
    case '0':
1952
    case '1':
1953
    case '2':
1954
    case '3':
1955
    case '4':
1956
    case '5':
1957
    case '6':
1958
    case '7':
1959
    case '8':
1960
    case '9':
1961
      {
1962
        /* It's a number.  */
1963
        int got_dot = 0, got_e = 0, toktype;
1964
        register char *p = tokstart;
1965
        int hex = input_radix > 10;
1966
 
1967
        if (c == '0' && (p[1] == 'x' || p[1] == 'X'))
1968
          {
1969
            p += 2;
1970
            hex = 1;
1971
          }
1972
        else if (c == '0' && (p[1]=='t' || p[1]=='T' || p[1]=='d' || p[1]=='D'))
1973
          {
1974
            p += 2;
1975
            hex = 0;
1976
          }
1977
 
1978
        for (;; ++p)
1979
          {
1980
            /* This test includes !hex because 'e' is a valid hex digit
1981
               and thus does not indicate a floating point number when
1982
               the radix is hex.  */
1983
            if (!hex && !got_e && (*p == 'e' || *p == 'E'))
1984
              got_dot = got_e = 1;
1985
            /* This test does not include !hex, because a '.' always indicates
1986
               a decimal floating point number regardless of the radix.  */
1987
            else if (!got_dot && *p == '.')
1988
              got_dot = 1;
1989
            else if (got_e && (p[-1] == 'e' || p[-1] == 'E')
1990
                     && (*p == '-' || *p == '+'))
1991
              /* This is the sign of the exponent, not the end of the
1992
                 number.  */
1993
              continue;
1994
            /* We will take any letters or digits.  parse_number will
1995
               complain if past the radix, or if L or U are not final.  */
1996
            else if ((*p < '0' || *p > '9')
1997
                     && ((*p < 'a' || *p > 'z')
1998
                                  && (*p < 'A' || *p > 'Z')))
1999
              break;
2000
          }
2001
        toktype = parse_number (tokstart, p - tokstart, got_dot|got_e, &yylval);
2002
        if (toktype == ERROR)
2003
          {
2004
            char *err_copy = (char *) alloca (p - tokstart + 1);
2005
 
2006
            memcpy (err_copy, tokstart, p - tokstart);
2007
            err_copy[p - tokstart] = 0;
2008
            error ("Invalid number \"%s\".", err_copy);
2009
          }
2010
        lexptr = p;
2011
        return toktype;
2012
      }
2013
 
2014
    case '+':
2015
    case '-':
2016
    case '*':
2017
    case '/':
2018
    case '|':
2019
    case '&':
2020
    case '^':
2021
    case '~':
2022
    case '!':
2023
    case '@':
2024
    case '<':
2025
    case '>':
2026
    case '[':
2027
    case ']':
2028
    case '?':
2029
    case ':':
2030
    case '=':
2031
    case '{':
2032
    case '}':
2033
    symbol:
2034
      lexptr++;
2035
      return c;
2036
 
2037
    case '"':
2038
 
2039
      /* Build the gdb internal form of the input string in tempbuf,
2040
         translating any standard C escape forms seen.  Note that the
2041
         buffer is null byte terminated *only* for the convenience of
2042
         debugging gdb itself and printing the buffer contents when
2043
         the buffer contains no embedded nulls.  Gdb does not depend
2044
         upon the buffer being null byte terminated, it uses the length
2045
         string instead.  This allows gdb to handle C strings (as well
2046
         as strings in other languages) with embedded null bytes */
2047
 
2048
      tokptr = ++tokstart;
2049
      tempbufindex = 0;
2050
 
2051
      do {
2052
        /* Grow the static temp buffer if necessary, including allocating
2053
           the first one on demand. */
2054
        if (tempbufindex + 1 >= tempbufsize)
2055
          {
2056
            tempbuf = (char *) xrealloc (tempbuf, tempbufsize += 64);
2057
          }
2058
        switch (*tokptr)
2059
          {
2060
          case '\0':
2061
          case '"':
2062
            /* Do nothing, loop will terminate. */
2063
            break;
2064
          case '\\':
2065
            tokptr++;
2066
            c = parse_escape (&tokptr);
2067
            if (c == -1)
2068
              {
2069
                continue;
2070
              }
2071
            tempbuf[tempbufindex++] = c;
2072
            break;
2073
          default:
2074
            tempbuf[tempbufindex++] = *tokptr++;
2075
            break;
2076
          }
2077
      } while ((*tokptr != '"') && (*tokptr != '\0'));
2078
      if (*tokptr++ != '"')
2079
        {
2080
          error ("Unterminated string in expression.");
2081
        }
2082
      tempbuf[tempbufindex] = '\0';     /* See note above */
2083
      yylval.sval.ptr = tempbuf;
2084
      yylval.sval.length = tempbufindex;
2085
      lexptr = tokptr;
2086
      return (STRING);
2087
    }
2088
 
2089
  if (!(c == '_' || c == '$'
2090
        || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')))
2091
    /* We must have come across a bad character (e.g. ';').  */
2092
    error ("Invalid character '%c' in expression.", c);
2093
 
2094
  /* It's a name.  See how long it is.  */
2095
  namelen = 0;
2096
  for (c = tokstart[namelen];
2097
       (c == '_' || c == '$' || (c >= '0' && c <= '9')
2098
        || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '<');)
2099
    {
2100
      /* Template parameter lists are part of the name.
2101
         FIXME: This mishandles `print $a<4&&$a>3'.  */
2102
      if (c == '<')
2103
        {
2104
          int i = namelen;
2105
          int nesting_level = 1;
2106
          while (tokstart[++i])
2107
            {
2108
              if (tokstart[i] == '<')
2109
                nesting_level++;
2110
              else if (tokstart[i] == '>')
2111
                {
2112
                  if (--nesting_level == 0)
2113
                    break;
2114
                }
2115
            }
2116
          if (tokstart[i] == '>')
2117
            namelen = i;
2118
          else
2119
            break;
2120
        }
2121
 
2122
      /* do NOT uppercase internals because of registers !!! */
2123
      c = tokstart[++namelen];
2124
    }
2125
 
2126
  uptokstart = uptok(tokstart,namelen);
2127
 
2128
  /* The token "if" terminates the expression and is NOT
2129
     removed from the input stream.  */
2130
  if (namelen == 2 && uptokstart[0] == 'I' && uptokstart[1] == 'F')
2131
    {
2132
      return 0;
2133
    }
2134
 
2135
  lexptr += namelen;
2136
 
2137
  tryname:
2138
 
2139
  /* Catch specific keywords.  Should be done with a data structure.  */
2140
  switch (namelen)
2141
    {
2142
    case 6:
2143
      if (STREQ (uptokstart, "OBJECT"))
2144
        return CLASS;
2145
      if (STREQ (uptokstart, "RECORD"))
2146
        return STRUCT;
2147
      if (STREQ (uptokstart, "SIZEOF"))
2148
        return SIZEOF;
2149
      break;
2150
    case 5:
2151
      if (STREQ (uptokstart, "CLASS"))
2152
        return CLASS;
2153
      if (STREQ (uptokstart, "FALSE"))
2154
        {
2155
          yylval.lval = 0;
2156
          return FALSE;
2157
        }
2158
      break;
2159
    case 4:
2160
      if (STREQ (uptokstart, "TRUE"))
2161
        {
2162
          yylval.lval = 1;
2163
          return TRUE;
2164
        }
2165
      if (STREQ (uptokstart, "SELF"))
2166
        {
2167
          /* here we search for 'this' like
2168
             inserted in FPC stabs debug info */
2169
          static const char this_name[] =
2170
                                 { /* CPLUS_MARKER,*/ 't', 'h', 'i', 's', '\0' };
2171
 
2172
          if (lookup_symbol (this_name, expression_context_block,
2173
                             VAR_NAMESPACE, (int *) NULL,
2174
                             (struct symtab **) NULL))
2175
            return THIS;
2176
        }
2177
      break;
2178
    default:
2179
      break;
2180
    }
2181
 
2182
  yylval.sval.ptr = tokstart;
2183
  yylval.sval.length = namelen;
2184
 
2185
  if (*tokstart == '$')
2186
    {
2187
      /* $ is the normal prefix for pascal hexadecimal values
2188
        but this conflicts with the GDB use for debugger variables
2189
        so in expression to enter hexadecimal values
2190
        we still need to use C syntax with 0xff  */
2191
      write_dollar_variable (yylval.sval);
2192
      return VARIABLE;
2193
    }
2194
 
2195
  /* Use token-type BLOCKNAME for symbols that happen to be defined as
2196
     functions or symtabs.  If this is not so, then ...
2197
     Use token-type TYPENAME for symbols that happen to be defined
2198
     currently as names of types; NAME for other symbols.
2199
     The caller is not constrained to care about the distinction.  */
2200
  {
2201
    char *tmp = copy_name (yylval.sval);
2202
    struct symbol *sym;
2203
    int is_a_field_of_this = 0;
2204
    int hextype;
2205
 
2206
    sym = lookup_symbol (tmp, expression_context_block,
2207
                         VAR_NAMESPACE,
2208
                         &is_a_field_of_this,
2209
                         (struct symtab **) NULL);
2210
    /* second chance uppercased ! */
2211
    if (!sym)
2212
      {
2213
       for (i = 0;i <= namelen;i++)
2214
         {
2215
           if ((tmp[i]>='a' && tmp[i]<='z'))
2216
             tmp[i] -= ('a'-'A');
2217
           /* I am not sure that copy_name gives excatly the same result ! */
2218
           if ((tokstart[i]>='a' && tokstart[i]<='z'))
2219
             tokstart[i] -= ('a'-'A');
2220
         }
2221
        sym = lookup_symbol (tmp, expression_context_block,
2222
                         VAR_NAMESPACE,
2223
                         &is_a_field_of_this,
2224
                         (struct symtab **) NULL);
2225
      }
2226
    /* Call lookup_symtab, not lookup_partial_symtab, in case there are
2227
       no psymtabs (coff, xcoff, or some future change to blow away the
2228
       psymtabs once once symbols are read).  */
2229
    if ((sym && SYMBOL_CLASS (sym) == LOC_BLOCK) ||
2230
        lookup_symtab (tmp))
2231
      {
2232
        yylval.ssym.sym = sym;
2233
        yylval.ssym.is_a_field_of_this = is_a_field_of_this;
2234
        return BLOCKNAME;
2235
      }
2236
    if (sym && SYMBOL_CLASS (sym) == LOC_TYPEDEF)
2237
        {
2238
#if 1
2239
          /* Despite the following flaw, we need to keep this code enabled.
2240
             Because we can get called from check_stub_method, if we don't
2241
             handle nested types then it screws many operations in any
2242
             program which uses nested types.  */
2243
          /* In "A::x", if x is a member function of A and there happens
2244
             to be a type (nested or not, since the stabs don't make that
2245
             distinction) named x, then this code incorrectly thinks we
2246
             are dealing with nested types rather than a member function.  */
2247
 
2248
          char *p;
2249
          char *namestart;
2250
          struct symbol *best_sym;
2251
 
2252
          /* Look ahead to detect nested types.  This probably should be
2253
             done in the grammar, but trying seemed to introduce a lot
2254
             of shift/reduce and reduce/reduce conflicts.  It's possible
2255
             that it could be done, though.  Or perhaps a non-grammar, but
2256
             less ad hoc, approach would work well.  */
2257
 
2258
          /* Since we do not currently have any way of distinguishing
2259
             a nested type from a non-nested one (the stabs don't tell
2260
             us whether a type is nested), we just ignore the
2261
             containing type.  */
2262
 
2263
          p = lexptr;
2264
          best_sym = sym;
2265
          while (1)
2266
            {
2267
              /* Skip whitespace.  */
2268
              while (*p == ' ' || *p == '\t' || *p == '\n')
2269
                ++p;
2270
              if (*p == ':' && p[1] == ':')
2271
                {
2272
                  /* Skip the `::'.  */
2273
                  p += 2;
2274
                  /* Skip whitespace.  */
2275
                  while (*p == ' ' || *p == '\t' || *p == '\n')
2276
                    ++p;
2277
                  namestart = p;
2278
                  while (*p == '_' || *p == '$' || (*p >= '0' && *p <= '9')
2279
                         || (*p >= 'a' && *p <= 'z')
2280
                         || (*p >= 'A' && *p <= 'Z'))
2281
                    ++p;
2282
                  if (p != namestart)
2283
                    {
2284
                      struct symbol *cur_sym;
2285
                      /* As big as the whole rest of the expression, which is
2286
                         at least big enough.  */
2287
                      char *ncopy = alloca (strlen (tmp)+strlen (namestart)+3);
2288
                      char *tmp1;
2289
 
2290
                      tmp1 = ncopy;
2291
                      memcpy (tmp1, tmp, strlen (tmp));
2292
                      tmp1 += strlen (tmp);
2293
                      memcpy (tmp1, "::", 2);
2294
                      tmp1 += 2;
2295
                      memcpy (tmp1, namestart, p - namestart);
2296
                      tmp1[p - namestart] = '\0';
2297
                      cur_sym = lookup_symbol (ncopy, expression_context_block,
2298
                                               VAR_NAMESPACE, (int *) NULL,
2299
                                               (struct symtab **) NULL);
2300
                      if (cur_sym)
2301
                        {
2302
                          if (SYMBOL_CLASS (cur_sym) == LOC_TYPEDEF)
2303
                            {
2304
                              best_sym = cur_sym;
2305
                              lexptr = p;
2306
                            }
2307
                          else
2308
                            break;
2309
                        }
2310
                      else
2311
                        break;
2312
                    }
2313
                  else
2314
                    break;
2315
                }
2316
              else
2317
                break;
2318
            }
2319
 
2320
          yylval.tsym.type = SYMBOL_TYPE (best_sym);
2321
#else /* not 0 */
2322
          yylval.tsym.type = SYMBOL_TYPE (sym);
2323
#endif /* not 0 */
2324
          return TYPENAME;
2325
        }
2326
    if ((yylval.tsym.type = lookup_primitive_typename (tmp)) != 0)
2327
        return TYPENAME;
2328
 
2329
    /* Input names that aren't symbols but ARE valid hex numbers,
2330
       when the input radix permits them, can be names or numbers
2331
       depending on the parse.  Note we support radixes > 16 here.  */
2332
    if (!sym &&
2333
        ((tokstart[0] >= 'a' && tokstart[0] < 'a' + input_radix - 10) ||
2334
         (tokstart[0] >= 'A' && tokstart[0] < 'A' + input_radix - 10)))
2335
      {
2336
        YYSTYPE newlval;        /* Its value is ignored.  */
2337
        hextype = parse_number (tokstart, namelen, 0, &newlval);
2338
        if (hextype == INT)
2339
          {
2340
            yylval.ssym.sym = sym;
2341
            yylval.ssym.is_a_field_of_this = is_a_field_of_this;
2342
            return NAME_OR_INT;
2343
          }
2344
      }
2345
 
2346
    free(uptokstart);
2347
    /* Any other kind of symbol */
2348
    yylval.ssym.sym = sym;
2349
    yylval.ssym.is_a_field_of_this = is_a_field_of_this;
2350
    return NAME;
2351
  }
2352
}
2353
 
2354
void
2355
yyerror (msg)
2356
     char *msg;
2357
{
2358
  error ("A %s in expression, near `%s'.", (msg ? msg : "error"), lexptr);
2359
}

powered by: WebSVN 2.1.0

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