Commit | Line | Data |
---|---|---|
0c9c3474 | 1 | |
c906108c | 2 | /* YACC parser for Fortran expressions, for GDB. |
3666a048 | 3 | Copyright (C) 1986-2021 Free Software Foundation, Inc. |
4fcf66da | 4 | |
c906108c SS |
5 | Contributed by Motorola. Adapted from the C parser by Farooq Butt |
6 | (fmbutt@engage.sps.mot.com). | |
7 | ||
5b1ba0e5 | 8 | This file is part of GDB. |
c906108c | 9 | |
5b1ba0e5 NS |
10 | This program is free software; you can redistribute it and/or modify |
11 | it under the terms of the GNU General Public License as published by | |
12 | the Free Software Foundation; either version 3 of the License, or | |
13 | (at your option) any later version. | |
c906108c | 14 | |
5b1ba0e5 NS |
15 | This program is distributed in the hope that it will be useful, |
16 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 | GNU General Public License for more details. | |
c906108c | 19 | |
5b1ba0e5 NS |
20 | You should have received a copy of the GNU General Public License |
21 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ | |
c906108c SS |
22 | |
23 | /* This was blantantly ripped off the C expression parser, please | |
24 | be aware of that as you look at its basic structure -FMB */ | |
25 | ||
26 | /* Parse a F77 expression from text in a string, | |
27 | and return the result as a struct expression pointer. | |
28 | That structure contains arithmetic operations in reverse polish, | |
29 | with constants represented by operations that are followed by special data. | |
30 | See expression.h for the details of the format. | |
31 | What is important here is that it can be built up sequentially | |
32 | during the process of parsing; the lower levels of the tree always | |
33 | come first in the result. | |
34 | ||
35 | Note that malloc's and realloc's in this file are transformed to | |
36 | xmalloc and xrealloc respectively by the same sed command in the | |
37 | makefile that remaps any other malloc/realloc inserted by the parser | |
38 | generator. Doing this with #defines and trying to control the interaction | |
39 | with include files (<malloc.h> and <stdlib.h> for example) just became | |
40 | too messy, particularly when such includes can be inserted at random | |
41 | times by the parser generator. */ | |
42 | ||
43 | %{ | |
44 | ||
45 | #include "defs.h" | |
c906108c SS |
46 | #include "expression.h" |
47 | #include "value.h" | |
48 | #include "parser-defs.h" | |
49 | #include "language.h" | |
50 | #include "f-lang.h" | |
51 | #include "bfd.h" /* Required by objfiles.h. */ | |
52 | #include "symfile.h" /* Required by objfiles.h. */ | |
53 | #include "objfiles.h" /* For have_full_symbols and have_partial_symbols */ | |
fe898f56 | 54 | #include "block.h" |
0f6e1ba6 | 55 | #include <ctype.h> |
325fac50 | 56 | #include <algorithm> |
dac43e32 | 57 | #include "type-stack.h" |
d308ba78 | 58 | #include "f-exp.h" |
c906108c | 59 | |
fa9f5be6 TT |
60 | #define parse_type(ps) builtin_type (ps->gdbarch ()) |
61 | #define parse_f_type(ps) builtin_f_type (ps->gdbarch ()) | |
3e79cecf | 62 | |
b3f11165 PA |
63 | /* Remap normal yacc parser interface names (yyparse, yylex, yyerror, |
64 | etc). */ | |
65 | #define GDB_YY_REMAP_PREFIX f_ | |
66 | #include "yy-remap.h" | |
f461f5cf | 67 | |
410a0ff2 SDJ |
68 | /* The state of the parser, used internally when we are parsing the |
69 | expression. */ | |
70 | ||
71 | static struct parser_state *pstate = NULL; | |
72 | ||
28aaf3fd TT |
73 | /* Depth of parentheses. */ |
74 | static int paren_depth; | |
75 | ||
dac43e32 TT |
76 | /* The current type stack. */ |
77 | static struct type_stack *type_stack; | |
78 | ||
a14ed312 | 79 | int yyparse (void); |
c906108c | 80 | |
a14ed312 | 81 | static int yylex (void); |
c906108c | 82 | |
69d340c6 | 83 | static void yyerror (const char *); |
c906108c | 84 | |
a14ed312 | 85 | static void growbuf_by_size (int); |
c906108c | 86 | |
a14ed312 | 87 | static int match_string_literal (void); |
c906108c | 88 | |
4d00f5d8 AB |
89 | static void push_kind_type (LONGEST val, struct type *type); |
90 | ||
91 | static struct type *convert_to_kind_type (struct type *basetype, int kind); | |
92 | ||
d308ba78 | 93 | using namespace expr; |
c906108c SS |
94 | %} |
95 | ||
96 | /* Although the yacc "value" of an expression is not used, | |
97 | since the result is stored in the structure being created, | |
98 | other node types do have values. */ | |
99 | ||
100 | %union | |
101 | { | |
102 | LONGEST lval; | |
103 | struct { | |
104 | LONGEST val; | |
105 | struct type *type; | |
106 | } typed_val; | |
edd079d9 UW |
107 | struct { |
108 | gdb_byte val[16]; | |
109 | struct type *type; | |
110 | } typed_val_float; | |
c906108c SS |
111 | struct symbol *sym; |
112 | struct type *tval; | |
113 | struct stoken sval; | |
114 | struct ttype tsym; | |
115 | struct symtoken ssym; | |
116 | int voidval; | |
c906108c SS |
117 | enum exp_opcode opcode; |
118 | struct internalvar *ivar; | |
119 | ||
120 | struct type **tvec; | |
121 | int *ivec; | |
122 | } | |
123 | ||
124 | %{ | |
125 | /* YYSTYPE gets defined by %union */ | |
410a0ff2 SDJ |
126 | static int parse_number (struct parser_state *, const char *, int, |
127 | int, YYSTYPE *); | |
c906108c SS |
128 | %} |
129 | ||
130 | %type <voidval> exp type_exp start variable | |
131 | %type <tval> type typebase | |
132 | %type <tvec> nonempty_typelist | |
133 | /* %type <bval> block */ | |
134 | ||
135 | /* Fancy type parsing. */ | |
136 | %type <voidval> func_mod direct_abs_decl abs_decl | |
137 | %type <tval> ptype | |
138 | ||
139 | %token <typed_val> INT | |
edd079d9 | 140 | %token <typed_val_float> FLOAT |
c906108c SS |
141 | |
142 | /* Both NAME and TYPENAME tokens represent symbols in the input, | |
143 | and both convey their data as strings. | |
144 | But a TYPENAME is a string that happens to be defined as a typedef | |
145 | or builtin type name (such as int or char) | |
146 | and a NAME is any other symbol. | |
147 | Contexts where this distinction is not important can use the | |
148 | nonterminal "name", which matches either NAME or TYPENAME. */ | |
149 | ||
150 | %token <sval> STRING_LITERAL | |
151 | %token <lval> BOOLEAN_LITERAL | |
152 | %token <ssym> NAME | |
153 | %token <tsym> TYPENAME | |
9dd02fc0 | 154 | %token <voidval> COMPLETE |
2a5e440c | 155 | %type <sval> name |
c906108c | 156 | %type <ssym> name_not_typename |
c906108c SS |
157 | |
158 | /* A NAME_OR_INT is a symbol which is not known in the symbol table, | |
159 | but which would parse as a valid number in the current input radix. | |
160 | E.g. "c" when input_radix==16. Depending on the parse, it will be | |
161 | turned into a name or into a number. */ | |
162 | ||
163 | %token <ssym> NAME_OR_INT | |
164 | ||
4d00f5d8 | 165 | %token SIZEOF KIND |
c906108c SS |
166 | %token ERROR |
167 | ||
168 | /* Special type cases, put in to allow the parser to distinguish different | |
169 | legal basetypes. */ | |
170 | %token INT_KEYWORD INT_S2_KEYWORD LOGICAL_S1_KEYWORD LOGICAL_S2_KEYWORD | |
ce4b0682 | 171 | %token LOGICAL_S8_KEYWORD |
c906108c | 172 | %token LOGICAL_KEYWORD REAL_KEYWORD REAL_S8_KEYWORD REAL_S16_KEYWORD |
36c8fb93 | 173 | %token COMPLEX_KEYWORD |
c906108c SS |
174 | %token COMPLEX_S8_KEYWORD COMPLEX_S16_KEYWORD COMPLEX_S32_KEYWORD |
175 | %token BOOL_AND BOOL_OR BOOL_NOT | |
36c8fb93 | 176 | %token SINGLE DOUBLE PRECISION |
c906108c SS |
177 | %token <lval> CHARACTER |
178 | ||
02c72701 | 179 | %token <sval> DOLLAR_VARIABLE |
c906108c SS |
180 | |
181 | %token <opcode> ASSIGN_MODIFY | |
b6d03bb2 | 182 | %token <opcode> UNOP_INTRINSIC BINOP_INTRINSIC |
e92c8eb8 | 183 | %token <opcode> UNOP_OR_BINOP_INTRINSIC |
c906108c SS |
184 | |
185 | %left ',' | |
186 | %left ABOVE_COMMA | |
187 | %right '=' ASSIGN_MODIFY | |
188 | %right '?' | |
189 | %left BOOL_OR | |
190 | %right BOOL_NOT | |
191 | %left BOOL_AND | |
192 | %left '|' | |
193 | %left '^' | |
194 | %left '&' | |
195 | %left EQUAL NOTEQUAL | |
196 | %left LESSTHAN GREATERTHAN LEQ GEQ | |
197 | %left LSH RSH | |
198 | %left '@' | |
199 | %left '+' '-' | |
2a5e440c | 200 | %left '*' '/' |
bd49c137 | 201 | %right STARSTAR |
2a5e440c | 202 | %right '%' |
c906108c SS |
203 | %right UNARY |
204 | %right '(' | |
205 | ||
206 | \f | |
207 | %% | |
208 | ||
209 | start : exp | |
210 | | type_exp | |
211 | ; | |
212 | ||
213 | type_exp: type | |
d308ba78 | 214 | { pstate->push_new<type_operation> ($1); } |
c906108c SS |
215 | ; |
216 | ||
217 | exp : '(' exp ')' | |
dda83cd7 SM |
218 | { } |
219 | ; | |
c906108c SS |
220 | |
221 | /* Expressions, not including the comma operator. */ | |
222 | exp : '*' exp %prec UNARY | |
d308ba78 | 223 | { pstate->wrap<unop_ind_operation> (); } |
ef944135 | 224 | ; |
c906108c SS |
225 | |
226 | exp : '&' exp %prec UNARY | |
d308ba78 | 227 | { pstate->wrap<unop_addr_operation> (); } |
ef944135 | 228 | ; |
c906108c SS |
229 | |
230 | exp : '-' exp %prec UNARY | |
d308ba78 | 231 | { pstate->wrap<unary_neg_operation> (); } |
c906108c SS |
232 | ; |
233 | ||
234 | exp : BOOL_NOT exp %prec UNARY | |
d308ba78 | 235 | { pstate->wrap<unary_logical_not_operation> (); } |
c906108c SS |
236 | ; |
237 | ||
238 | exp : '~' exp %prec UNARY | |
d308ba78 | 239 | { pstate->wrap<unary_complement_operation> (); } |
c906108c SS |
240 | ; |
241 | ||
242 | exp : SIZEOF exp %prec UNARY | |
d308ba78 | 243 | { pstate->wrap<unop_sizeof_operation> (); } |
c906108c SS |
244 | ; |
245 | ||
4d00f5d8 | 246 | exp : KIND '(' exp ')' %prec UNARY |
d308ba78 | 247 | { pstate->wrap<fortran_kind_operation> (); } |
4d00f5d8 AB |
248 | ; |
249 | ||
e92c8eb8 AB |
250 | exp : UNOP_OR_BINOP_INTRINSIC '(' |
251 | { pstate->start_arglist (); } | |
252 | one_or_two_args ')' | |
d308ba78 TT |
253 | { |
254 | int n = pstate->end_arglist (); | |
255 | gdb_assert (n == 1 || n == 2); | |
256 | if ($1 == FORTRAN_ASSOCIATED) | |
257 | { | |
258 | if (n == 1) | |
259 | pstate->wrap<fortran_associated_1arg> (); | |
260 | else | |
261 | pstate->wrap2<fortran_associated_2arg> (); | |
262 | } | |
7ba155b3 AB |
263 | else if ($1 == FORTRAN_ARRAY_SIZE) |
264 | { | |
265 | if (n == 1) | |
266 | pstate->wrap<fortran_array_size_1arg> (); | |
267 | else | |
268 | pstate->wrap2<fortran_array_size_2arg> (); | |
269 | } | |
d308ba78 TT |
270 | else |
271 | { | |
272 | std::vector<operation_up> args | |
273 | = pstate->pop_vector (n); | |
274 | gdb_assert ($1 == FORTRAN_LBOUND | |
275 | || $1 == FORTRAN_UBOUND); | |
276 | operation_up op; | |
277 | if (n == 1) | |
278 | op.reset | |
279 | (new fortran_bound_1arg ($1, | |
280 | std::move (args[0]))); | |
281 | else | |
282 | op.reset | |
283 | (new fortran_bound_2arg ($1, | |
284 | std::move (args[0]), | |
285 | std::move (args[1]))); | |
286 | pstate->push (std::move (op)); | |
287 | } | |
288 | } | |
e92c8eb8 AB |
289 | ; |
290 | ||
291 | one_or_two_args | |
292 | : exp | |
293 | { pstate->arglist_len = 1; } | |
294 | | exp ',' exp | |
295 | { pstate->arglist_len = 2; } | |
296 | ; | |
297 | ||
c906108c SS |
298 | /* No more explicit array operators, we treat everything in F77 as |
299 | a function call. The disambiguation as to whether we are | |
300 | doing a subscript operation or a function call is done | |
301 | later in eval.c. */ | |
302 | ||
303 | exp : exp '(' | |
43476f0b | 304 | { pstate->start_arglist (); } |
c906108c | 305 | arglist ')' |
d308ba78 TT |
306 | { |
307 | std::vector<operation_up> args | |
308 | = pstate->pop_vector (pstate->end_arglist ()); | |
309 | pstate->push_new<fortran_undetermined> | |
310 | (pstate->pop (), std::move (args)); | |
311 | } | |
c906108c SS |
312 | ; |
313 | ||
0841c79a | 314 | exp : UNOP_INTRINSIC '(' exp ')' |
d308ba78 TT |
315 | { |
316 | switch ($1) | |
317 | { | |
318 | case UNOP_ABS: | |
319 | pstate->wrap<fortran_abs_operation> (); | |
320 | break; | |
321 | case UNOP_FORTRAN_FLOOR: | |
322 | pstate->wrap<fortran_floor_operation> (); | |
323 | break; | |
324 | case UNOP_FORTRAN_CEILING: | |
325 | pstate->wrap<fortran_ceil_operation> (); | |
326 | break; | |
327 | case UNOP_FORTRAN_ALLOCATED: | |
328 | pstate->wrap<fortran_allocated_operation> (); | |
329 | break; | |
e14816a8 AB |
330 | case UNOP_FORTRAN_RANK: |
331 | pstate->wrap<fortran_rank_operation> (); | |
332 | break; | |
eef32f59 AB |
333 | case UNOP_FORTRAN_SHAPE: |
334 | pstate->wrap<fortran_array_shape_operation> (); | |
335 | break; | |
611aa09d FW |
336 | case UNOP_FORTRAN_LOC: |
337 | pstate->wrap<fortran_loc_operation> (); | |
338 | break; | |
d308ba78 TT |
339 | default: |
340 | gdb_assert_not_reached ("unhandled intrinsic"); | |
341 | } | |
342 | } | |
0841c79a AB |
343 | ; |
344 | ||
b6d03bb2 | 345 | exp : BINOP_INTRINSIC '(' exp ',' exp ')' |
d308ba78 TT |
346 | { |
347 | switch ($1) | |
348 | { | |
349 | case BINOP_MOD: | |
350 | pstate->wrap2<fortran_mod_operation> (); | |
351 | break; | |
352 | case BINOP_FORTRAN_MODULO: | |
353 | pstate->wrap2<fortran_modulo_operation> (); | |
354 | break; | |
355 | case BINOP_FORTRAN_CMPLX: | |
356 | pstate->wrap2<fortran_cmplx_operation> (); | |
357 | break; | |
358 | default: | |
359 | gdb_assert_not_reached ("unhandled intrinsic"); | |
360 | } | |
361 | } | |
b6d03bb2 AB |
362 | ; |
363 | ||
c906108c SS |
364 | arglist : |
365 | ; | |
366 | ||
367 | arglist : exp | |
43476f0b | 368 | { pstate->arglist_len = 1; } |
c906108c SS |
369 | ; |
370 | ||
0b4e1325 | 371 | arglist : subrange |
43476f0b | 372 | { pstate->arglist_len = 1; } |
ef944135 | 373 | ; |
c906108c SS |
374 | |
375 | arglist : arglist ',' exp %prec ABOVE_COMMA | |
43476f0b | 376 | { pstate->arglist_len++; } |
c906108c SS |
377 | ; |
378 | ||
6b4c676c AB |
379 | arglist : arglist ',' subrange %prec ABOVE_COMMA |
380 | { pstate->arglist_len++; } | |
381 | ; | |
382 | ||
0b4e1325 WZ |
383 | /* There are four sorts of subrange types in F90. */ |
384 | ||
385 | subrange: exp ':' exp %prec ABOVE_COMMA | |
d308ba78 TT |
386 | { |
387 | operation_up high = pstate->pop (); | |
388 | operation_up low = pstate->pop (); | |
389 | pstate->push_new<fortran_range_operation> | |
390 | (RANGE_STANDARD, std::move (low), | |
391 | std::move (high), operation_up ()); | |
392 | } | |
0b4e1325 WZ |
393 | ; |
394 | ||
395 | subrange: exp ':' %prec ABOVE_COMMA | |
d308ba78 TT |
396 | { |
397 | operation_up low = pstate->pop (); | |
398 | pstate->push_new<fortran_range_operation> | |
399 | (RANGE_HIGH_BOUND_DEFAULT, std::move (low), | |
400 | operation_up (), operation_up ()); | |
401 | } | |
c906108c SS |
402 | ; |
403 | ||
0b4e1325 | 404 | subrange: ':' exp %prec ABOVE_COMMA |
d308ba78 TT |
405 | { |
406 | operation_up high = pstate->pop (); | |
407 | pstate->push_new<fortran_range_operation> | |
408 | (RANGE_LOW_BOUND_DEFAULT, operation_up (), | |
409 | std::move (high), operation_up ()); | |
410 | } | |
0b4e1325 WZ |
411 | ; |
412 | ||
413 | subrange: ':' %prec ABOVE_COMMA | |
d308ba78 TT |
414 | { |
415 | pstate->push_new<fortran_range_operation> | |
416 | (RANGE_LOW_BOUND_DEFAULT | |
417 | | RANGE_HIGH_BOUND_DEFAULT, | |
418 | operation_up (), operation_up (), | |
419 | operation_up ()); | |
420 | } | |
0b4e1325 | 421 | ; |
c906108c | 422 | |
6b4c676c AB |
423 | /* And each of the four subrange types can also have a stride. */ |
424 | subrange: exp ':' exp ':' exp %prec ABOVE_COMMA | |
d308ba78 TT |
425 | { |
426 | operation_up stride = pstate->pop (); | |
427 | operation_up high = pstate->pop (); | |
428 | operation_up low = pstate->pop (); | |
429 | pstate->push_new<fortran_range_operation> | |
430 | (RANGE_STANDARD | RANGE_HAS_STRIDE, | |
431 | std::move (low), std::move (high), | |
432 | std::move (stride)); | |
433 | } | |
6b4c676c AB |
434 | ; |
435 | ||
436 | subrange: exp ':' ':' exp %prec ABOVE_COMMA | |
d308ba78 TT |
437 | { |
438 | operation_up stride = pstate->pop (); | |
439 | operation_up low = pstate->pop (); | |
440 | pstate->push_new<fortran_range_operation> | |
441 | (RANGE_HIGH_BOUND_DEFAULT | |
442 | | RANGE_HAS_STRIDE, | |
443 | std::move (low), operation_up (), | |
444 | std::move (stride)); | |
445 | } | |
6b4c676c AB |
446 | ; |
447 | ||
448 | subrange: ':' exp ':' exp %prec ABOVE_COMMA | |
d308ba78 TT |
449 | { |
450 | operation_up stride = pstate->pop (); | |
451 | operation_up high = pstate->pop (); | |
452 | pstate->push_new<fortran_range_operation> | |
453 | (RANGE_LOW_BOUND_DEFAULT | |
454 | | RANGE_HAS_STRIDE, | |
455 | operation_up (), std::move (high), | |
456 | std::move (stride)); | |
457 | } | |
6b4c676c AB |
458 | ; |
459 | ||
460 | subrange: ':' ':' exp %prec ABOVE_COMMA | |
d308ba78 TT |
461 | { |
462 | operation_up stride = pstate->pop (); | |
463 | pstate->push_new<fortran_range_operation> | |
464 | (RANGE_LOW_BOUND_DEFAULT | |
465 | | RANGE_HIGH_BOUND_DEFAULT | |
466 | | RANGE_HAS_STRIDE, | |
467 | operation_up (), operation_up (), | |
468 | std::move (stride)); | |
469 | } | |
6b4c676c AB |
470 | ; |
471 | ||
c906108c | 472 | complexnum: exp ',' exp |
dda83cd7 SM |
473 | { } |
474 | ; | |
c906108c SS |
475 | |
476 | exp : '(' complexnum ')' | |
d308ba78 TT |
477 | { |
478 | operation_up rhs = pstate->pop (); | |
479 | operation_up lhs = pstate->pop (); | |
480 | pstate->push_new<complex_operation> | |
481 | (std::move (lhs), std::move (rhs), | |
482 | parse_f_type (pstate)->builtin_complex_s16); | |
483 | } | |
c906108c SS |
484 | ; |
485 | ||
486 | exp : '(' type ')' exp %prec UNARY | |
d308ba78 TT |
487 | { |
488 | pstate->push_new<unop_cast_operation> | |
489 | (pstate->pop (), $2); | |
490 | } | |
c906108c SS |
491 | ; |
492 | ||
2a5e440c | 493 | exp : exp '%' name |
d308ba78 TT |
494 | { |
495 | pstate->push_new<structop_operation> | |
496 | (pstate->pop (), copy_name ($3)); | |
497 | } | |
dda83cd7 | 498 | ; |
2a5e440c | 499 | |
9dd02fc0 | 500 | exp : exp '%' name COMPLETE |
d308ba78 TT |
501 | { |
502 | structop_base_operation *op | |
503 | = new structop_operation (pstate->pop (), | |
504 | copy_name ($3)); | |
505 | pstate->mark_struct_expression (op); | |
506 | pstate->push (operation_up (op)); | |
507 | } | |
9dd02fc0 AB |
508 | ; |
509 | ||
510 | exp : exp '%' COMPLETE | |
d308ba78 TT |
511 | { |
512 | structop_base_operation *op | |
513 | = new structop_operation (pstate->pop (), ""); | |
514 | pstate->mark_struct_expression (op); | |
515 | pstate->push (operation_up (op)); | |
516 | } | |
517 | ; | |
9dd02fc0 | 518 | |
c906108c SS |
519 | /* Binary operators in order of decreasing precedence. */ |
520 | ||
521 | exp : exp '@' exp | |
d308ba78 | 522 | { pstate->wrap2<repeat_operation> (); } |
c906108c SS |
523 | ; |
524 | ||
bd49c137 | 525 | exp : exp STARSTAR exp |
d308ba78 | 526 | { pstate->wrap2<exp_operation> (); } |
bd49c137 WZ |
527 | ; |
528 | ||
c906108c | 529 | exp : exp '*' exp |
d308ba78 | 530 | { pstate->wrap2<mul_operation> (); } |
c906108c SS |
531 | ; |
532 | ||
533 | exp : exp '/' exp | |
d308ba78 | 534 | { pstate->wrap2<div_operation> (); } |
c906108c SS |
535 | ; |
536 | ||
c906108c | 537 | exp : exp '+' exp |
d308ba78 | 538 | { pstate->wrap2<add_operation> (); } |
c906108c SS |
539 | ; |
540 | ||
541 | exp : exp '-' exp | |
d308ba78 | 542 | { pstate->wrap2<sub_operation> (); } |
c906108c SS |
543 | ; |
544 | ||
545 | exp : exp LSH exp | |
d308ba78 | 546 | { pstate->wrap2<lsh_operation> (); } |
c906108c SS |
547 | ; |
548 | ||
549 | exp : exp RSH exp | |
d308ba78 | 550 | { pstate->wrap2<rsh_operation> (); } |
c906108c SS |
551 | ; |
552 | ||
553 | exp : exp EQUAL exp | |
d308ba78 | 554 | { pstate->wrap2<equal_operation> (); } |
c906108c SS |
555 | ; |
556 | ||
557 | exp : exp NOTEQUAL exp | |
d308ba78 | 558 | { pstate->wrap2<notequal_operation> (); } |
c906108c SS |
559 | ; |
560 | ||
561 | exp : exp LEQ exp | |
d308ba78 | 562 | { pstate->wrap2<leq_operation> (); } |
c906108c SS |
563 | ; |
564 | ||
565 | exp : exp GEQ exp | |
d308ba78 | 566 | { pstate->wrap2<geq_operation> (); } |
c906108c SS |
567 | ; |
568 | ||
569 | exp : exp LESSTHAN exp | |
d308ba78 | 570 | { pstate->wrap2<less_operation> (); } |
c906108c SS |
571 | ; |
572 | ||
573 | exp : exp GREATERTHAN exp | |
d308ba78 | 574 | { pstate->wrap2<gtr_operation> (); } |
c906108c SS |
575 | ; |
576 | ||
577 | exp : exp '&' exp | |
d308ba78 | 578 | { pstate->wrap2<bitwise_and_operation> (); } |
c906108c SS |
579 | ; |
580 | ||
581 | exp : exp '^' exp | |
d308ba78 | 582 | { pstate->wrap2<bitwise_xor_operation> (); } |
c906108c SS |
583 | ; |
584 | ||
585 | exp : exp '|' exp | |
d308ba78 | 586 | { pstate->wrap2<bitwise_ior_operation> (); } |
c906108c SS |
587 | ; |
588 | ||
589 | exp : exp BOOL_AND exp | |
d308ba78 | 590 | { pstate->wrap2<logical_and_operation> (); } |
c906108c SS |
591 | ; |
592 | ||
593 | ||
594 | exp : exp BOOL_OR exp | |
d308ba78 | 595 | { pstate->wrap2<logical_or_operation> (); } |
c906108c SS |
596 | ; |
597 | ||
598 | exp : exp '=' exp | |
d308ba78 | 599 | { pstate->wrap2<assign_operation> (); } |
c906108c SS |
600 | ; |
601 | ||
602 | exp : exp ASSIGN_MODIFY exp | |
d308ba78 TT |
603 | { |
604 | operation_up rhs = pstate->pop (); | |
605 | operation_up lhs = pstate->pop (); | |
606 | pstate->push_new<assign_modify_operation> | |
607 | ($2, std::move (lhs), std::move (rhs)); | |
608 | } | |
c906108c SS |
609 | ; |
610 | ||
611 | exp : INT | |
d308ba78 TT |
612 | { |
613 | pstate->push_new<long_const_operation> | |
614 | ($1.type, $1.val); | |
615 | } | |
c906108c SS |
616 | ; |
617 | ||
618 | exp : NAME_OR_INT | |
619 | { YYSTYPE val; | |
410a0ff2 SDJ |
620 | parse_number (pstate, $1.stoken.ptr, |
621 | $1.stoken.length, 0, &val); | |
d308ba78 TT |
622 | pstate->push_new<long_const_operation> |
623 | (val.typed_val.type, | |
624 | val.typed_val.val); | |
625 | } | |
c906108c SS |
626 | ; |
627 | ||
628 | exp : FLOAT | |
d308ba78 TT |
629 | { |
630 | float_data data; | |
631 | std::copy (std::begin ($1.val), std::end ($1.val), | |
632 | std::begin (data)); | |
633 | pstate->push_new<float_const_operation> ($1.type, data); | |
634 | } | |
c906108c SS |
635 | ; |
636 | ||
637 | exp : variable | |
638 | ; | |
639 | ||
cfeadda5 | 640 | exp : DOLLAR_VARIABLE |
d308ba78 | 641 | { pstate->push_dollar ($1); } |
c906108c SS |
642 | ; |
643 | ||
644 | exp : SIZEOF '(' type ')' %prec UNARY | |
d308ba78 | 645 | { |
f168693b | 646 | $3 = check_typedef ($3); |
d308ba78 TT |
647 | pstate->push_new<long_const_operation> |
648 | (parse_f_type (pstate)->builtin_integer, | |
649 | TYPE_LENGTH ($3)); | |
650 | } | |
c906108c SS |
651 | ; |
652 | ||
653 | exp : BOOLEAN_LITERAL | |
d308ba78 | 654 | { pstate->push_new<bool_operation> ($1); } |
dda83cd7 | 655 | ; |
c906108c SS |
656 | |
657 | exp : STRING_LITERAL | |
658 | { | |
d308ba78 TT |
659 | pstate->push_new<string_operation> |
660 | (copy_name ($1)); | |
c906108c SS |
661 | } |
662 | ; | |
663 | ||
664 | variable: name_not_typename | |
d12307c1 | 665 | { struct block_symbol sym = $1.sym; |
1b30f421 | 666 | std::string name = copy_name ($1.stoken); |
d308ba78 | 667 | pstate->push_symbol (name.c_str (), sym); |
c906108c SS |
668 | } |
669 | ; | |
670 | ||
671 | ||
672 | type : ptype | |
dda83cd7 | 673 | ; |
c906108c SS |
674 | |
675 | ptype : typebase | |
676 | | typebase abs_decl | |
677 | { | |
678 | /* This is where the interesting stuff happens. */ | |
679 | int done = 0; | |
680 | int array_size; | |
681 | struct type *follow_type = $1; | |
682 | struct type *range_type; | |
683 | ||
684 | while (!done) | |
dac43e32 | 685 | switch (type_stack->pop ()) |
c906108c SS |
686 | { |
687 | case tp_end: | |
688 | done = 1; | |
689 | break; | |
690 | case tp_pointer: | |
691 | follow_type = lookup_pointer_type (follow_type); | |
692 | break; | |
693 | case tp_reference: | |
3b224330 | 694 | follow_type = lookup_lvalue_reference_type (follow_type); |
c906108c SS |
695 | break; |
696 | case tp_array: | |
dac43e32 | 697 | array_size = type_stack->pop_int (); |
c906108c SS |
698 | if (array_size != -1) |
699 | { | |
700 | range_type = | |
0c9c3474 SA |
701 | create_static_range_type ((struct type *) NULL, |
702 | parse_f_type (pstate) | |
703 | ->builtin_integer, | |
704 | 0, array_size - 1); | |
c906108c SS |
705 | follow_type = |
706 | create_array_type ((struct type *) NULL, | |
707 | follow_type, range_type); | |
708 | } | |
709 | else | |
710 | follow_type = lookup_pointer_type (follow_type); | |
711 | break; | |
712 | case tp_function: | |
713 | follow_type = lookup_function_type (follow_type); | |
714 | break; | |
4d00f5d8 AB |
715 | case tp_kind: |
716 | { | |
dac43e32 | 717 | int kind_val = type_stack->pop_int (); |
4d00f5d8 AB |
718 | follow_type |
719 | = convert_to_kind_type (follow_type, kind_val); | |
720 | } | |
721 | break; | |
c906108c SS |
722 | } |
723 | $$ = follow_type; | |
724 | } | |
725 | ; | |
726 | ||
727 | abs_decl: '*' | |
dac43e32 | 728 | { type_stack->push (tp_pointer); $$ = 0; } |
c906108c | 729 | | '*' abs_decl |
dac43e32 | 730 | { type_stack->push (tp_pointer); $$ = $2; } |
c906108c | 731 | | '&' |
dac43e32 | 732 | { type_stack->push (tp_reference); $$ = 0; } |
c906108c | 733 | | '&' abs_decl |
dac43e32 | 734 | { type_stack->push (tp_reference); $$ = $2; } |
c906108c SS |
735 | | direct_abs_decl |
736 | ; | |
737 | ||
738 | direct_abs_decl: '(' abs_decl ')' | |
739 | { $$ = $2; } | |
4d00f5d8 AB |
740 | | '(' KIND '=' INT ')' |
741 | { push_kind_type ($4.val, $4.type); } | |
efbecbc1 AB |
742 | | '*' INT |
743 | { push_kind_type ($2.val, $2.type); } | |
c906108c | 744 | | direct_abs_decl func_mod |
dac43e32 | 745 | { type_stack->push (tp_function); } |
c906108c | 746 | | func_mod |
dac43e32 | 747 | { type_stack->push (tp_function); } |
c906108c SS |
748 | ; |
749 | ||
750 | func_mod: '(' ')' | |
751 | { $$ = 0; } | |
752 | | '(' nonempty_typelist ')' | |
8dbb1c65 | 753 | { free ($2); $$ = 0; } |
c906108c SS |
754 | ; |
755 | ||
756 | typebase /* Implements (approximately): (type-qualifier)* type-specifier */ | |
757 | : TYPENAME | |
758 | { $$ = $1.type; } | |
759 | | INT_KEYWORD | |
410a0ff2 | 760 | { $$ = parse_f_type (pstate)->builtin_integer; } |
c906108c | 761 | | INT_S2_KEYWORD |
410a0ff2 | 762 | { $$ = parse_f_type (pstate)->builtin_integer_s2; } |
c906108c | 763 | | CHARACTER |
410a0ff2 | 764 | { $$ = parse_f_type (pstate)->builtin_character; } |
ce4b0682 | 765 | | LOGICAL_S8_KEYWORD |
410a0ff2 | 766 | { $$ = parse_f_type (pstate)->builtin_logical_s8; } |
c906108c | 767 | | LOGICAL_KEYWORD |
410a0ff2 | 768 | { $$ = parse_f_type (pstate)->builtin_logical; } |
c906108c | 769 | | LOGICAL_S2_KEYWORD |
410a0ff2 | 770 | { $$ = parse_f_type (pstate)->builtin_logical_s2; } |
c906108c | 771 | | LOGICAL_S1_KEYWORD |
410a0ff2 | 772 | { $$ = parse_f_type (pstate)->builtin_logical_s1; } |
c906108c | 773 | | REAL_KEYWORD |
410a0ff2 | 774 | { $$ = parse_f_type (pstate)->builtin_real; } |
c906108c | 775 | | REAL_S8_KEYWORD |
410a0ff2 | 776 | { $$ = parse_f_type (pstate)->builtin_real_s8; } |
c906108c | 777 | | REAL_S16_KEYWORD |
410a0ff2 | 778 | { $$ = parse_f_type (pstate)->builtin_real_s16; } |
36c8fb93 AB |
779 | | COMPLEX_KEYWORD |
780 | { $$ = parse_f_type (pstate)->builtin_complex_s8; } | |
c906108c | 781 | | COMPLEX_S8_KEYWORD |
410a0ff2 | 782 | { $$ = parse_f_type (pstate)->builtin_complex_s8; } |
c906108c | 783 | | COMPLEX_S16_KEYWORD |
410a0ff2 | 784 | { $$ = parse_f_type (pstate)->builtin_complex_s16; } |
c906108c | 785 | | COMPLEX_S32_KEYWORD |
410a0ff2 | 786 | { $$ = parse_f_type (pstate)->builtin_complex_s32; } |
36c8fb93 AB |
787 | | SINGLE PRECISION |
788 | { $$ = parse_f_type (pstate)->builtin_real;} | |
789 | | DOUBLE PRECISION | |
790 | { $$ = parse_f_type (pstate)->builtin_real_s8;} | |
791 | | SINGLE COMPLEX_KEYWORD | |
792 | { $$ = parse_f_type (pstate)->builtin_complex_s8;} | |
793 | | DOUBLE COMPLEX_KEYWORD | |
794 | { $$ = parse_f_type (pstate)->builtin_complex_s16;} | |
c906108c SS |
795 | ; |
796 | ||
c906108c SS |
797 | nonempty_typelist |
798 | : type | |
799 | { $$ = (struct type **) malloc (sizeof (struct type *) * 2); | |
800 | $<ivec>$[0] = 1; /* Number of types in vector */ | |
801 | $$[1] = $1; | |
802 | } | |
803 | | nonempty_typelist ',' type | |
804 | { int len = sizeof (struct type *) * (++($<ivec>1[0]) + 1); | |
805 | $$ = (struct type **) realloc ((char *) $1, len); | |
806 | $$[$<ivec>$[0]] = $3; | |
807 | } | |
808 | ; | |
809 | ||
2a5e440c WZ |
810 | name : NAME |
811 | { $$ = $1.stoken; } | |
812 | ; | |
813 | ||
c906108c SS |
814 | name_not_typename : NAME |
815 | /* These would be useful if name_not_typename was useful, but it is just | |
816 | a fake for "variable", so these cause reduce/reduce conflicts because | |
817 | the parser can't tell whether NAME_OR_INT is a name_not_typename (=variable, | |
818 | =exp) or just an exp. If name_not_typename was ever used in an lvalue | |
819 | context where only a name could occur, this might be useful. | |
820 | | NAME_OR_INT | |
821 | */ | |
822 | ; | |
823 | ||
824 | %% | |
825 | ||
826 | /* Take care of parsing a number (anything that starts with a digit). | |
827 | Set yylval and return the token type; update lexptr. | |
828 | LEN is the number of characters in it. */ | |
829 | ||
830 | /*** Needs some error checking for the float case ***/ | |
831 | ||
832 | static int | |
410a0ff2 SDJ |
833 | parse_number (struct parser_state *par_state, |
834 | const char *p, int len, int parsed_float, YYSTYPE *putithere) | |
c906108c | 835 | { |
710122da DC |
836 | LONGEST n = 0; |
837 | LONGEST prevn = 0; | |
838 | int c; | |
839 | int base = input_radix; | |
c906108c SS |
840 | int unsigned_p = 0; |
841 | int long_p = 0; | |
842 | ULONGEST high_bit; | |
843 | struct type *signed_type; | |
844 | struct type *unsigned_type; | |
845 | ||
846 | if (parsed_float) | |
847 | { | |
848 | /* It's a float since it contains a point or an exponent. */ | |
edd079d9 UW |
849 | /* [dD] is not understood as an exponent by parse_float, |
850 | change it to 'e'. */ | |
c906108c SS |
851 | char *tmp, *tmp2; |
852 | ||
4fcf66da | 853 | tmp = xstrdup (p); |
c906108c SS |
854 | for (tmp2 = tmp; *tmp2; ++tmp2) |
855 | if (*tmp2 == 'd' || *tmp2 == 'D') | |
856 | *tmp2 = 'e'; | |
edd079d9 UW |
857 | |
858 | /* FIXME: Should this use different types? */ | |
859 | putithere->typed_val_float.type = parse_f_type (pstate)->builtin_real_s8; | |
860 | bool parsed = parse_float (tmp, len, | |
861 | putithere->typed_val_float.type, | |
862 | putithere->typed_val_float.val); | |
c906108c | 863 | free (tmp); |
edd079d9 | 864 | return parsed? FLOAT : ERROR; |
c906108c SS |
865 | } |
866 | ||
867 | /* Handle base-switching prefixes 0x, 0t, 0d, 0 */ | |
868 | if (p[0] == '0') | |
869 | switch (p[1]) | |
870 | { | |
871 | case 'x': | |
872 | case 'X': | |
873 | if (len >= 3) | |
874 | { | |
875 | p += 2; | |
876 | base = 16; | |
877 | len -= 2; | |
878 | } | |
879 | break; | |
880 | ||
881 | case 't': | |
882 | case 'T': | |
883 | case 'd': | |
884 | case 'D': | |
885 | if (len >= 3) | |
886 | { | |
887 | p += 2; | |
888 | base = 10; | |
889 | len -= 2; | |
890 | } | |
891 | break; | |
892 | ||
893 | default: | |
894 | base = 8; | |
895 | break; | |
896 | } | |
897 | ||
898 | while (len-- > 0) | |
899 | { | |
900 | c = *p++; | |
0f6e1ba6 AC |
901 | if (isupper (c)) |
902 | c = tolower (c); | |
903 | if (len == 0 && c == 'l') | |
904 | long_p = 1; | |
905 | else if (len == 0 && c == 'u') | |
906 | unsigned_p = 1; | |
c906108c SS |
907 | else |
908 | { | |
0f6e1ba6 AC |
909 | int i; |
910 | if (c >= '0' && c <= '9') | |
911 | i = c - '0'; | |
912 | else if (c >= 'a' && c <= 'f') | |
913 | i = c - 'a' + 10; | |
c906108c SS |
914 | else |
915 | return ERROR; /* Char not a digit */ | |
0f6e1ba6 AC |
916 | if (i >= base) |
917 | return ERROR; /* Invalid digit in this base */ | |
918 | n *= base; | |
919 | n += i; | |
c906108c | 920 | } |
c906108c SS |
921 | /* Portably test for overflow (only works for nonzero values, so make |
922 | a second check for zero). */ | |
923 | if ((prevn >= n) && n != 0) | |
924 | unsigned_p=1; /* Try something unsigned */ | |
925 | /* If range checking enabled, portably test for unsigned overflow. */ | |
926 | if (RANGE_CHECK && n != 0) | |
927 | { | |
928 | if ((unsigned_p && (unsigned)prevn >= (unsigned)n)) | |
001083c6 | 929 | range_error (_("Overflow on numeric constant.")); |
c906108c SS |
930 | } |
931 | prevn = n; | |
932 | } | |
933 | ||
934 | /* If the number is too big to be an int, or it's got an l suffix | |
935 | then it's a long. Work out if this has to be a long by | |
7a9dd1b2 | 936 | shifting right and seeing if anything remains, and the |
c906108c SS |
937 | target int size is different to the target long size. |
938 | ||
939 | In the expression below, we could have tested | |
3e79cecf | 940 | (n >> gdbarch_int_bit (parse_gdbarch)) |
c906108c SS |
941 | to see if it was zero, |
942 | but too many compilers warn about that, when ints and longs | |
943 | are the same size. So we shift it twice, with fewer bits | |
944 | each time, for the same result. */ | |
945 | ||
fa9f5be6 TT |
946 | if ((gdbarch_int_bit (par_state->gdbarch ()) |
947 | != gdbarch_long_bit (par_state->gdbarch ()) | |
9a76efb6 | 948 | && ((n >> 2) |
fa9f5be6 | 949 | >> (gdbarch_int_bit (par_state->gdbarch ())-2))) /* Avoid |
410a0ff2 | 950 | shift warning */ |
c906108c SS |
951 | || long_p) |
952 | { | |
410a0ff2 | 953 | high_bit = ((ULONGEST)1) |
fa9f5be6 | 954 | << (gdbarch_long_bit (par_state->gdbarch ())-1); |
410a0ff2 SDJ |
955 | unsigned_type = parse_type (par_state)->builtin_unsigned_long; |
956 | signed_type = parse_type (par_state)->builtin_long; | |
c906108c SS |
957 | } |
958 | else | |
959 | { | |
410a0ff2 | 960 | high_bit = |
fa9f5be6 | 961 | ((ULONGEST)1) << (gdbarch_int_bit (par_state->gdbarch ()) - 1); |
410a0ff2 SDJ |
962 | unsigned_type = parse_type (par_state)->builtin_unsigned_int; |
963 | signed_type = parse_type (par_state)->builtin_int; | |
c906108c SS |
964 | } |
965 | ||
966 | putithere->typed_val.val = n; | |
967 | ||
968 | /* If the high bit of the worked out type is set then this number | |
0963b4bd | 969 | has to be unsigned. */ |
c906108c SS |
970 | |
971 | if (unsigned_p || (n & high_bit)) | |
972 | putithere->typed_val.type = unsigned_type; | |
973 | else | |
974 | putithere->typed_val.type = signed_type; | |
975 | ||
976 | return INT; | |
977 | } | |
978 | ||
4d00f5d8 AB |
979 | /* Called to setup the type stack when we encounter a '(kind=N)' type |
980 | modifier, performs some bounds checking on 'N' and then pushes this to | |
981 | the type stack followed by the 'tp_kind' marker. */ | |
982 | static void | |
983 | push_kind_type (LONGEST val, struct type *type) | |
984 | { | |
985 | int ival; | |
986 | ||
c6d940a9 | 987 | if (type->is_unsigned ()) |
4d00f5d8 AB |
988 | { |
989 | ULONGEST uval = static_cast <ULONGEST> (val); | |
990 | if (uval > INT_MAX) | |
991 | error (_("kind value out of range")); | |
992 | ival = static_cast <int> (uval); | |
993 | } | |
994 | else | |
995 | { | |
996 | if (val > INT_MAX || val < 0) | |
997 | error (_("kind value out of range")); | |
998 | ival = static_cast <int> (val); | |
999 | } | |
1000 | ||
dac43e32 TT |
1001 | type_stack->push (ival); |
1002 | type_stack->push (tp_kind); | |
4d00f5d8 AB |
1003 | } |
1004 | ||
1005 | /* Called when a type has a '(kind=N)' modifier after it, for example | |
1006 | 'character(kind=1)'. The BASETYPE is the type described by 'character' | |
1007 | in our example, and KIND is the integer '1'. This function returns a | |
1008 | new type that represents the basetype of a specific kind. */ | |
1009 | static struct type * | |
1010 | convert_to_kind_type (struct type *basetype, int kind) | |
1011 | { | |
1012 | if (basetype == parse_f_type (pstate)->builtin_character) | |
1013 | { | |
1014 | /* Character of kind 1 is a special case, this is the same as the | |
1015 | base character type. */ | |
1016 | if (kind == 1) | |
1017 | return parse_f_type (pstate)->builtin_character; | |
1018 | } | |
3be47f7a AB |
1019 | else if (basetype == parse_f_type (pstate)->builtin_complex_s8) |
1020 | { | |
1021 | if (kind == 4) | |
1022 | return parse_f_type (pstate)->builtin_complex_s8; | |
1023 | else if (kind == 8) | |
1024 | return parse_f_type (pstate)->builtin_complex_s16; | |
1025 | else if (kind == 16) | |
1026 | return parse_f_type (pstate)->builtin_complex_s32; | |
1027 | } | |
1028 | else if (basetype == parse_f_type (pstate)->builtin_real) | |
1029 | { | |
1030 | if (kind == 4) | |
1031 | return parse_f_type (pstate)->builtin_real; | |
1032 | else if (kind == 8) | |
1033 | return parse_f_type (pstate)->builtin_real_s8; | |
1034 | else if (kind == 16) | |
1035 | return parse_f_type (pstate)->builtin_real_s16; | |
1036 | } | |
1037 | else if (basetype == parse_f_type (pstate)->builtin_logical) | |
1038 | { | |
1039 | if (kind == 1) | |
1040 | return parse_f_type (pstate)->builtin_logical_s1; | |
1041 | else if (kind == 2) | |
1042 | return parse_f_type (pstate)->builtin_logical_s2; | |
1043 | else if (kind == 4) | |
1044 | return parse_f_type (pstate)->builtin_logical; | |
1045 | else if (kind == 8) | |
1046 | return parse_f_type (pstate)->builtin_logical_s8; | |
1047 | } | |
1048 | else if (basetype == parse_f_type (pstate)->builtin_integer) | |
1049 | { | |
1050 | if (kind == 2) | |
1051 | return parse_f_type (pstate)->builtin_integer_s2; | |
1052 | else if (kind == 4) | |
1053 | return parse_f_type (pstate)->builtin_integer; | |
067630bd AB |
1054 | else if (kind == 8) |
1055 | return parse_f_type (pstate)->builtin_integer_s8; | |
3be47f7a | 1056 | } |
4d00f5d8 AB |
1057 | |
1058 | error (_("unsupported kind %d for type %s"), | |
1059 | kind, TYPE_SAFE_NAME (basetype)); | |
1060 | ||
1061 | /* Should never get here. */ | |
1062 | return nullptr; | |
1063 | } | |
1064 | ||
c906108c SS |
1065 | struct token |
1066 | { | |
c8f91604 | 1067 | /* The string to match against. */ |
a121b7c1 | 1068 | const char *oper; |
c8f91604 AB |
1069 | |
1070 | /* The lexer token to return. */ | |
c906108c | 1071 | int token; |
c8f91604 AB |
1072 | |
1073 | /* The expression opcode to embed within the token. */ | |
c906108c | 1074 | enum exp_opcode opcode; |
c8f91604 AB |
1075 | |
1076 | /* When this is true the string in OPER is matched exactly including | |
1077 | case, when this is false OPER is matched case insensitively. */ | |
1078 | bool case_sensitive; | |
c906108c SS |
1079 | }; |
1080 | ||
7c654b71 AB |
1081 | /* List of Fortran operators. */ |
1082 | ||
1083 | static const struct token fortran_operators[] = | |
c906108c | 1084 | { |
79ab486e TT |
1085 | { ".and.", BOOL_AND, OP_NULL, false }, |
1086 | { ".or.", BOOL_OR, OP_NULL, false }, | |
1087 | { ".not.", BOOL_NOT, OP_NULL, false }, | |
1088 | { ".eq.", EQUAL, OP_NULL, false }, | |
1089 | { ".eqv.", EQUAL, OP_NULL, false }, | |
1090 | { ".neqv.", NOTEQUAL, OP_NULL, false }, | |
1091 | { ".xor.", NOTEQUAL, OP_NULL, false }, | |
1092 | { "==", EQUAL, OP_NULL, false }, | |
1093 | { ".ne.", NOTEQUAL, OP_NULL, false }, | |
1094 | { "/=", NOTEQUAL, OP_NULL, false }, | |
1095 | { ".le.", LEQ, OP_NULL, false }, | |
1096 | { "<=", LEQ, OP_NULL, false }, | |
1097 | { ".ge.", GEQ, OP_NULL, false }, | |
1098 | { ">=", GEQ, OP_NULL, false }, | |
1099 | { ".gt.", GREATERTHAN, OP_NULL, false }, | |
1100 | { ">", GREATERTHAN, OP_NULL, false }, | |
1101 | { ".lt.", LESSTHAN, OP_NULL, false }, | |
1102 | { "<", LESSTHAN, OP_NULL, false }, | |
7c654b71 | 1103 | { "**", STARSTAR, BINOP_EXP, false }, |
c906108c SS |
1104 | }; |
1105 | ||
dd9f2c76 AB |
1106 | /* Holds the Fortran representation of a boolean, and the integer value we |
1107 | substitute in when one of the matching strings is parsed. */ | |
1108 | struct f77_boolean_val | |
c906108c | 1109 | { |
dd9f2c76 | 1110 | /* The string representing a Fortran boolean. */ |
a121b7c1 | 1111 | const char *name; |
dd9f2c76 AB |
1112 | |
1113 | /* The integer value to replace it with. */ | |
c906108c | 1114 | int value; |
dd9f2c76 | 1115 | }; |
c906108c | 1116 | |
dd9f2c76 AB |
1117 | /* The set of Fortran booleans. These are matched case insensitively. */ |
1118 | static const struct f77_boolean_val boolean_values[] = | |
c906108c SS |
1119 | { |
1120 | { ".true.", 1 }, | |
dd9f2c76 | 1121 | { ".false.", 0 } |
c906108c SS |
1122 | }; |
1123 | ||
c8f91604 | 1124 | static const struct token f77_keywords[] = |
c906108c | 1125 | { |
c8f91604 | 1126 | /* Historically these have always been lowercase only in GDB. */ |
79ab486e TT |
1127 | { "complex_16", COMPLEX_S16_KEYWORD, OP_NULL, true }, |
1128 | { "complex_32", COMPLEX_S32_KEYWORD, OP_NULL, true }, | |
1129 | { "character", CHARACTER, OP_NULL, true }, | |
1130 | { "integer_2", INT_S2_KEYWORD, OP_NULL, true }, | |
1131 | { "logical_1", LOGICAL_S1_KEYWORD, OP_NULL, true }, | |
1132 | { "logical_2", LOGICAL_S2_KEYWORD, OP_NULL, true }, | |
1133 | { "logical_8", LOGICAL_S8_KEYWORD, OP_NULL, true }, | |
1134 | { "complex_8", COMPLEX_S8_KEYWORD, OP_NULL, true }, | |
1135 | { "integer", INT_KEYWORD, OP_NULL, true }, | |
1136 | { "logical", LOGICAL_KEYWORD, OP_NULL, true }, | |
1137 | { "real_16", REAL_S16_KEYWORD, OP_NULL, true }, | |
1138 | { "complex", COMPLEX_KEYWORD, OP_NULL, true }, | |
1139 | { "sizeof", SIZEOF, OP_NULL, true }, | |
1140 | { "real_8", REAL_S8_KEYWORD, OP_NULL, true }, | |
1141 | { "real", REAL_KEYWORD, OP_NULL, true }, | |
1142 | { "single", SINGLE, OP_NULL, true }, | |
1143 | { "double", DOUBLE, OP_NULL, true }, | |
1144 | { "precision", PRECISION, OP_NULL, true }, | |
4d00f5d8 AB |
1145 | /* The following correspond to actual functions in Fortran and are case |
1146 | insensitive. */ | |
79ab486e | 1147 | { "kind", KIND, OP_NULL, false }, |
b6d03bb2 AB |
1148 | { "abs", UNOP_INTRINSIC, UNOP_ABS, false }, |
1149 | { "mod", BINOP_INTRINSIC, BINOP_MOD, false }, | |
1150 | { "floor", UNOP_INTRINSIC, UNOP_FORTRAN_FLOOR, false }, | |
1151 | { "ceiling", UNOP_INTRINSIC, UNOP_FORTRAN_CEILING, false }, | |
1152 | { "modulo", BINOP_INTRINSIC, BINOP_FORTRAN_MODULO, false }, | |
1153 | { "cmplx", BINOP_INTRINSIC, BINOP_FORTRAN_CMPLX, false }, | |
e92c8eb8 AB |
1154 | { "lbound", UNOP_OR_BINOP_INTRINSIC, FORTRAN_LBOUND, false }, |
1155 | { "ubound", UNOP_OR_BINOP_INTRINSIC, FORTRAN_UBOUND, false }, | |
96df3e28 | 1156 | { "allocated", UNOP_INTRINSIC, UNOP_FORTRAN_ALLOCATED, false }, |
faeb9f13 | 1157 | { "associated", UNOP_OR_BINOP_INTRINSIC, FORTRAN_ASSOCIATED, false }, |
e14816a8 | 1158 | { "rank", UNOP_INTRINSIC, UNOP_FORTRAN_RANK, false }, |
7ba155b3 | 1159 | { "size", UNOP_OR_BINOP_INTRINSIC, FORTRAN_ARRAY_SIZE, false }, |
eef32f59 | 1160 | { "shape", UNOP_INTRINSIC, UNOP_FORTRAN_SHAPE, false }, |
611aa09d | 1161 | { "loc", UNOP_INTRINSIC, UNOP_FORTRAN_LOC, false }, |
c8f91604 | 1162 | }; |
c906108c SS |
1163 | |
1164 | /* Implementation of a dynamically expandable buffer for processing input | |
1165 | characters acquired through lexptr and building a value to return in | |
0963b4bd | 1166 | yylval. Ripped off from ch-exp.y */ |
c906108c SS |
1167 | |
1168 | static char *tempbuf; /* Current buffer contents */ | |
1169 | static int tempbufsize; /* Size of allocated buffer */ | |
1170 | static int tempbufindex; /* Current index into buffer */ | |
1171 | ||
1172 | #define GROWBY_MIN_SIZE 64 /* Minimum amount to grow buffer by */ | |
1173 | ||
1174 | #define CHECKBUF(size) \ | |
1175 | do { \ | |
1176 | if (tempbufindex + (size) >= tempbufsize) \ | |
1177 | { \ | |
1178 | growbuf_by_size (size); \ | |
1179 | } \ | |
1180 | } while (0); | |
1181 | ||
1182 | ||
0963b4bd MS |
1183 | /* Grow the static temp buffer if necessary, including allocating the |
1184 | first one on demand. */ | |
c906108c SS |
1185 | |
1186 | static void | |
d04550a6 | 1187 | growbuf_by_size (int count) |
c906108c SS |
1188 | { |
1189 | int growby; | |
1190 | ||
325fac50 | 1191 | growby = std::max (count, GROWBY_MIN_SIZE); |
c906108c SS |
1192 | tempbufsize += growby; |
1193 | if (tempbuf == NULL) | |
1194 | tempbuf = (char *) malloc (tempbufsize); | |
1195 | else | |
1196 | tempbuf = (char *) realloc (tempbuf, tempbufsize); | |
1197 | } | |
1198 | ||
1199 | /* Blatantly ripped off from ch-exp.y. This routine recognizes F77 | |
0963b4bd | 1200 | string-literals. |
c906108c SS |
1201 | |
1202 | Recognize a string literal. A string literal is a nonzero sequence | |
1203 | of characters enclosed in matching single quotes, except that | |
1204 | a single character inside single quotes is a character literal, which | |
1205 | we reject as a string literal. To embed the terminator character inside | |
1206 | a string, it is simply doubled (I.E. 'this''is''one''string') */ | |
1207 | ||
1208 | static int | |
eeae04df | 1209 | match_string_literal (void) |
c906108c | 1210 | { |
5776fca3 | 1211 | const char *tokptr = pstate->lexptr; |
c906108c SS |
1212 | |
1213 | for (tempbufindex = 0, tokptr++; *tokptr != '\0'; tokptr++) | |
1214 | { | |
1215 | CHECKBUF (1); | |
5776fca3 | 1216 | if (*tokptr == *pstate->lexptr) |
c906108c | 1217 | { |
5776fca3 | 1218 | if (*(tokptr + 1) == *pstate->lexptr) |
c906108c SS |
1219 | tokptr++; |
1220 | else | |
1221 | break; | |
1222 | } | |
1223 | tempbuf[tempbufindex++] = *tokptr; | |
1224 | } | |
1225 | if (*tokptr == '\0' /* no terminator */ | |
1226 | || tempbufindex == 0) /* no string */ | |
1227 | return 0; | |
1228 | else | |
1229 | { | |
1230 | tempbuf[tempbufindex] = '\0'; | |
1231 | yylval.sval.ptr = tempbuf; | |
1232 | yylval.sval.length = tempbufindex; | |
5776fca3 | 1233 | pstate->lexptr = ++tokptr; |
c906108c SS |
1234 | return STRING_LITERAL; |
1235 | } | |
1236 | } | |
1237 | ||
9dd02fc0 AB |
1238 | /* This is set if a NAME token appeared at the very end of the input |
1239 | string, with no whitespace separating the name from the EOF. This | |
1240 | is used only when parsing to do field name completion. */ | |
1241 | static bool saw_name_at_eof; | |
1242 | ||
1243 | /* This is set if the previously-returned token was a structure | |
1244 | operator '%'. */ | |
1245 | static bool last_was_structop; | |
1246 | ||
c906108c SS |
1247 | /* Read one token, getting characters through lexptr. */ |
1248 | ||
1249 | static int | |
eeae04df | 1250 | yylex (void) |
c906108c SS |
1251 | { |
1252 | int c; | |
1253 | int namelen; | |
b926417a | 1254 | unsigned int token; |
d7561cbb | 1255 | const char *tokstart; |
9dd02fc0 AB |
1256 | bool saw_structop = last_was_structop; |
1257 | ||
1258 | last_was_structop = false; | |
1259 | ||
c906108c | 1260 | retry: |
065432a8 | 1261 | |
5776fca3 | 1262 | pstate->prev_lexptr = pstate->lexptr; |
065432a8 | 1263 | |
5776fca3 | 1264 | tokstart = pstate->lexptr; |
dd9f2c76 AB |
1265 | |
1266 | /* First of all, let us make sure we are not dealing with the | |
c906108c | 1267 | special tokens .true. and .false. which evaluate to 1 and 0. */ |
dd9f2c76 | 1268 | |
5776fca3 | 1269 | if (*pstate->lexptr == '.') |
dd9f2c76 AB |
1270 | { |
1271 | for (int i = 0; i < ARRAY_SIZE (boolean_values); i++) | |
c906108c | 1272 | { |
dd9f2c76 AB |
1273 | if (strncasecmp (tokstart, boolean_values[i].name, |
1274 | strlen (boolean_values[i].name)) == 0) | |
c906108c | 1275 | { |
5776fca3 | 1276 | pstate->lexptr += strlen (boolean_values[i].name); |
dd9f2c76 | 1277 | yylval.lval = boolean_values[i].value; |
c906108c SS |
1278 | return BOOLEAN_LITERAL; |
1279 | } | |
1280 | } | |
1281 | } | |
c8f91604 | 1282 | |
7c654b71 AB |
1283 | /* See if it is a Fortran operator. */ |
1284 | for (int i = 0; i < ARRAY_SIZE (fortran_operators); i++) | |
1285 | if (strncasecmp (tokstart, fortran_operators[i].oper, | |
1286 | strlen (fortran_operators[i].oper)) == 0) | |
c906108c | 1287 | { |
7c654b71 AB |
1288 | gdb_assert (!fortran_operators[i].case_sensitive); |
1289 | pstate->lexptr += strlen (fortran_operators[i].oper); | |
1290 | yylval.opcode = fortran_operators[i].opcode; | |
1291 | return fortran_operators[i].token; | |
c906108c | 1292 | } |
c8f91604 | 1293 | |
c906108c SS |
1294 | switch (c = *tokstart) |
1295 | { | |
1296 | case 0: | |
9dd02fc0 AB |
1297 | if (saw_name_at_eof) |
1298 | { | |
1299 | saw_name_at_eof = false; | |
1300 | return COMPLETE; | |
1301 | } | |
1302 | else if (pstate->parse_completion && saw_structop) | |
1303 | return COMPLETE; | |
c906108c SS |
1304 | return 0; |
1305 | ||
1306 | case ' ': | |
1307 | case '\t': | |
1308 | case '\n': | |
5776fca3 | 1309 | pstate->lexptr++; |
c906108c SS |
1310 | goto retry; |
1311 | ||
1312 | case '\'': | |
1313 | token = match_string_literal (); | |
1314 | if (token != 0) | |
1315 | return (token); | |
1316 | break; | |
1317 | ||
1318 | case '(': | |
1319 | paren_depth++; | |
5776fca3 | 1320 | pstate->lexptr++; |
c906108c SS |
1321 | return c; |
1322 | ||
1323 | case ')': | |
1324 | if (paren_depth == 0) | |
1325 | return 0; | |
1326 | paren_depth--; | |
5776fca3 | 1327 | pstate->lexptr++; |
c906108c SS |
1328 | return c; |
1329 | ||
1330 | case ',': | |
8621b685 | 1331 | if (pstate->comma_terminates && paren_depth == 0) |
c906108c | 1332 | return 0; |
5776fca3 | 1333 | pstate->lexptr++; |
c906108c SS |
1334 | return c; |
1335 | ||
1336 | case '.': | |
1337 | /* Might be a floating point number. */ | |
5776fca3 | 1338 | if (pstate->lexptr[1] < '0' || pstate->lexptr[1] > '9') |
0963b4bd | 1339 | goto symbol; /* Nope, must be a symbol. */ |
86a73007 | 1340 | /* FALL THRU. */ |
c906108c SS |
1341 | |
1342 | case '0': | |
1343 | case '1': | |
1344 | case '2': | |
1345 | case '3': | |
1346 | case '4': | |
1347 | case '5': | |
1348 | case '6': | |
1349 | case '7': | |
1350 | case '8': | |
1351 | case '9': | |
1352 | { | |
dda83cd7 | 1353 | /* It's a number. */ |
c906108c | 1354 | int got_dot = 0, got_e = 0, got_d = 0, toktype; |
d7561cbb | 1355 | const char *p = tokstart; |
c906108c SS |
1356 | int hex = input_radix > 10; |
1357 | ||
1358 | if (c == '0' && (p[1] == 'x' || p[1] == 'X')) | |
1359 | { | |
1360 | p += 2; | |
1361 | hex = 1; | |
1362 | } | |
0963b4bd MS |
1363 | else if (c == '0' && (p[1]=='t' || p[1]=='T' |
1364 | || p[1]=='d' || p[1]=='D')) | |
c906108c SS |
1365 | { |
1366 | p += 2; | |
1367 | hex = 0; | |
1368 | } | |
1369 | ||
1370 | for (;; ++p) | |
1371 | { | |
1372 | if (!hex && !got_e && (*p == 'e' || *p == 'E')) | |
1373 | got_dot = got_e = 1; | |
1374 | else if (!hex && !got_d && (*p == 'd' || *p == 'D')) | |
1375 | got_dot = got_d = 1; | |
1376 | else if (!hex && !got_dot && *p == '.') | |
1377 | got_dot = 1; | |
1378 | else if (((got_e && (p[-1] == 'e' || p[-1] == 'E')) | |
1379 | || (got_d && (p[-1] == 'd' || p[-1] == 'D'))) | |
1380 | && (*p == '-' || *p == '+')) | |
1381 | /* This is the sign of the exponent, not the end of the | |
1382 | number. */ | |
1383 | continue; | |
1384 | /* We will take any letters or digits. parse_number will | |
1385 | complain if past the radix, or if L or U are not final. */ | |
1386 | else if ((*p < '0' || *p > '9') | |
1387 | && ((*p < 'a' || *p > 'z') | |
1388 | && (*p < 'A' || *p > 'Z'))) | |
1389 | break; | |
1390 | } | |
410a0ff2 SDJ |
1391 | toktype = parse_number (pstate, tokstart, p - tokstart, |
1392 | got_dot|got_e|got_d, | |
c906108c | 1393 | &yylval); |
dda83cd7 SM |
1394 | if (toktype == ERROR) |
1395 | { | |
c906108c SS |
1396 | char *err_copy = (char *) alloca (p - tokstart + 1); |
1397 | ||
1398 | memcpy (err_copy, tokstart, p - tokstart); | |
1399 | err_copy[p - tokstart] = 0; | |
001083c6 | 1400 | error (_("Invalid number \"%s\"."), err_copy); |
c906108c | 1401 | } |
5776fca3 | 1402 | pstate->lexptr = p; |
c906108c SS |
1403 | return toktype; |
1404 | } | |
9dd02fc0 AB |
1405 | |
1406 | case '%': | |
1407 | last_was_structop = true; | |
1408 | /* Fall through. */ | |
c906108c SS |
1409 | case '+': |
1410 | case '-': | |
1411 | case '*': | |
1412 | case '/': | |
c906108c SS |
1413 | case '|': |
1414 | case '&': | |
1415 | case '^': | |
1416 | case '~': | |
1417 | case '!': | |
1418 | case '@': | |
1419 | case '<': | |
1420 | case '>': | |
1421 | case '[': | |
1422 | case ']': | |
1423 | case '?': | |
1424 | case ':': | |
1425 | case '=': | |
1426 | case '{': | |
1427 | case '}': | |
1428 | symbol: | |
5776fca3 | 1429 | pstate->lexptr++; |
c906108c SS |
1430 | return c; |
1431 | } | |
1432 | ||
f55ee35c | 1433 | if (!(c == '_' || c == '$' || c ==':' |
c906108c SS |
1434 | || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))) |
1435 | /* We must have come across a bad character (e.g. ';'). */ | |
001083c6 | 1436 | error (_("Invalid character '%c' in expression."), c); |
c906108c SS |
1437 | |
1438 | namelen = 0; | |
1439 | for (c = tokstart[namelen]; | |
f55ee35c | 1440 | (c == '_' || c == '$' || c == ':' || (c >= '0' && c <= '9') |
c906108c SS |
1441 | || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')); |
1442 | c = tokstart[++namelen]); | |
1443 | ||
1444 | /* The token "if" terminates the expression and is NOT | |
1445 | removed from the input stream. */ | |
1446 | ||
1447 | if (namelen == 2 && tokstart[0] == 'i' && tokstart[1] == 'f') | |
1448 | return 0; | |
1449 | ||
5776fca3 | 1450 | pstate->lexptr += namelen; |
c906108c SS |
1451 | |
1452 | /* Catch specific keywords. */ | |
c8f91604 AB |
1453 | |
1454 | for (int i = 0; i < ARRAY_SIZE (f77_keywords); i++) | |
fe978cb0 | 1455 | if (strlen (f77_keywords[i].oper) == namelen |
c8f91604 AB |
1456 | && ((!f77_keywords[i].case_sensitive |
1457 | && strncasecmp (tokstart, f77_keywords[i].oper, namelen) == 0) | |
1458 | || (f77_keywords[i].case_sensitive | |
1459 | && strncmp (tokstart, f77_keywords[i].oper, namelen) == 0))) | |
c906108c | 1460 | { |
c906108c SS |
1461 | yylval.opcode = f77_keywords[i].opcode; |
1462 | return f77_keywords[i].token; | |
1463 | } | |
c8f91604 | 1464 | |
c906108c SS |
1465 | yylval.sval.ptr = tokstart; |
1466 | yylval.sval.length = namelen; | |
1467 | ||
1468 | if (*tokstart == '$') | |
02c72701 TT |
1469 | return DOLLAR_VARIABLE; |
1470 | ||
c906108c SS |
1471 | /* Use token-type TYPENAME for symbols that happen to be defined |
1472 | currently as names of types; NAME for other symbols. | |
1473 | The caller is not constrained to care about the distinction. */ | |
1474 | { | |
61f4b350 | 1475 | std::string tmp = copy_name (yylval.sval); |
d12307c1 | 1476 | struct block_symbol result; |
530e8392 KB |
1477 | enum domain_enum_tag lookup_domains[] = |
1478 | { | |
1479 | STRUCT_DOMAIN, | |
1480 | VAR_DOMAIN, | |
1481 | MODULE_DOMAIN | |
1482 | }; | |
c906108c | 1483 | int hextype; |
7f9b20bb | 1484 | |
b926417a | 1485 | for (int i = 0; i < ARRAY_SIZE (lookup_domains); ++i) |
c906108c | 1486 | { |
61f4b350 | 1487 | result = lookup_symbol (tmp.c_str (), pstate->expression_context_block, |
43771869 | 1488 | lookup_domains[i], NULL); |
d12307c1 | 1489 | if (result.symbol && SYMBOL_CLASS (result.symbol) == LOC_TYPEDEF) |
7f9b20bb | 1490 | { |
d12307c1 | 1491 | yylval.tsym.type = SYMBOL_TYPE (result.symbol); |
7f9b20bb KB |
1492 | return TYPENAME; |
1493 | } | |
1494 | ||
d12307c1 | 1495 | if (result.symbol) |
7f9b20bb | 1496 | break; |
c906108c | 1497 | } |
7f9b20bb | 1498 | |
54a5b07d | 1499 | yylval.tsym.type |
73923d7e | 1500 | = language_lookup_primitive_type (pstate->language (), |
61f4b350 | 1501 | pstate->gdbarch (), tmp.c_str ()); |
54a5b07d | 1502 | if (yylval.tsym.type != NULL) |
c906108c SS |
1503 | return TYPENAME; |
1504 | ||
1505 | /* Input names that aren't symbols but ARE valid hex numbers, | |
1506 | when the input radix permits them, can be names or numbers | |
1507 | depending on the parse. Note we support radixes > 16 here. */ | |
d12307c1 | 1508 | if (!result.symbol |
c906108c SS |
1509 | && ((tokstart[0] >= 'a' && tokstart[0] < 'a' + input_radix - 10) |
1510 | || (tokstart[0] >= 'A' && tokstart[0] < 'A' + input_radix - 10))) | |
1511 | { | |
1512 | YYSTYPE newlval; /* Its value is ignored. */ | |
410a0ff2 | 1513 | hextype = parse_number (pstate, tokstart, namelen, 0, &newlval); |
c906108c SS |
1514 | if (hextype == INT) |
1515 | { | |
d12307c1 | 1516 | yylval.ssym.sym = result; |
43771869 | 1517 | yylval.ssym.is_a_field_of_this = false; |
c906108c SS |
1518 | return NAME_OR_INT; |
1519 | } | |
1520 | } | |
9dd02fc0 AB |
1521 | |
1522 | if (pstate->parse_completion && *pstate->lexptr == '\0') | |
1523 | saw_name_at_eof = true; | |
1524 | ||
c906108c | 1525 | /* Any other kind of symbol */ |
d12307c1 | 1526 | yylval.ssym.sym = result; |
43771869 | 1527 | yylval.ssym.is_a_field_of_this = false; |
c906108c SS |
1528 | return NAME; |
1529 | } | |
1530 | } | |
1531 | ||
410a0ff2 | 1532 | int |
1a0ea399 | 1533 | f_language::parser (struct parser_state *par_state) const |
410a0ff2 | 1534 | { |
410a0ff2 | 1535 | /* Setting up the parser state. */ |
eae49211 | 1536 | scoped_restore pstate_restore = make_scoped_restore (&pstate); |
e454224f AB |
1537 | scoped_restore restore_yydebug = make_scoped_restore (&yydebug, |
1538 | parser_debug); | |
410a0ff2 SDJ |
1539 | gdb_assert (par_state != NULL); |
1540 | pstate = par_state; | |
9dd02fc0 AB |
1541 | last_was_structop = false; |
1542 | saw_name_at_eof = false; | |
28aaf3fd | 1543 | paren_depth = 0; |
410a0ff2 | 1544 | |
dac43e32 TT |
1545 | struct type_stack stack; |
1546 | scoped_restore restore_type_stack = make_scoped_restore (&type_stack, | |
1547 | &stack); | |
1548 | ||
d308ba78 TT |
1549 | int result = yyparse (); |
1550 | if (!result) | |
1551 | pstate->set_operation (pstate->pop ()); | |
1552 | return result; | |
410a0ff2 SDJ |
1553 | } |
1554 | ||
69d340c6 | 1555 | static void |
a121b7c1 | 1556 | yyerror (const char *msg) |
c906108c | 1557 | { |
5776fca3 TT |
1558 | if (pstate->prev_lexptr) |
1559 | pstate->lexptr = pstate->prev_lexptr; | |
065432a8 | 1560 | |
5776fca3 | 1561 | error (_("A %s in expression, near `%s'."), msg, pstate->lexptr); |
c906108c | 1562 | } |