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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [gdb-5.0/] [gdb/] [f-exp.tab.c] - Blame information for rev 1772

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

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

powered by: WebSVN 2.1.0

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