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

Subversion Repositories or1k

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

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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