2 /* A Bison parser, made from f-exp.y
3 by GNU Bison version 1.25
6 #define YYBISON 1 /* Identify Bison output. */
10 #define STRING_LITERAL 260
11 #define BOOLEAN_LITERAL 261
14 #define NAME_OR_INT 264
17 #define INT_KEYWORD 267
18 #define INT_S2_KEYWORD 268
19 #define LOGICAL_S1_KEYWORD 269
20 #define LOGICAL_S2_KEYWORD 270
21 #define LOGICAL_KEYWORD 271
22 #define REAL_KEYWORD 272
23 #define REAL_S8_KEYWORD 273
24 #define REAL_S16_KEYWORD 274
25 #define COMPLEX_S8_KEYWORD 275
26 #define COMPLEX_S16_KEYWORD 276
27 #define COMPLEX_S32_KEYWORD 277
33 #define ASSIGN_MODIFY 283
34 #define ABOVE_COMMA 284
38 #define GREATERTHAN 288
49 #include "gdb_string.h"
50 #include "expression.h"
52 #include "parser-defs.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 */
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. */
66 #define yymaxdepth f_maxdepth
67 #define yyparse f_parse
69 #define yyerror f_error
72 #define yydebug f_debug
81 #define yyerrflag f_errflag
82 #define yynerrs f_nerrs
87 #define yystate f_state
93 #define yyreds f_reds /* With YYDEBUG defined */
94 #define yytoks f_toks /* With YYDEBUG defined */
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
106 #define YYDEBUG 1 /* Default to no yydebug support */
109 int yyparse
PARAMS ((void));
111 static int yylex
PARAMS ((void));
113 void yyerror
PARAMS ((char *));
115 static void growbuf_by_size
PARAMS ((int));
117 static int match_string_literal
PARAMS ((void));
133 struct symtoken ssym
;
136 enum exp_opcode opcode
;
137 struct internalvar
*ivar
;
144 /* YYSTYPE gets defined by %union */
145 static int parse_number
PARAMS ((char *, int, int, YYSTYPE
*));
157 #define YYFLAG -32768
160 #define YYTRANSLATE(x) ((unsigned)(x) <= 293 ? yytranslate[x] : 71)
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, 2, 3, 4, 5,
189 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
190 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
191 26, 27, 28, 30, 36, 37, 38, 39, 40, 41,
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,
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,
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,
253 #if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
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
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,
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,
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,
308 static const short yydefgoto
[] = { 123,
309 28, 41, 99, 112, 113, 42, 30, 103, 32, 70,
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
329 static const short yypgoto
[] = {-32768,
330 -32768, 0,-32768,-32768,-32768,-32768,-32768, 4,-32768, -25,
331 -32768, -50,-32768,-32768,-32768
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
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
435 /* -*-C-*- Note some compilers choke on comments on `#line' lines. */
436 #line 3 "/stone/jimb/main-98r2/share/bison.simple"
438 /* Skeleton output parser for bison,
439 Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
441 This program is free software; you can redistribute it and/or modify
442 it under the terms of the GNU General Public License as published by
443 the Free Software Foundation; either version 2, or (at your option)
446 This program is distributed in the hope that it will be useful,
447 but WITHOUT ANY WARRANTY; without even the implied warranty of
448 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
449 GNU General Public License for more details.
451 You should have received a copy of the GNU General Public License
452 along with this program; if not, write to the Free Software
453 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
455 /* As a special exception, when this file is copied by Bison into a
456 Bison output file, you may use that output file without restriction.
457 This special exception was added by the Free Software Foundation
458 in version 1.24 of Bison. */
462 #define alloca __builtin_alloca
463 #else /* not GNU C. */
464 #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi)
466 #else /* not sparc */
467 #if defined (MSDOS) && !defined (__TURBOC__)
468 #else /* not MSDOS, or __TURBOC__ */
471 #else /* not MSDOS, __TURBOC__, or _AIX */
475 void *alloca (unsigned int);
477 #else /* not __cplusplus */
479 #endif /* not __cplusplus */
481 #endif /* not _AIX */
482 #endif /* not MSDOS, or __TURBOC__ */
483 #endif /* not sparc. */
484 #endif /* not GNU C. */
485 #endif /* alloca not defined. */
487 /* This is the parser code that is written into each bison parser
488 when the %semantic_parser declaration is not specified in the grammar.
489 It was written by Richard Stallman by simplifying the hairy parser
490 used when %semantic_parser is specified. */
492 /* Note: there must be only one dollar sign in this file.
493 It is replaced by the list of actions, each action
494 as one case of the switch. */
496 #define yyerrok (yyerrstatus = 0)
497 #define yyclearin (yychar = YYEMPTY)
500 #define YYACCEPT return(0)
501 #define YYABORT return(1)
502 #define YYERROR goto yyerrlab1
503 /* Like YYERROR except do call yyerror.
504 This remains here temporarily to ease the
505 transition to the new meaning of YYERROR, for GCC.
506 Once GCC version 2 has supplanted version 1, this can go. */
507 #define YYFAIL goto yyerrlab
508 #define YYRECOVERING() (!!yyerrstatus)
509 #define YYBACKUP(token, value) \
511 if (yychar == YYEMPTY && yylen == 1) \
512 { yychar = (token), yylval = (value); \
513 yychar1 = YYTRANSLATE (yychar); \
518 { yyerror ("syntax error: cannot back up"); YYERROR; } \
522 #define YYERRCODE 256
525 #define YYLEX yylex()
531 #define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
533 #define YYLEX yylex(&yylval, &yylloc)
535 #else /* not YYLSP_NEEDED */
537 #define YYLEX yylex(&yylval, YYLEX_PARAM)
539 #define YYLEX yylex(&yylval)
541 #endif /* not YYLSP_NEEDED */
544 /* If nonreentrant, generate the variables here */
548 int yychar
; /* the lookahead symbol */
549 YYSTYPE yylval
; /* the semantic value of the */
550 /* lookahead symbol */
553 YYLTYPE yylloc
; /* location data for the lookahead */
557 int yynerrs
; /* number of parse errors so far */
558 #endif /* not YYPURE */
561 int yydebug
; /* nonzero means print parse trace */
562 /* Since this is uninitialized, it does not stop multiple parsers
566 /* YYINITDEPTH indicates the initial size of the parser's stacks */
569 #define YYINITDEPTH 200
572 /* YYMAXDEPTH is the maximum size the stacks can grow to
573 (effective only if the built-in stack extension method is used). */
580 #define YYMAXDEPTH 10000
583 /* Prevent warning if -Wstrict-prototypes. */
588 #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
589 #define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
590 #else /* not GNU C or C++ */
593 /* This is the most reliable way to avoid incompatibilities
594 in available built-in functions on various systems. */
596 __yy_memcpy (to
, from
, count
)
601 register char *f
= from
;
602 register char *t
= to
;
603 register int i
= count
;
609 #else /* __cplusplus */
611 /* This is the most reliable way to avoid incompatibilities
612 in available built-in functions on various systems. */
614 __yy_memcpy (char *to
, char *from
, int count
)
616 register char *f
= from
;
617 register char *t
= to
;
618 register int i
= count
;
627 #line 196 "/stone/jimb/main-98r2/share/bison.simple"
629 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
630 into yyparse. The argument should have type void *.
631 It should actually point to an object.
632 Grammar actions can access the variable by casting it
633 to the proper pointer type. */
637 #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
638 #define YYPARSE_PARAM_DECL
639 #else /* not __cplusplus */
640 #define YYPARSE_PARAM_ARG YYPARSE_PARAM
641 #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
642 #endif /* not __cplusplus */
643 #else /* not YYPARSE_PARAM */
644 #define YYPARSE_PARAM_ARG
645 #define YYPARSE_PARAM_DECL
646 #endif /* not YYPARSE_PARAM */
649 yyparse(YYPARSE_PARAM_ARG
)
652 register int yystate
;
654 register short *yyssp
;
655 register YYSTYPE
*yyvsp
;
656 int yyerrstatus
; /* number of tokens to shift before error messages enabled */
657 int yychar1
= 0; /* lookahead token as an internal (translated) token number */
659 short yyssa
[YYINITDEPTH
]; /* the state stack */
660 YYSTYPE yyvsa
[YYINITDEPTH
]; /* the semantic value stack */
662 short *yyss
= yyssa
; /* refer to the stacks thru separate pointers */
663 YYSTYPE
*yyvs
= yyvsa
; /* to allow yyoverflow to xreallocate them elsewhere */
666 YYLTYPE yylsa
[YYINITDEPTH
]; /* the location stack */
667 YYLTYPE
*yyls
= yylsa
;
670 #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
672 #define YYPOPSTACK (yyvsp--, yyssp--)
675 int yystacksize
= YYINITDEPTH
;
686 YYSTYPE yyval
; /* the variable used to return */
687 /* semantic values from the action */
694 fprintf(stderr
, "Starting parse\n");
700 yychar
= YYEMPTY
; /* Cause a token to be read. */
702 /* Initialize stack pointers.
703 Waste one element of value and location stack
704 so that they stay on the same level as the state stack.
705 The wasted elements are never initialized. */
713 /* Push a new state, which is found in yystate . */
714 /* In all cases, when you get here, the value and location stacks
715 have just been pushed. so pushing a state here evens the stacks. */
720 if (yyssp
>= yyss
+ yystacksize
- 1)
722 /* Give user a chance to xreallocate the stack */
723 /* Use copies of these so that the &'s don't force the real ones into memory. */
724 YYSTYPE
*yyvs1
= yyvs
;
727 YYLTYPE
*yyls1
= yyls
;
730 /* Get the current used size of the three stacks, in elements. */
731 int size
= yyssp
- yyss
+ 1;
734 /* Each stack pointer address is followed by the size of
735 the data in use in that stack, in bytes. */
737 /* This used to be a conditional around just the two extra args,
738 but that might be undefined if yyoverflow is a macro. */
739 yyoverflow("parser stack overflow",
740 &yyss1
, size
* sizeof (*yyssp
),
741 &yyvs1
, size
* sizeof (*yyvsp
),
742 &yyls1
, size
* sizeof (*yylsp
),
745 yyoverflow("parser stack overflow",
746 &yyss1
, size
* sizeof (*yyssp
),
747 &yyvs1
, size
* sizeof (*yyvsp
),
751 yyss
= yyss1
; yyvs
= yyvs1
;
755 #else /* no yyoverflow */
756 /* Extend the stack our own way. */
757 if (yystacksize
>= YYMAXDEPTH
)
759 yyerror("parser stack overflow");
763 if (yystacksize
> YYMAXDEPTH
)
764 yystacksize
= YYMAXDEPTH
;
765 yyss
= (short *) alloca (yystacksize
* sizeof (*yyssp
));
766 __yy_memcpy ((char *)yyss
, (char *)yyss1
, size
* sizeof (*yyssp
));
767 yyvs
= (YYSTYPE
*) alloca (yystacksize
* sizeof (*yyvsp
));
768 __yy_memcpy ((char *)yyvs
, (char *)yyvs1
, size
* sizeof (*yyvsp
));
770 yyls
= (YYLTYPE
*) alloca (yystacksize
* sizeof (*yylsp
));
771 __yy_memcpy ((char *)yyls
, (char *)yyls1
, size
* sizeof (*yylsp
));
773 #endif /* no yyoverflow */
775 yyssp
= yyss
+ size
- 1;
776 yyvsp
= yyvs
+ size
- 1;
778 yylsp
= yyls
+ size
- 1;
783 fprintf(stderr
, "Stack size increased to %d\n", yystacksize
);
786 if (yyssp
>= yyss
+ yystacksize
- 1)
792 fprintf(stderr
, "Entering state %d\n", yystate
);
798 /* Do appropriate processing given the current state. */
799 /* Read a lookahead token if we need one and don't already have one. */
802 /* First try to decide what to do without reference to lookahead token. */
804 yyn
= yypact
[yystate
];
808 /* Not known => get a lookahead token if don't already have one. */
810 /* yychar is either YYEMPTY or YYEOF
811 or a valid token in external form. */
813 if (yychar
== YYEMPTY
)
817 fprintf(stderr
, "Reading a token: ");
822 /* Convert token to internal form (in yychar1) for indexing tables with */
824 if (yychar
<= 0) /* This means end of input. */
827 yychar
= YYEOF
; /* Don't call YYLEX any more */
831 fprintf(stderr
, "Now at end of input.\n");
836 yychar1
= YYTRANSLATE(yychar
);
841 fprintf (stderr
, "Next token is %d (%s", yychar
, yytname
[yychar1
]);
842 /* Give the individual parser a way to print the precise meaning
843 of a token, for further debugging info. */
845 YYPRINT (stderr
, yychar
, yylval
);
847 fprintf (stderr
, ")\n");
853 if (yyn
< 0 || yyn
> YYLAST
|| yycheck
[yyn
] != yychar1
)
858 /* yyn is what to do for this token type in this state.
859 Negative => reduce, -yyn is rule number.
860 Positive => shift, yyn is new state.
861 New state is final state => don't bother to shift,
863 0, or most negative number => error. */
878 /* Shift the lookahead token. */
882 fprintf(stderr
, "Shifting token %d (%s), ", yychar
, yytname
[yychar1
]);
885 /* Discard the token being shifted unless it is eof. */
894 /* count tokens shifted since error; after three, turn off error status. */
895 if (yyerrstatus
) yyerrstatus
--;
900 /* Do the default action for the current state. */
903 yyn
= yydefact
[yystate
];
907 /* Do a reduction. yyn is the number of a rule to reduce with. */
911 yyval
= yyvsp
[1-yylen
]; /* implement default value of the action */
918 fprintf (stderr
, "Reducing via rule %d (line %d), ",
921 /* Print the symbols being reduced, and their result. */
922 for (i
= yyprhs
[yyn
]; yyrhs
[i
] > 0; i
++)
923 fprintf (stderr
, "%s ", yytname
[yyrhs
[i
]]);
924 fprintf (stderr
, " -> %s\n", yytname
[yyr1
[yyn
]]);
933 { write_exp_elt_opcode(OP_TYPE
);
934 write_exp_elt_type(yyvsp
[0].tval
);
935 write_exp_elt_opcode(OP_TYPE
); ;
943 { write_exp_elt_opcode (UNOP_IND
); ;
947 { write_exp_elt_opcode (UNOP_ADDR
); ;
951 { write_exp_elt_opcode (UNOP_NEG
); ;
955 { write_exp_elt_opcode (UNOP_LOGICAL_NOT
); ;
959 { write_exp_elt_opcode (UNOP_COMPLEMENT
); ;
963 { write_exp_elt_opcode (UNOP_SIZEOF
); ;
967 { start_arglist (); ;
971 { write_exp_elt_opcode (OP_F77_UNDETERMINED_ARGLIST
);
972 write_exp_elt_longcst ((LONGEST
) end_arglist ());
973 write_exp_elt_opcode (OP_F77_UNDETERMINED_ARGLIST
); ;
997 { write_exp_elt_opcode(OP_COMPLEX
); ;
1001 { write_exp_elt_opcode (UNOP_CAST
);
1002 write_exp_elt_type (yyvsp
[-2].tval
);
1003 write_exp_elt_opcode (UNOP_CAST
); ;
1007 { write_exp_elt_opcode (BINOP_REPEAT
); ;
1011 { write_exp_elt_opcode (BINOP_MUL
); ;
1015 { write_exp_elt_opcode (BINOP_DIV
); ;
1019 { write_exp_elt_opcode (BINOP_REM
); ;
1023 { write_exp_elt_opcode (BINOP_ADD
); ;
1027 { write_exp_elt_opcode (BINOP_SUB
); ;
1031 { write_exp_elt_opcode (BINOP_LSH
); ;
1035 { write_exp_elt_opcode (BINOP_RSH
); ;
1039 { write_exp_elt_opcode (BINOP_EQUAL
); ;
1043 { write_exp_elt_opcode (BINOP_NOTEQUAL
); ;
1047 { write_exp_elt_opcode (BINOP_LEQ
); ;
1051 { write_exp_elt_opcode (BINOP_GEQ
); ;
1055 { write_exp_elt_opcode (BINOP_LESS
); ;
1059 { write_exp_elt_opcode (BINOP_GTR
); ;
1063 { write_exp_elt_opcode (BINOP_BITWISE_AND
); ;
1067 { write_exp_elt_opcode (BINOP_BITWISE_XOR
); ;
1071 { write_exp_elt_opcode (BINOP_BITWISE_IOR
); ;
1075 { write_exp_elt_opcode (BINOP_LOGICAL_AND
); ;
1079 { write_exp_elt_opcode (BINOP_LOGICAL_OR
); ;
1083 { write_exp_elt_opcode (BINOP_ASSIGN
); ;
1087 { write_exp_elt_opcode (BINOP_ASSIGN_MODIFY
);
1088 write_exp_elt_opcode (yyvsp
[-1].opcode
);
1089 write_exp_elt_opcode (BINOP_ASSIGN_MODIFY
); ;
1093 { write_exp_elt_opcode (OP_LONG
);
1094 write_exp_elt_type (yyvsp
[0].typed_val
.type
);
1095 write_exp_elt_longcst ((LONGEST
)(yyvsp
[0].typed_val
.val
));
1096 write_exp_elt_opcode (OP_LONG
); ;
1101 parse_number (yyvsp
[0].ssym
.stoken
.ptr
, yyvsp
[0].ssym
.stoken
.length
, 0, &val
);
1102 write_exp_elt_opcode (OP_LONG
);
1103 write_exp_elt_type (val
.typed_val
.type
);
1104 write_exp_elt_longcst ((LONGEST
)val
.typed_val
.val
);
1105 write_exp_elt_opcode (OP_LONG
); ;
1109 { write_exp_elt_opcode (OP_DOUBLE
);
1110 write_exp_elt_type (builtin_type_f_real_s8
);
1111 write_exp_elt_dblcst (yyvsp
[0].dval
);
1112 write_exp_elt_opcode (OP_DOUBLE
); ;
1116 { write_exp_elt_opcode (OP_LONG
);
1117 write_exp_elt_type (builtin_type_f_integer
);
1118 CHECK_TYPEDEF (yyvsp
[-1].tval
);
1119 write_exp_elt_longcst ((LONGEST
) TYPE_LENGTH (yyvsp
[-1].tval
));
1120 write_exp_elt_opcode (OP_LONG
); ;
1124 { write_exp_elt_opcode (OP_BOOL
);
1125 write_exp_elt_longcst ((LONGEST
) yyvsp
[0].lval
);
1126 write_exp_elt_opcode (OP_BOOL
);
1132 write_exp_elt_opcode (OP_STRING
);
1133 write_exp_string (yyvsp
[0].sval
);
1134 write_exp_elt_opcode (OP_STRING
);
1139 { struct symbol
*sym
= yyvsp
[0].ssym
.sym
;
1143 if (symbol_read_needs_frame (sym
))
1145 if (innermost_block
== 0 ||
1146 contained_in (block_found
,
1148 innermost_block
= block_found
;
1150 write_exp_elt_opcode (OP_VAR_VALUE
);
1151 /* We want to use the selected frame, not
1152 another more inner frame which happens to
1153 be in the same block. */
1154 write_exp_elt_block (NULL
);
1155 write_exp_elt_sym (sym
);
1156 write_exp_elt_opcode (OP_VAR_VALUE
);
1161 struct minimal_symbol
*msymbol
;
1162 register char *arg
= copy_name (yyvsp
[0].ssym
.stoken
);
1165 lookup_minimal_symbol (arg
, NULL
, NULL
);
1166 if (msymbol
!= NULL
)
1168 write_exp_msymbol (msymbol
,
1169 lookup_function_type (builtin_type_int
),
1172 else if (!have_full_symbols () && !have_partial_symbols ())
1173 error ("No symbol table is loaded. Use the \"file\" command.");
1175 error ("No symbol \"%s\" in current context.",
1176 copy_name (yyvsp
[0].ssym
.stoken
));
1183 /* This is where the interesting stuff happens. */
1186 struct type
*follow_type
= yyvsp
[-1].tval
;
1187 struct type
*range_type
;
1190 switch (pop_type ())
1196 follow_type
= lookup_pointer_type (follow_type
);
1199 follow_type
= lookup_reference_type (follow_type
);
1202 array_size
= pop_type_int ();
1203 if (array_size
!= -1)
1206 create_range_type ((struct type
*) NULL
,
1207 builtin_type_f_integer
, 0,
1210 create_array_type ((struct type
*) NULL
,
1211 follow_type
, range_type
);
1214 follow_type
= lookup_pointer_type (follow_type
);
1217 follow_type
= lookup_function_type (follow_type
);
1220 yyval
.tval
= follow_type
;
1225 { push_type (tp_pointer
); yyval
.voidval
= 0; ;
1229 { push_type (tp_pointer
); yyval
.voidval
= yyvsp
[0].voidval
; ;
1233 { push_type (tp_reference
); yyval
.voidval
= 0; ;
1237 { push_type (tp_reference
); yyval
.voidval
= yyvsp
[0].voidval
; ;
1241 { yyval
.voidval
= yyvsp
[-1].voidval
; ;
1245 { push_type (tp_function
); ;
1249 { push_type (tp_function
); ;
1253 { yyval
.voidval
= 0; ;
1257 { free ((PTR
)yyvsp
[-1].tvec
); yyval
.voidval
= 0; ;
1261 { yyval
.tval
= yyvsp
[0].tsym
.type
; ;
1265 { yyval
.tval
= builtin_type_f_integer
; ;
1269 { yyval
.tval
= builtin_type_f_integer_s2
; ;
1273 { yyval
.tval
= builtin_type_f_character
; ;
1277 { yyval
.tval
= builtin_type_f_logical
;;
1281 { yyval
.tval
= builtin_type_f_logical_s2
;;
1285 { yyval
.tval
= builtin_type_f_logical_s1
;;
1289 { yyval
.tval
= builtin_type_f_real
;;
1293 { yyval
.tval
= builtin_type_f_real_s8
;;
1297 { yyval
.tval
= builtin_type_f_real_s16
;;
1301 { yyval
.tval
= builtin_type_f_complex_s8
;;
1305 { yyval
.tval
= builtin_type_f_complex_s16
;;
1309 { yyval
.tval
= builtin_type_f_complex_s32
;;
1313 { yyval
.tvec
= (struct type
**) xmalloc (sizeof (struct type
*) * 2);
1314 yyval
.ivec
[0] = 1; /* Number of types in vector */
1315 yyval
.tvec
[1] = yyvsp
[0].tval
;
1320 { int len
= sizeof (struct type
*) * (++(yyvsp
[-2].ivec
[0]) + 1);
1321 yyval
.tvec
= (struct type
**) xrealloc ((char *) yyvsp
[-2].tvec
, len
);
1322 yyval
.tvec
[yyval
.ivec
[0]] = yyvsp
[0].tval
;
1327 { yyval
.sval
= yyvsp
[0].ssym
.stoken
; ;
1331 { yyval
.sval
= yyvsp
[0].tsym
.stoken
; ;
1335 { yyval
.sval
= yyvsp
[0].ssym
.stoken
; ;
1338 /* the action file gets copied in in place of this dollarsign */
1339 #line 498 "/stone/jimb/main-98r2/share/bison.simple"
1350 short *ssp1
= yyss
- 1;
1351 fprintf (stderr
, "state stack now");
1352 while (ssp1
!= yyssp
)
1353 fprintf (stderr
, " %d", *++ssp1
);
1354 fprintf (stderr
, "\n");
1364 yylsp
->first_line
= yylloc
.first_line
;
1365 yylsp
->first_column
= yylloc
.first_column
;
1366 yylsp
->last_line
= (yylsp
-1)->last_line
;
1367 yylsp
->last_column
= (yylsp
-1)->last_column
;
1372 yylsp
->last_line
= (yylsp
+yylen
-1)->last_line
;
1373 yylsp
->last_column
= (yylsp
+yylen
-1)->last_column
;
1377 /* Now "shift" the result of the reduction.
1378 Determine what state that goes to,
1379 based on the state we popped back to
1380 and the rule number reduced by. */
1384 yystate
= yypgoto
[yyn
- YYNTBASE
] + *yyssp
;
1385 if (yystate
>= 0 && yystate
<= YYLAST
&& yycheck
[yystate
] == *yyssp
)
1386 yystate
= yytable
[yystate
];
1388 yystate
= yydefgoto
[yyn
- YYNTBASE
];
1392 yyerrlab
: /* here on detecting error */
1395 /* If not already recovering from an error, report this error. */
1399 #ifdef YYERROR_VERBOSE
1400 yyn
= yypact
[yystate
];
1402 if (yyn
> YYFLAG
&& yyn
< YYLAST
)
1409 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
1410 for (x
= (yyn
< 0 ? -yyn
: 0);
1411 x
< (sizeof(yytname
) / sizeof(char *)); x
++)
1412 if (yycheck
[x
+ yyn
] == x
)
1413 size
+= strlen(yytname
[x
]) + 15, count
++;
1414 msg
= (char *) xmalloc(size
+ 15);
1417 strcpy(msg
, "parse error");
1422 for (x
= (yyn
< 0 ? -yyn
: 0);
1423 x
< (sizeof(yytname
) / sizeof(char *)); x
++)
1424 if (yycheck
[x
+ yyn
] == x
)
1426 strcat(msg
, count
== 0 ? ", expecting `" : " or `");
1427 strcat(msg
, yytname
[x
]);
1436 yyerror ("parse error; also virtual memory exceeded");
1439 #endif /* YYERROR_VERBOSE */
1440 yyerror("parse error");
1444 yyerrlab1
: /* here on error raised explicitly by an action */
1446 if (yyerrstatus
== 3)
1448 /* if just tried and failed to reuse lookahead token after an error, discard it. */
1450 /* return failure if at end of input */
1451 if (yychar
== YYEOF
)
1456 fprintf(stderr
, "Discarding token %d (%s).\n", yychar
, yytname
[yychar1
]);
1462 /* Else will try to reuse lookahead token
1463 after shifting the error token. */
1465 yyerrstatus
= 3; /* Each real token shifted decrements this */
1469 yyerrdefault
: /* current state does not do anything special for the error token. */
1472 /* This is wrong; only states that explicitly want error tokens
1473 should shift them. */
1474 yyn
= yydefact
[yystate
]; /* If its default is to accept any token, ok. Otherwise pop it.*/
1475 if (yyn
) goto yydefault
;
1478 yyerrpop
: /* pop the current state because it cannot handle the error token */
1480 if (yyssp
== yyss
) YYABORT
;
1490 short *ssp1
= yyss
- 1;
1491 fprintf (stderr
, "Error: state stack now");
1492 while (ssp1
!= yyssp
)
1493 fprintf (stderr
, " %d", *++ssp1
);
1494 fprintf (stderr
, "\n");
1500 yyn
= yypact
[yystate
];
1505 if (yyn
< 0 || yyn
> YYLAST
|| yycheck
[yyn
] != YYTERROR
)
1524 fprintf(stderr
, "Shifting error token, ");
1538 /* Take care of parsing a number (anything that starts with a digit).
1539 Set yylval and return the token type; update lexptr.
1540 LEN is the number of characters in it. */
1542 /*** Needs some error checking for the float case ***/
1545 parse_number (p
, len
, parsed_float
, putithere
)
1551 register LONGEST n
= 0;
1552 register LONGEST prevn
= 0;
1555 register int base
= input_radix
;
1559 struct type
*signed_type
;
1560 struct type
*unsigned_type
;
1564 /* It's a float since it contains a point or an exponent. */
1565 /* [dD] is not understood as an exponent by atof, change it to 'e'. */
1569 for (tmp2
= tmp
; *tmp2
; ++tmp2
)
1570 if (*tmp2
== 'd' || *tmp2
== 'D')
1572 putithere
->dval
= atof (tmp
);
1577 /* Handle base-switching prefixes 0x, 0t, 0d, 0 */
1611 if (c
>= 'A' && c
<= 'Z')
1613 if (c
!= 'l' && c
!= 'u')
1615 if (c
>= '0' && c
<= '9')
1619 if (base
> 10 && c
>= 'a' && c
<= 'f')
1620 n
+= i
= c
- 'a' + 10;
1621 else if (len
== 0 && c
== 'l')
1623 else if (len
== 0 && c
== 'u')
1626 return ERROR
; /* Char not a digit */
1629 return ERROR
; /* Invalid digit in this base */
1631 /* Portably test for overflow (only works for nonzero values, so make
1632 a second check for zero). */
1633 if ((prevn
>= n
) && n
!= 0)
1634 unsigned_p
=1; /* Try something unsigned */
1635 /* If range checking enabled, portably test for unsigned overflow. */
1636 if (RANGE_CHECK
&& n
!= 0)
1638 if ((unsigned_p
&& (unsigned)prevn
>= (unsigned)n
))
1639 range_error("Overflow on numeric constant.");
1644 /* If the number is too big to be an int, or it's got an l suffix
1645 then it's a long. Work out if this has to be a long by
1646 shifting right and and seeing if anything remains, and the
1647 target int size is different to the target long size.
1649 In the expression below, we could have tested
1650 (n >> TARGET_INT_BIT)
1651 to see if it was zero,
1652 but too many compilers warn about that, when ints and longs
1653 are the same size. So we shift it twice, with fewer bits
1654 each time, for the same result. */
1656 if ((TARGET_INT_BIT
!= TARGET_LONG_BIT
1657 && ((n
>> 2) >> (TARGET_INT_BIT
-2))) /* Avoid shift warning */
1660 high_bit
= ((ULONGEST
)1) << (TARGET_LONG_BIT
-1);
1661 unsigned_type
= builtin_type_unsigned_long
;
1662 signed_type
= builtin_type_long
;
1666 high_bit
= ((ULONGEST
)1) << (TARGET_INT_BIT
-1);
1667 unsigned_type
= builtin_type_unsigned_int
;
1668 signed_type
= builtin_type_int
;
1671 putithere
->typed_val
.val
= n
;
1673 /* If the high bit of the worked out type is set then this number
1674 has to be unsigned. */
1676 if (unsigned_p
|| (n
& high_bit
))
1677 putithere
->typed_val
.type
= unsigned_type
;
1679 putithere
->typed_val
.type
= signed_type
;
1688 enum exp_opcode opcode
;
1691 static const struct token dot_ops
[] =
1693 { ".and.", BOOL_AND
, BINOP_END
},
1694 { ".AND.", BOOL_AND
, BINOP_END
},
1695 { ".or.", BOOL_OR
, BINOP_END
},
1696 { ".OR.", BOOL_OR
, BINOP_END
},
1697 { ".not.", BOOL_NOT
, BINOP_END
},
1698 { ".NOT.", BOOL_NOT
, BINOP_END
},
1699 { ".eq.", EQUAL
, BINOP_END
},
1700 { ".EQ.", EQUAL
, BINOP_END
},
1701 { ".eqv.", EQUAL
, BINOP_END
},
1702 { ".NEQV.", NOTEQUAL
, BINOP_END
},
1703 { ".neqv.", NOTEQUAL
, BINOP_END
},
1704 { ".EQV.", EQUAL
, BINOP_END
},
1705 { ".ne.", NOTEQUAL
, BINOP_END
},
1706 { ".NE.", NOTEQUAL
, BINOP_END
},
1707 { ".le.", LEQ
, BINOP_END
},
1708 { ".LE.", LEQ
, BINOP_END
},
1709 { ".ge.", GEQ
, BINOP_END
},
1710 { ".GE.", GEQ
, BINOP_END
},
1711 { ".gt.", GREATERTHAN
, BINOP_END
},
1712 { ".GT.", GREATERTHAN
, BINOP_END
},
1713 { ".lt.", LESSTHAN
, BINOP_END
},
1714 { ".LT.", LESSTHAN
, BINOP_END
},
1718 struct f77_boolean_val
1724 static const struct f77_boolean_val boolean_values
[] =
1733 static const struct token f77_keywords
[] =
1735 { "complex_16", COMPLEX_S16_KEYWORD
, BINOP_END
},
1736 { "complex_32", COMPLEX_S32_KEYWORD
, BINOP_END
},
1737 { "character", CHARACTER
, BINOP_END
},
1738 { "integer_2", INT_S2_KEYWORD
, BINOP_END
},
1739 { "logical_1", LOGICAL_S1_KEYWORD
, BINOP_END
},
1740 { "logical_2", LOGICAL_S2_KEYWORD
, BINOP_END
},
1741 { "complex_8", COMPLEX_S8_KEYWORD
, BINOP_END
},
1742 { "integer", INT_KEYWORD
, BINOP_END
},
1743 { "logical", LOGICAL_KEYWORD
, BINOP_END
},
1744 { "real_16", REAL_S16_KEYWORD
, BINOP_END
},
1745 { "complex", COMPLEX_S8_KEYWORD
, BINOP_END
},
1746 { "sizeof", SIZEOF
, BINOP_END
},
1747 { "real_8", REAL_S8_KEYWORD
, BINOP_END
},
1748 { "real", REAL_KEYWORD
, BINOP_END
},
1752 /* Implementation of a dynamically expandable buffer for processing input
1753 characters acquired through lexptr and building a value to return in
1754 yylval. Ripped off from ch-exp.y */
1756 static char *tempbuf
; /* Current buffer contents */
1757 static int tempbufsize
; /* Size of allocated buffer */
1758 static int tempbufindex
; /* Current index into buffer */
1760 #define GROWBY_MIN_SIZE 64 /* Minimum amount to grow buffer by */
1762 #define CHECKBUF(size) \
1764 if (tempbufindex + (size) >= tempbufsize) \
1766 growbuf_by_size (size); \
1771 /* Grow the static temp buffer if necessary, including allocating the first one
1775 growbuf_by_size (count
)
1780 growby
= max (count
, GROWBY_MIN_SIZE
);
1781 tempbufsize
+= growby
;
1782 if (tempbuf
== NULL
)
1783 tempbuf
= (char *) xmalloc (tempbufsize
);
1785 tempbuf
= (char *) xrealloc (tempbuf
, tempbufsize
);
1788 /* Blatantly ripped off from ch-exp.y. This routine recognizes F77
1791 Recognize a string literal. A string literal is a nonzero sequence
1792 of characters enclosed in matching single quotes, except that
1793 a single character inside single quotes is a character literal, which
1794 we reject as a string literal. To embed the terminator character inside
1795 a string, it is simply doubled (I.E. 'this''is''one''string') */
1798 match_string_literal ()
1800 char *tokptr
= lexptr
;
1802 for (tempbufindex
= 0, tokptr
++; *tokptr
!= '\0'; tokptr
++)
1805 if (*tokptr
== *lexptr
)
1807 if (*(tokptr
+ 1) == *lexptr
)
1812 tempbuf
[tempbufindex
++] = *tokptr
;
1814 if (*tokptr
== '\0' /* no terminator */
1815 || tempbufindex
== 0) /* no string */
1819 tempbuf
[tempbufindex
] = '\0';
1820 yylval
.sval
.ptr
= tempbuf
;
1821 yylval
.sval
.length
= tempbufindex
;
1823 return STRING_LITERAL
;
1827 /* Read one token, getting characters through lexptr. */
1834 unsigned int i
,token
;
1841 /* First of all, let us make sure we are not dealing with the
1842 special tokens .true. and .false. which evaluate to 1 and 0. */
1846 for (i
= 0; boolean_values
[i
].name
!= NULL
; i
++)
1848 if STREQN (tokstart
, boolean_values
[i
].name
,
1849 strlen (boolean_values
[i
].name
))
1851 lexptr
+= strlen (boolean_values
[i
].name
);
1852 yylval
.lval
= boolean_values
[i
].value
;
1853 return BOOLEAN_LITERAL
;
1858 /* See if it is a special .foo. operator */
1860 for (i
= 0; dot_ops
[i
].operator != NULL
; i
++)
1861 if (STREQN (tokstart
, dot_ops
[i
].operator, strlen (dot_ops
[i
].operator)))
1863 lexptr
+= strlen (dot_ops
[i
].operator);
1864 yylval
.opcode
= dot_ops
[i
].opcode
;
1865 return dot_ops
[i
].token
;
1868 switch (c
= *tokstart
)
1880 token
= match_string_literal ();
1891 if (paren_depth
== 0)
1898 if (comma_terminates
&& paren_depth
== 0)
1904 /* Might be a floating point number. */
1905 if (lexptr
[1] < '0' || lexptr
[1] > '9')
1906 goto symbol
; /* Nope, must be a symbol. */
1907 /* FALL THRU into number case. */
1920 /* It's a number. */
1921 int got_dot
= 0, got_e
= 0, got_d
= 0, toktype
;
1922 register char *p
= tokstart
;
1923 int hex
= input_radix
> 10;
1925 if (c
== '0' && (p
[1] == 'x' || p
[1] == 'X'))
1930 else if (c
== '0' && (p
[1]=='t' || p
[1]=='T' || p
[1]=='d' || p
[1]=='D'))
1938 if (!hex
&& !got_e
&& (*p
== 'e' || *p
== 'E'))
1939 got_dot
= got_e
= 1;
1940 else if (!hex
&& !got_d
&& (*p
== 'd' || *p
== 'D'))
1941 got_dot
= got_d
= 1;
1942 else if (!hex
&& !got_dot
&& *p
== '.')
1944 else if (((got_e
&& (p
[-1] == 'e' || p
[-1] == 'E'))
1945 || (got_d
&& (p
[-1] == 'd' || p
[-1] == 'D')))
1946 && (*p
== '-' || *p
== '+'))
1947 /* This is the sign of the exponent, not the end of the
1950 /* We will take any letters or digits. parse_number will
1951 complain if past the radix, or if L or U are not final. */
1952 else if ((*p
< '0' || *p
> '9')
1953 && ((*p
< 'a' || *p
> 'z')
1954 && (*p
< 'A' || *p
> 'Z')))
1957 toktype
= parse_number (tokstart
, p
- tokstart
, got_dot
|got_e
|got_d
,
1959 if (toktype
== ERROR
)
1961 char *err_copy
= (char *) alloca (p
- tokstart
+ 1);
1963 memcpy (err_copy
, tokstart
, p
- tokstart
);
1964 err_copy
[p
- tokstart
] = 0;
1965 error ("Invalid number \"%s\".", err_copy
);
1996 if (!(c
== '_' || c
== '$'
1997 || (c
>= 'a' && c
<= 'z') || (c
>= 'A' && c
<= 'Z')))
1998 /* We must have come across a bad character (e.g. ';'). */
1999 error ("Invalid character '%c' in expression.", c
);
2002 for (c
= tokstart
[namelen
];
2003 (c
== '_' || c
== '$' || (c
>= '0' && c
<= '9')
2004 || (c
>= 'a' && c
<= 'z') || (c
>= 'A' && c
<= 'Z'));
2005 c
= tokstart
[++namelen
]);
2007 /* The token "if" terminates the expression and is NOT
2008 removed from the input stream. */
2010 if (namelen
== 2 && tokstart
[0] == 'i' && tokstart
[1] == 'f')
2015 /* Catch specific keywords. */
2017 for (i
= 0; f77_keywords
[i
].operator != NULL
; i
++)
2018 if (STREQN(tokstart
, f77_keywords
[i
].operator,
2019 strlen(f77_keywords
[i
].operator)))
2021 /* lexptr += strlen(f77_keywords[i].operator); */
2022 yylval
.opcode
= f77_keywords
[i
].opcode
;
2023 return f77_keywords
[i
].token
;
2026 yylval
.sval
.ptr
= tokstart
;
2027 yylval
.sval
.length
= namelen
;
2029 if (*tokstart
== '$')
2031 write_dollar_variable (yylval
.sval
);
2035 /* Use token-type TYPENAME for symbols that happen to be defined
2036 currently as names of types; NAME for other symbols.
2037 The caller is not constrained to care about the distinction. */
2039 char *tmp
= copy_name (yylval
.sval
);
2041 int is_a_field_of_this
= 0;
2044 sym
= lookup_symbol (tmp
, expression_context_block
,
2046 current_language
->la_language
== language_cplus
2047 ? &is_a_field_of_this
: NULL
,
2049 if (sym
&& SYMBOL_CLASS (sym
) == LOC_TYPEDEF
)
2051 yylval
.tsym
.type
= SYMBOL_TYPE (sym
);
2054 if ((yylval
.tsym
.type
= lookup_primitive_typename (tmp
)) != 0)
2057 /* Input names that aren't symbols but ARE valid hex numbers,
2058 when the input radix permits them, can be names or numbers
2059 depending on the parse. Note we support radixes > 16 here. */
2061 && ((tokstart
[0] >= 'a' && tokstart
[0] < 'a' + input_radix
- 10)
2062 || (tokstart
[0] >= 'A' && tokstart
[0] < 'A' + input_radix
- 10)))
2064 YYSTYPE newlval
; /* Its value is ignored. */
2065 hextype
= parse_number (tokstart
, namelen
, 0, &newlval
);
2068 yylval
.ssym
.sym
= sym
;
2069 yylval
.ssym
.is_a_field_of_this
= is_a_field_of_this
;
2074 /* Any other kind of symbol */
2075 yylval
.ssym
.sym
= sym
;
2076 yylval
.ssym
.is_a_field_of_this
= is_a_field_of_this
;
2085 error ("A %s in expression, near `%s'.", (msg
? msg
: "error"), lexptr
);