1 /* YACC parser for C expressions, for GDB.
2 Copyright (C) 1986, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
3 1998, 1999, 2000, 2003, 2004, 2006, 2007, 2008
4 Free Software Foundation, Inc.
6 This file is part of GDB.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 Boston, MA 02110-1301, USA. */
23 /* Parse a C expression from text in a string,
24 and return the result as a struct expression pointer.
25 That structure contains arithmetic operations in reverse polish,
26 with constants represented by operations that are followed by special data.
27 See expression.h for the details of the format.
28 What is important here is that it can be built up sequentially
29 during the process of parsing; the lower levels of the tree always
30 come first in the result.
32 Note that malloc's and realloc's in this file are transformed to
33 xmalloc and xrealloc respectively by the same sed command in the
34 makefile that remaps any other malloc/realloc inserted by the parser
35 generator. Doing this with #defines and trying to control the interaction
36 with include files (<malloc.h> and <stdlib.h> for example) just became
37 too messy, particularly when such includes can be inserted at random
38 times by the parser generator. */
43 #include "gdb_string.h"
45 #include "expression.h"
47 #include "parser-defs.h"
50 #include "bfd.h" /* Required by objfiles.h. */
51 #include "symfile.h" /* Required by objfiles.h. */
52 #include "objfiles.h" /* For have_full_symbols and have_partial_symbols */
55 #include "cp-support.h"
58 #define parse_type builtin_type (parse_gdbarch)
60 /* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc),
61 as well as gratuitiously global symbol names, so we can have multiple
62 yacc generated parsers in gdb. Note that these are only the variables
63 produced by yacc. If other parser generators (bison, byacc, etc) produce
64 additional global names that conflict at link time, then those parser
65 generators need to be fixed instead of adding those names to this list. */
67 #define yymaxdepth c_maxdepth
68 #define yyparse c_parse_internal
70 #define yyerror c_error
73 #define yydebug c_debug
82 #define yyerrflag c_errflag
83 #define yynerrs c_nerrs
88 #define yystate c_state
94 #define yyreds c_reds /* With YYDEBUG defined */
95 #define yytoks c_toks /* With YYDEBUG defined */
96 #define yyname c_name /* With YYDEBUG defined */
97 #define yyrule c_rule /* With YYDEBUG defined */
100 #define yydefred c_yydefred
101 #define yydgoto c_yydgoto
102 #define yysindex c_yysindex
103 #define yyrindex c_yyrindex
104 #define yygindex c_yygindex
105 #define yytable c_yytable
106 #define yycheck c_yycheck
109 #define YYDEBUG 1 /* Default to yydebug support */
112 #define YYFPRINTF parser_fprintf
116 static int yylex (void);
118 void yyerror (char *);
122 /* Although the yacc "value" of an expression is not used,
123 since the result is stored in the structure being created,
124 other node types do have values. */
140 } typed_val_decfloat;
145 struct symtoken ssym;
148 enum exp_opcode opcode;
149 struct internalvar *ivar;
156 /* YYSTYPE gets defined by %union */
157 static int parse_number (char *, int, int, YYSTYPE *);
160 %type <voidval> exp exp1 type_exp start variable qualified_name lcurly
162 %type <tval> type typebase qualified_type
163 %type <tvec> nonempty_typelist
164 /* %type <bval> block */
166 /* Fancy type parsing. */
167 %type <voidval> func_mod direct_abs_decl abs_decl
169 %type <lval> array_mod
171 %token <typed_val_int> INT
172 %token <typed_val_float> FLOAT
173 %token <typed_val_decfloat> DECFLOAT
175 /* Both NAME and TYPENAME tokens represent symbols in the input,
176 and both convey their data as strings.
177 But a TYPENAME is a string that happens to be defined as a typedef
178 or builtin type name (such as int or char)
179 and a NAME is any other symbol.
180 Contexts where this distinction is not important can use the
181 nonterminal "name", which matches either NAME or TYPENAME. */
184 %token <ssym> NAME /* BLOCKNAME defined below to give it higher precedence. */
185 %token <voidval> COMPLETE
186 %token <tsym> TYPENAME
188 %type <ssym> name_not_typename
189 %type <tsym> typename
191 /* A NAME_OR_INT is a symbol which is not known in the symbol table,
192 but which would parse as a valid number in the current input radix.
193 E.g. "c" when input_radix==16. Depending on the parse, it will be
194 turned into a name or into a number. */
196 %token <ssym> NAME_OR_INT
198 %token STRUCT CLASS UNION ENUM SIZEOF UNSIGNED COLONCOLON
202 /* Special type cases, put in to allow the parser to distinguish different
204 %token SIGNED_KEYWORD LONG SHORT INT_KEYWORD CONST_KEYWORD VOLATILE_KEYWORD DOUBLE_KEYWORD
206 %token <voidval> VARIABLE
208 %token <opcode> ASSIGN_MODIFY
217 %right '=' ASSIGN_MODIFY
225 %left '<' '>' LEQ GEQ
230 %right UNARY INCREMENT DECREMENT
231 %right ARROW '.' '[' '('
232 %token <ssym> BLOCKNAME
233 %token <bval> FILENAME
245 { write_exp_elt_opcode(OP_TYPE);
246 write_exp_elt_type($1);
247 write_exp_elt_opcode(OP_TYPE);}
250 /* Expressions, including the comma operator. */
253 { write_exp_elt_opcode (BINOP_COMMA); }
256 /* Expressions, not including the comma operator. */
257 exp : '*' exp %prec UNARY
258 { write_exp_elt_opcode (UNOP_IND); }
261 exp : '&' exp %prec UNARY
262 { write_exp_elt_opcode (UNOP_ADDR); }
265 exp : '-' exp %prec UNARY
266 { write_exp_elt_opcode (UNOP_NEG); }
269 exp : '+' exp %prec UNARY
270 { write_exp_elt_opcode (UNOP_PLUS); }
273 exp : '!' exp %prec UNARY
274 { write_exp_elt_opcode (UNOP_LOGICAL_NOT); }
277 exp : '~' exp %prec UNARY
278 { write_exp_elt_opcode (UNOP_COMPLEMENT); }
281 exp : INCREMENT exp %prec UNARY
282 { write_exp_elt_opcode (UNOP_PREINCREMENT); }
285 exp : DECREMENT exp %prec UNARY
286 { write_exp_elt_opcode (UNOP_PREDECREMENT); }
289 exp : exp INCREMENT %prec UNARY
290 { write_exp_elt_opcode (UNOP_POSTINCREMENT); }
293 exp : exp DECREMENT %prec UNARY
294 { write_exp_elt_opcode (UNOP_POSTDECREMENT); }
297 exp : SIZEOF exp %prec UNARY
298 { write_exp_elt_opcode (UNOP_SIZEOF); }
302 { write_exp_elt_opcode (STRUCTOP_PTR);
303 write_exp_string ($3);
304 write_exp_elt_opcode (STRUCTOP_PTR); }
307 exp : exp ARROW name COMPLETE
308 { mark_struct_expression ();
309 write_exp_elt_opcode (STRUCTOP_PTR);
310 write_exp_string ($3);
311 write_exp_elt_opcode (STRUCTOP_PTR); }
314 exp : exp ARROW COMPLETE
316 mark_struct_expression ();
317 write_exp_elt_opcode (STRUCTOP_PTR);
320 write_exp_string (s);
321 write_exp_elt_opcode (STRUCTOP_PTR); }
324 exp : exp ARROW qualified_name
325 { /* exp->type::name becomes exp->*(&type::name) */
326 /* Note: this doesn't work if name is a
327 static member! FIXME */
328 write_exp_elt_opcode (UNOP_ADDR);
329 write_exp_elt_opcode (STRUCTOP_MPTR); }
332 exp : exp ARROW '*' exp
333 { write_exp_elt_opcode (STRUCTOP_MPTR); }
337 { write_exp_elt_opcode (STRUCTOP_STRUCT);
338 write_exp_string ($3);
339 write_exp_elt_opcode (STRUCTOP_STRUCT); }
342 exp : exp '.' name COMPLETE
343 { mark_struct_expression ();
344 write_exp_elt_opcode (STRUCTOP_STRUCT);
345 write_exp_string ($3);
346 write_exp_elt_opcode (STRUCTOP_STRUCT); }
349 exp : exp '.' COMPLETE
351 mark_struct_expression ();
352 write_exp_elt_opcode (STRUCTOP_STRUCT);
355 write_exp_string (s);
356 write_exp_elt_opcode (STRUCTOP_STRUCT); }
359 exp : exp '.' qualified_name
360 { /* exp.type::name becomes exp.*(&type::name) */
361 /* Note: this doesn't work if name is a
362 static member! FIXME */
363 write_exp_elt_opcode (UNOP_ADDR);
364 write_exp_elt_opcode (STRUCTOP_MEMBER); }
367 exp : exp '.' '*' exp
368 { write_exp_elt_opcode (STRUCTOP_MEMBER); }
371 exp : exp '[' exp1 ']'
372 { write_exp_elt_opcode (BINOP_SUBSCRIPT); }
376 /* This is to save the value of arglist_len
377 being accumulated by an outer function call. */
378 { start_arglist (); }
379 arglist ')' %prec ARROW
380 { write_exp_elt_opcode (OP_FUNCALL);
381 write_exp_elt_longcst ((LONGEST) end_arglist ());
382 write_exp_elt_opcode (OP_FUNCALL); }
386 { start_arglist (); }
396 arglist : arglist ',' exp %prec ABOVE_COMMA
401 { $$ = end_arglist () - 1; }
403 exp : lcurly arglist rcurly %prec ARROW
404 { write_exp_elt_opcode (OP_ARRAY);
405 write_exp_elt_longcst ((LONGEST) 0);
406 write_exp_elt_longcst ((LONGEST) $3);
407 write_exp_elt_opcode (OP_ARRAY); }
410 exp : lcurly type rcurly exp %prec UNARY
411 { write_exp_elt_opcode (UNOP_MEMVAL);
412 write_exp_elt_type ($2);
413 write_exp_elt_opcode (UNOP_MEMVAL); }
416 exp : '(' type ')' exp %prec UNARY
417 { write_exp_elt_opcode (UNOP_CAST);
418 write_exp_elt_type ($2);
419 write_exp_elt_opcode (UNOP_CAST); }
426 /* Binary operators in order of decreasing precedence. */
429 { write_exp_elt_opcode (BINOP_REPEAT); }
433 { write_exp_elt_opcode (BINOP_MUL); }
437 { write_exp_elt_opcode (BINOP_DIV); }
441 { write_exp_elt_opcode (BINOP_REM); }
445 { write_exp_elt_opcode (BINOP_ADD); }
449 { write_exp_elt_opcode (BINOP_SUB); }
453 { write_exp_elt_opcode (BINOP_LSH); }
457 { write_exp_elt_opcode (BINOP_RSH); }
461 { write_exp_elt_opcode (BINOP_EQUAL); }
464 exp : exp NOTEQUAL exp
465 { write_exp_elt_opcode (BINOP_NOTEQUAL); }
469 { write_exp_elt_opcode (BINOP_LEQ); }
473 { write_exp_elt_opcode (BINOP_GEQ); }
477 { write_exp_elt_opcode (BINOP_LESS); }
481 { write_exp_elt_opcode (BINOP_GTR); }
485 { write_exp_elt_opcode (BINOP_BITWISE_AND); }
489 { write_exp_elt_opcode (BINOP_BITWISE_XOR); }
493 { write_exp_elt_opcode (BINOP_BITWISE_IOR); }
497 { write_exp_elt_opcode (BINOP_LOGICAL_AND); }
501 { write_exp_elt_opcode (BINOP_LOGICAL_OR); }
504 exp : exp '?' exp ':' exp %prec '?'
505 { write_exp_elt_opcode (TERNOP_COND); }
509 { write_exp_elt_opcode (BINOP_ASSIGN); }
512 exp : exp ASSIGN_MODIFY exp
513 { write_exp_elt_opcode (BINOP_ASSIGN_MODIFY);
514 write_exp_elt_opcode ($2);
515 write_exp_elt_opcode (BINOP_ASSIGN_MODIFY); }
519 { write_exp_elt_opcode (OP_LONG);
520 write_exp_elt_type ($1.type);
521 write_exp_elt_longcst ((LONGEST)($1.val));
522 write_exp_elt_opcode (OP_LONG); }
527 parse_number ($1.stoken.ptr, $1.stoken.length, 0, &val);
528 write_exp_elt_opcode (OP_LONG);
529 write_exp_elt_type (val.typed_val_int.type);
530 write_exp_elt_longcst ((LONGEST)val.typed_val_int.val);
531 write_exp_elt_opcode (OP_LONG);
537 { write_exp_elt_opcode (OP_DOUBLE);
538 write_exp_elt_type ($1.type);
539 write_exp_elt_dblcst ($1.dval);
540 write_exp_elt_opcode (OP_DOUBLE); }
544 { write_exp_elt_opcode (OP_DECFLOAT);
545 write_exp_elt_type ($1.type);
546 write_exp_elt_decfloatcst ($1.val);
547 write_exp_elt_opcode (OP_DECFLOAT); }
554 /* Already written by write_dollar_variable. */
557 exp : SIZEOF '(' type ')' %prec UNARY
558 { write_exp_elt_opcode (OP_LONG);
559 write_exp_elt_type (parse_type->builtin_int);
561 write_exp_elt_longcst ((LONGEST) TYPE_LENGTH ($3));
562 write_exp_elt_opcode (OP_LONG); }
566 { /* C strings are converted into array constants with
567 an explicit null byte added at the end. Thus
568 the array upper bound is the string length.
569 There is no such thing in C as a completely empty
571 char *sp = $1.ptr; int count = $1.length;
574 write_exp_elt_opcode (OP_LONG);
575 write_exp_elt_type (parse_type->builtin_char);
576 write_exp_elt_longcst ((LONGEST)(*sp++));
577 write_exp_elt_opcode (OP_LONG);
579 write_exp_elt_opcode (OP_LONG);
580 write_exp_elt_type (parse_type->builtin_char);
581 write_exp_elt_longcst ((LONGEST)'\0');
582 write_exp_elt_opcode (OP_LONG);
583 write_exp_elt_opcode (OP_ARRAY);
584 write_exp_elt_longcst ((LONGEST) 0);
585 write_exp_elt_longcst ((LONGEST) ($1.length));
586 write_exp_elt_opcode (OP_ARRAY); }
591 { write_exp_elt_opcode (OP_LONG);
592 write_exp_elt_type (parse_type->builtin_bool);
593 write_exp_elt_longcst ((LONGEST) 1);
594 write_exp_elt_opcode (OP_LONG); }
598 { write_exp_elt_opcode (OP_LONG);
599 write_exp_elt_type (parse_type->builtin_bool);
600 write_exp_elt_longcst ((LONGEST) 0);
601 write_exp_elt_opcode (OP_LONG); }
609 $$ = SYMBOL_BLOCK_VALUE ($1.sym);
611 error ("No file or function \"%s\".",
612 copy_name ($1.stoken));
620 block : block COLONCOLON name
622 = lookup_symbol (copy_name ($3), $1,
623 VAR_DOMAIN, (int *) NULL);
624 if (!tem || SYMBOL_CLASS (tem) != LOC_BLOCK)
625 error ("No function \"%s\" in specified context.",
627 $$ = SYMBOL_BLOCK_VALUE (tem); }
630 variable: block COLONCOLON name
631 { struct symbol *sym;
632 sym = lookup_symbol (copy_name ($3), $1,
633 VAR_DOMAIN, (int *) NULL);
635 error ("No symbol \"%s\" in specified context.",
638 write_exp_elt_opcode (OP_VAR_VALUE);
639 /* block_found is set by lookup_symbol. */
640 write_exp_elt_block (block_found);
641 write_exp_elt_sym (sym);
642 write_exp_elt_opcode (OP_VAR_VALUE); }
645 qualified_name: typebase COLONCOLON name
647 struct type *type = $1;
648 if (TYPE_CODE (type) != TYPE_CODE_STRUCT
649 && TYPE_CODE (type) != TYPE_CODE_UNION
650 && TYPE_CODE (type) != TYPE_CODE_NAMESPACE)
651 error ("`%s' is not defined as an aggregate type.",
654 write_exp_elt_opcode (OP_SCOPE);
655 write_exp_elt_type (type);
656 write_exp_string ($3);
657 write_exp_elt_opcode (OP_SCOPE);
659 | typebase COLONCOLON '~' name
661 struct type *type = $1;
662 struct stoken tmp_token;
663 if (TYPE_CODE (type) != TYPE_CODE_STRUCT
664 && TYPE_CODE (type) != TYPE_CODE_UNION
665 && TYPE_CODE (type) != TYPE_CODE_NAMESPACE)
666 error ("`%s' is not defined as an aggregate type.",
669 tmp_token.ptr = (char*) alloca ($4.length + 2);
670 tmp_token.length = $4.length + 1;
671 tmp_token.ptr[0] = '~';
672 memcpy (tmp_token.ptr+1, $4.ptr, $4.length);
673 tmp_token.ptr[tmp_token.length] = 0;
675 /* Check for valid destructor name. */
676 destructor_name_p (tmp_token.ptr, type);
677 write_exp_elt_opcode (OP_SCOPE);
678 write_exp_elt_type (type);
679 write_exp_string (tmp_token);
680 write_exp_elt_opcode (OP_SCOPE);
684 variable: qualified_name
687 char *name = copy_name ($2);
689 struct minimal_symbol *msymbol;
692 lookup_symbol (name, (const struct block *) NULL,
693 VAR_DOMAIN, (int *) NULL);
696 write_exp_elt_opcode (OP_VAR_VALUE);
697 write_exp_elt_block (NULL);
698 write_exp_elt_sym (sym);
699 write_exp_elt_opcode (OP_VAR_VALUE);
703 msymbol = lookup_minimal_symbol (name, NULL, NULL);
705 write_exp_msymbol (msymbol);
706 else if (!have_full_symbols () && !have_partial_symbols ())
707 error ("No symbol table is loaded. Use the \"file\" command.");
709 error ("No symbol \"%s\" in current context.", name);
713 variable: name_not_typename
714 { struct symbol *sym = $1.sym;
718 if (symbol_read_needs_frame (sym))
720 if (innermost_block == 0 ||
721 contained_in (block_found,
723 innermost_block = block_found;
726 write_exp_elt_opcode (OP_VAR_VALUE);
727 /* We want to use the selected frame, not
728 another more inner frame which happens to
729 be in the same block. */
730 write_exp_elt_block (NULL);
731 write_exp_elt_sym (sym);
732 write_exp_elt_opcode (OP_VAR_VALUE);
734 else if ($1.is_a_field_of_this)
736 /* C++: it hangs off of `this'. Must
737 not inadvertently convert from a method call
739 if (innermost_block == 0 ||
740 contained_in (block_found, innermost_block))
741 innermost_block = block_found;
742 write_exp_elt_opcode (OP_THIS);
743 write_exp_elt_opcode (OP_THIS);
744 write_exp_elt_opcode (STRUCTOP_PTR);
745 write_exp_string ($1.stoken);
746 write_exp_elt_opcode (STRUCTOP_PTR);
750 struct minimal_symbol *msymbol;
751 char *arg = copy_name ($1.stoken);
754 lookup_minimal_symbol (arg, NULL, NULL);
756 write_exp_msymbol (msymbol);
757 else if (!have_full_symbols () && !have_partial_symbols ())
758 error ("No symbol table is loaded. Use the \"file\" command.");
760 error ("No symbol \"%s\" in current context.",
761 copy_name ($1.stoken));
766 space_identifier : '@' NAME
767 { push_type_address_space (copy_name ($2.stoken));
768 push_type (tp_space_identifier);
772 const_or_volatile: const_or_volatile_noopt
776 cv_with_space_id : const_or_volatile space_identifier const_or_volatile
779 const_or_volatile_or_space_identifier_noopt: cv_with_space_id
780 | const_or_volatile_noopt
783 const_or_volatile_or_space_identifier:
784 const_or_volatile_or_space_identifier_noopt
789 { push_type (tp_pointer); $$ = 0; }
791 { push_type (tp_pointer); $$ = $2; }
793 { push_type (tp_reference); $$ = 0; }
795 { push_type (tp_reference); $$ = $2; }
799 direct_abs_decl: '(' abs_decl ')'
801 | direct_abs_decl array_mod
804 push_type (tp_array);
809 push_type (tp_array);
813 | direct_abs_decl func_mod
814 { push_type (tp_function); }
816 { push_type (tp_function); }
827 | '(' nonempty_typelist ')'
828 { free ($2); $$ = 0; }
831 /* We used to try to recognize pointer to member types here, but
832 that didn't work (shift/reduce conflicts meant that these rules never
833 got executed). The problem is that
834 int (foo::bar::baz::bizzle)
835 is a function type but
836 int (foo::bar::baz::bizzle::*)
837 is a pointer to member type. Stroustrup loses again! */
842 typebase /* Implements (approximately): (type-qualifier)* type-specifier */
846 { $$ = parse_type->builtin_int; }
848 { $$ = parse_type->builtin_long; }
850 { $$ = parse_type->builtin_short; }
852 { $$ = parse_type->builtin_long; }
853 | LONG SIGNED_KEYWORD INT_KEYWORD
854 { $$ = parse_type->builtin_long; }
855 | LONG SIGNED_KEYWORD
856 { $$ = parse_type->builtin_long; }
857 | SIGNED_KEYWORD LONG INT_KEYWORD
858 { $$ = parse_type->builtin_long; }
859 | UNSIGNED LONG INT_KEYWORD
860 { $$ = parse_type->builtin_unsigned_long; }
861 | LONG UNSIGNED INT_KEYWORD
862 { $$ = parse_type->builtin_unsigned_long; }
864 { $$ = parse_type->builtin_unsigned_long; }
866 { $$ = parse_type->builtin_long_long; }
867 | LONG LONG INT_KEYWORD
868 { $$ = parse_type->builtin_long_long; }
869 | LONG LONG SIGNED_KEYWORD INT_KEYWORD
870 { $$ = parse_type->builtin_long_long; }
871 | LONG LONG SIGNED_KEYWORD
872 { $$ = parse_type->builtin_long_long; }
873 | SIGNED_KEYWORD LONG LONG
874 { $$ = parse_type->builtin_long_long; }
875 | SIGNED_KEYWORD LONG LONG INT_KEYWORD
876 { $$ = parse_type->builtin_long_long; }
878 { $$ = parse_type->builtin_unsigned_long_long; }
879 | UNSIGNED LONG LONG INT_KEYWORD
880 { $$ = parse_type->builtin_unsigned_long_long; }
882 { $$ = parse_type->builtin_unsigned_long_long; }
883 | LONG LONG UNSIGNED INT_KEYWORD
884 { $$ = parse_type->builtin_unsigned_long_long; }
886 { $$ = parse_type->builtin_short; }
887 | SHORT SIGNED_KEYWORD INT_KEYWORD
888 { $$ = parse_type->builtin_short; }
889 | SHORT SIGNED_KEYWORD
890 { $$ = parse_type->builtin_short; }
891 | UNSIGNED SHORT INT_KEYWORD
892 { $$ = parse_type->builtin_unsigned_short; }
894 { $$ = parse_type->builtin_unsigned_short; }
895 | SHORT UNSIGNED INT_KEYWORD
896 { $$ = parse_type->builtin_unsigned_short; }
898 { $$ = parse_type->builtin_double; }
899 | LONG DOUBLE_KEYWORD
900 { $$ = parse_type->builtin_long_double; }
902 { $$ = lookup_struct (copy_name ($2),
903 expression_context_block); }
905 { $$ = lookup_struct (copy_name ($2),
906 expression_context_block); }
908 { $$ = lookup_union (copy_name ($2),
909 expression_context_block); }
911 { $$ = lookup_enum (copy_name ($2),
912 expression_context_block); }
914 { $$ = lookup_unsigned_typename (TYPE_NAME($2.type)); }
916 { $$ = parse_type->builtin_unsigned_int; }
917 | SIGNED_KEYWORD typename
918 { $$ = lookup_signed_typename (TYPE_NAME($2.type)); }
920 { $$ = parse_type->builtin_int; }
921 /* It appears that this rule for templates is never
922 reduced; template recognition happens by lookahead
923 in the token processing code in yylex. */
924 | TEMPLATE name '<' type '>'
925 { $$ = lookup_template_type(copy_name($2), $4,
926 expression_context_block);
928 | const_or_volatile_or_space_identifier_noopt typebase
929 { $$ = follow_types ($2); }
930 | typebase const_or_volatile_or_space_identifier_noopt
931 { $$ = follow_types ($1); }
935 /* FIXME: carlton/2003-09-25: This next bit leads to lots of
936 reduce-reduce conflicts, because the parser doesn't know whether or
937 not to use qualified_name or qualified_type: the rules are
938 identical. If the parser is parsing 'A::B::x', then, when it sees
939 the second '::', it knows that the expression to the left of it has
940 to be a type, so it uses qualified_type. But if it is parsing just
941 'A::B', then it doesn't have any way of knowing which rule to use,
942 so there's a reduce-reduce conflict; it picks qualified_name, since
943 that occurs earlier in this file than qualified_type.
945 There's no good way to fix this with the grammar as it stands; as
946 far as I can tell, some of the problems arise from ambiguities that
947 GDB introduces ('start' can be either an expression or a type), but
948 some of it is inherent to the nature of C++ (you want to treat the
949 input "(FOO)" fairly differently depending on whether FOO is an
950 expression or a type, and if FOO is a complex expression, this can
951 be hard to determine at the right time). Fortunately, it works
952 pretty well in most cases. For example, if you do 'ptype A::B',
953 where A::B is a nested type, then the parser will mistakenly
954 misidentify it as an expression; but evaluate_subexp will get
955 called with 'noside' set to EVAL_AVOID_SIDE_EFFECTS, and everything
956 will work out anyways. But there are situations where the parser
957 will get confused: the most common one that I've run into is when
962 where the parser doesn't realize that A::B has to be a type until
963 it hits the first right paren, at which point it's too late. (The
964 workaround is to type "print *(('A::B' *) x)" instead.) (And
965 another solution is to fix our symbol-handling code so that the
966 user never wants to type something like that in the first place,
967 because we get all the types right without the user's help!)
969 Perhaps we could fix this by making the lexer smarter. Some of
970 this functionality used to be in the lexer, but in a way that
971 worked even less well than the current solution: that attempt
972 involved having the parser sometimes handle '::' and having the
973 lexer sometimes handle it, and without a clear division of
974 responsibility, it quickly degenerated into a big mess. Probably
975 the eventual correct solution will give more of a role to the lexer
976 (ideally via code that is shared between the lexer and
977 decode_line_1), but I'm not holding my breath waiting for somebody
978 to get around to cleaning this up... */
980 qualified_type: typebase COLONCOLON name
982 struct type *type = $1;
983 struct type *new_type;
984 char *ncopy = alloca ($3.length + 1);
986 memcpy (ncopy, $3.ptr, $3.length);
987 ncopy[$3.length] = '\0';
989 if (TYPE_CODE (type) != TYPE_CODE_STRUCT
990 && TYPE_CODE (type) != TYPE_CODE_UNION
991 && TYPE_CODE (type) != TYPE_CODE_NAMESPACE)
992 error ("`%s' is not defined as an aggregate type.",
995 new_type = cp_lookup_nested_type (type, ncopy,
996 expression_context_block);
997 if (new_type == NULL)
998 error ("No type \"%s\" within class or namespace \"%s\".",
999 ncopy, TYPE_NAME (type));
1008 $$.stoken.ptr = "int";
1009 $$.stoken.length = 3;
1010 $$.type = parse_type->builtin_int;
1014 $$.stoken.ptr = "long";
1015 $$.stoken.length = 4;
1016 $$.type = parse_type->builtin_long;
1020 $$.stoken.ptr = "short";
1021 $$.stoken.length = 5;
1022 $$.type = parse_type->builtin_short;
1028 { $$ = (struct type **) malloc (sizeof (struct type *) * 2);
1029 $<ivec>$[0] = 1; /* Number of types in vector */
1032 | nonempty_typelist ',' type
1033 { int len = sizeof (struct type *) * (++($<ivec>1[0]) + 1);
1034 $$ = (struct type **) realloc ((char *) $1, len);
1035 $$[$<ivec>$[0]] = $3;
1040 | ptype const_or_volatile_or_space_identifier abs_decl const_or_volatile_or_space_identifier
1041 { $$ = follow_types ($1); }
1044 const_and_volatile: CONST_KEYWORD VOLATILE_KEYWORD
1045 | VOLATILE_KEYWORD CONST_KEYWORD
1048 const_or_volatile_noopt: const_and_volatile
1049 { push_type (tp_const);
1050 push_type (tp_volatile);
1053 { push_type (tp_const); }
1055 { push_type (tp_volatile); }
1058 name : NAME { $$ = $1.stoken; }
1059 | BLOCKNAME { $$ = $1.stoken; }
1060 | TYPENAME { $$ = $1.stoken; }
1061 | NAME_OR_INT { $$ = $1.stoken; }
1064 name_not_typename : NAME
1066 /* These would be useful if name_not_typename was useful, but it is just
1067 a fake for "variable", so these cause reduce/reduce conflicts because
1068 the parser can't tell whether NAME_OR_INT is a name_not_typename (=variable,
1069 =exp) or just an exp. If name_not_typename was ever used in an lvalue
1070 context where only a name could occur, this might be useful.
1077 /* Take care of parsing a number (anything that starts with a digit).
1078 Set yylval and return the token type; update lexptr.
1079 LEN is the number of characters in it. */
1081 /*** Needs some error checking for the float case ***/
1084 parse_number (p, len, parsed_float, putithere)
1090 /* FIXME: Shouldn't these be unsigned? We don't deal with negative values
1091 here, and we do kind of silly things like cast to unsigned. */
1098 int base = input_radix;
1101 /* Number of "L" suffixes encountered. */
1104 /* We have found a "L" or "U" suffix. */
1105 int found_suffix = 0;
1108 struct type *signed_type;
1109 struct type *unsigned_type;
1113 /* It's a float since it contains a point or an exponent. */
1115 int num; /* number of tokens scanned by scanf */
1118 /* If it ends at "df", "dd" or "dl", take it as type of decimal floating
1119 point. Return DECFLOAT. */
1121 if (len >= 2 && p[len - 2] == 'd' && p[len - 1] == 'f')
1124 putithere->typed_val_decfloat.type
1125 = parse_type->builtin_decfloat;
1126 decimal_from_string (putithere->typed_val_decfloat.val, 4, p);
1131 if (len >= 2 && p[len - 2] == 'd' && p[len - 1] == 'd')
1134 putithere->typed_val_decfloat.type
1135 = parse_type->builtin_decdouble;
1136 decimal_from_string (putithere->typed_val_decfloat.val, 8, p);
1141 if (len >= 2 && p[len - 2] == 'd' && p[len - 1] == 'l')
1144 putithere->typed_val_decfloat.type
1145 = parse_type->builtin_declong;
1146 decimal_from_string (putithere->typed_val_decfloat.val, 16, p);
1152 saved_char = p[len];
1153 p[len] = 0; /* null-terminate the token */
1154 num = sscanf (p, "%" DOUBLEST_SCAN_FORMAT "%s",
1155 &putithere->typed_val_float.dval, s);
1156 p[len] = saved_char; /* restore the input stream */
1159 putithere->typed_val_float.type =
1160 parse_type->builtin_double;
1164 /* See if it has any float suffix: 'f' for float, 'l' for long
1166 if (!strcasecmp (s, "f"))
1167 putithere->typed_val_float.type =
1168 parse_type->builtin_float;
1169 else if (!strcasecmp (s, "l"))
1170 putithere->typed_val_float.type =
1171 parse_type->builtin_long_double;
1183 /* Handle base-switching prefixes 0x, 0t, 0d, 0 */
1217 if (c >= 'A' && c <= 'Z')
1219 if (c != 'l' && c != 'u')
1221 if (c >= '0' && c <= '9')
1229 if (base > 10 && c >= 'a' && c <= 'f')
1233 n += i = c - 'a' + 10;
1246 return ERROR; /* Char not a digit */
1249 return ERROR; /* Invalid digit in this base */
1251 /* Portably test for overflow (only works for nonzero values, so make
1252 a second check for zero). FIXME: Can't we just make n and prevn
1253 unsigned and avoid this? */
1254 if (c != 'l' && c != 'u' && (prevn >= n) && n != 0)
1255 unsigned_p = 1; /* Try something unsigned */
1257 /* Portably test for unsigned overflow.
1258 FIXME: This check is wrong; for example it doesn't find overflow
1259 on 0x123456789 when LONGEST is 32 bits. */
1260 if (c != 'l' && c != 'u' && n != 0)
1262 if ((unsigned_p && (ULONGEST) prevn >= (ULONGEST) n))
1263 error ("Numeric constant too large.");
1268 /* An integer constant is an int, a long, or a long long. An L
1269 suffix forces it to be long; an LL suffix forces it to be long
1270 long. If not forced to a larger size, it gets the first type of
1271 the above that it fits in. To figure out whether it fits, we
1272 shift it right and see whether anything remains. Note that we
1273 can't shift sizeof (LONGEST) * HOST_CHAR_BIT bits or more in one
1274 operation, because many compilers will warn about such a shift
1275 (which always produces a zero result). Sometimes gdbarch_int_bit
1276 or gdbarch_long_bit will be that big, sometimes not. To deal with
1277 the case where it is we just always shift the value more than
1278 once, with fewer bits each time. */
1280 un = (ULONGEST)n >> 2;
1282 && (un >> (gdbarch_int_bit (parse_gdbarch) - 2)) == 0)
1284 high_bit = ((ULONGEST)1) << (gdbarch_int_bit (parse_gdbarch) - 1);
1286 /* A large decimal (not hex or octal) constant (between INT_MAX
1287 and UINT_MAX) is a long or unsigned long, according to ANSI,
1288 never an unsigned int, but this code treats it as unsigned
1289 int. This probably should be fixed. GCC gives a warning on
1292 unsigned_type = parse_type->builtin_unsigned_int;
1293 signed_type = parse_type->builtin_int;
1295 else if (long_p <= 1
1296 && (un >> (gdbarch_long_bit (parse_gdbarch) - 2)) == 0)
1298 high_bit = ((ULONGEST)1) << (gdbarch_long_bit (parse_gdbarch) - 1);
1299 unsigned_type = parse_type->builtin_unsigned_long;
1300 signed_type = parse_type->builtin_long;
1305 if (sizeof (ULONGEST) * HOST_CHAR_BIT
1306 < gdbarch_long_long_bit (parse_gdbarch))
1307 /* A long long does not fit in a LONGEST. */
1308 shift = (sizeof (ULONGEST) * HOST_CHAR_BIT - 1);
1310 shift = (gdbarch_long_long_bit (parse_gdbarch) - 1);
1311 high_bit = (ULONGEST) 1 << shift;
1312 unsigned_type = parse_type->builtin_unsigned_long_long;
1313 signed_type = parse_type->builtin_long_long;
1316 putithere->typed_val_int.val = n;
1318 /* If the high bit of the worked out type is set then this number
1319 has to be unsigned. */
1321 if (unsigned_p || (n & high_bit))
1323 putithere->typed_val_int.type = unsigned_type;
1327 putithere->typed_val_int.type = signed_type;
1337 enum exp_opcode opcode;
1340 static const struct token tokentab3[] =
1342 {">>=", ASSIGN_MODIFY, BINOP_RSH},
1343 {"<<=", ASSIGN_MODIFY, BINOP_LSH}
1346 static const struct token tokentab2[] =
1348 {"+=", ASSIGN_MODIFY, BINOP_ADD},
1349 {"-=", ASSIGN_MODIFY, BINOP_SUB},
1350 {"*=", ASSIGN_MODIFY, BINOP_MUL},
1351 {"/=", ASSIGN_MODIFY, BINOP_DIV},
1352 {"%=", ASSIGN_MODIFY, BINOP_REM},
1353 {"|=", ASSIGN_MODIFY, BINOP_BITWISE_IOR},
1354 {"&=", ASSIGN_MODIFY, BINOP_BITWISE_AND},
1355 {"^=", ASSIGN_MODIFY, BINOP_BITWISE_XOR},
1356 {"++", INCREMENT, BINOP_END},
1357 {"--", DECREMENT, BINOP_END},
1358 {"->", ARROW, BINOP_END},
1359 {"&&", ANDAND, BINOP_END},
1360 {"||", OROR, BINOP_END},
1361 {"::", COLONCOLON, BINOP_END},
1362 {"<<", LSH, BINOP_END},
1363 {">>", RSH, BINOP_END},
1364 {"==", EQUAL, BINOP_END},
1365 {"!=", NOTEQUAL, BINOP_END},
1366 {"<=", LEQ, BINOP_END},
1367 {">=", GEQ, BINOP_END}
1370 /* This is set if a NAME token appeared at the very end of the input
1371 string, with no whitespace separating the name from the EOF. This
1372 is used only when parsing to do field name completion. */
1373 static int saw_name_at_eof;
1375 /* This is set if the previously-returned token was a structure
1376 operator -- either '.' or ARROW. This is used only when parsing to
1377 do field name completion. */
1378 static int last_was_structop;
1380 /* Read one token, getting characters through lexptr. */
1391 static char *tempbuf;
1392 static int tempbufsize;
1393 char * token_string = NULL;
1394 int class_prefix = 0;
1395 int saw_structop = last_was_structop;
1397 last_was_structop = 0;
1401 /* Check if this is a macro invocation that we need to expand. */
1402 if (! scanning_macro_expansion ())
1404 char *expanded = macro_expand_next (&lexptr,
1405 expression_macro_lookup_func,
1406 expression_macro_lookup_baton);
1409 scan_macro_expansion (expanded);
1412 prev_lexptr = lexptr;
1415 /* See if it is a special token of length 3. */
1416 for (i = 0; i < sizeof tokentab3 / sizeof tokentab3[0]; i++)
1417 if (strncmp (tokstart, tokentab3[i].operator, 3) == 0)
1420 yylval.opcode = tokentab3[i].opcode;
1421 return tokentab3[i].token;
1424 /* See if it is a special token of length 2. */
1425 for (i = 0; i < sizeof tokentab2 / sizeof tokentab2[0]; i++)
1426 if (strncmp (tokstart, tokentab2[i].operator, 2) == 0)
1429 yylval.opcode = tokentab2[i].opcode;
1430 if (in_parse_field && tokentab2[i].token == ARROW)
1431 last_was_structop = 1;
1432 return tokentab2[i].token;
1435 switch (c = *tokstart)
1438 /* If we were just scanning the result of a macro expansion,
1439 then we need to resume scanning the original text.
1440 If we're parsing for field name completion, and the previous
1441 token allows such completion, return a COMPLETE token.
1442 Otherwise, we were already scanning the original text, and
1443 we're really done. */
1444 if (scanning_macro_expansion ())
1446 finished_macro_expansion ();
1449 else if (saw_name_at_eof)
1451 saw_name_at_eof = 0;
1454 else if (saw_structop)
1466 /* We either have a character constant ('0' or '\177' for example)
1467 or we have a quoted symbol reference ('foo(int,int)' in C++
1472 c = parse_escape (&lexptr);
1474 error ("Empty character constant.");
1475 else if (! host_char_to_target (c, &c))
1477 int toklen = lexptr - tokstart + 1;
1478 char *tok = alloca (toklen + 1);
1479 memcpy (tok, tokstart, toklen);
1481 error ("There is no character corresponding to %s in the target "
1482 "character set `%s'.", tok, target_charset ());
1485 yylval.typed_val_int.val = c;
1486 yylval.typed_val_int.type = parse_type->builtin_char;
1491 namelen = skip_quoted (tokstart) - tokstart;
1494 lexptr = tokstart + namelen;
1495 if (lexptr[-1] != '\'')
1496 error ("Unmatched single quote.");
1501 error ("Invalid character constant.");
1511 if (paren_depth == 0)
1518 if (comma_terminates
1520 && ! scanning_macro_expansion ())
1526 /* Might be a floating point number. */
1527 if (lexptr[1] < '0' || lexptr[1] > '9')
1530 last_was_structop = 1;
1531 goto symbol; /* Nope, must be a symbol. */
1533 /* FALL THRU into number case. */
1546 /* It's a number. */
1547 int got_dot = 0, got_e = 0, toktype;
1549 int hex = input_radix > 10;
1551 if (c == '0' && (p[1] == 'x' || p[1] == 'X'))
1556 else if (c == '0' && (p[1]=='t' || p[1]=='T' || p[1]=='d' || p[1]=='D'))
1564 /* This test includes !hex because 'e' is a valid hex digit
1565 and thus does not indicate a floating point number when
1566 the radix is hex. */
1567 if (!hex && !got_e && (*p == 'e' || *p == 'E'))
1568 got_dot = got_e = 1;
1569 /* This test does not include !hex, because a '.' always indicates
1570 a decimal floating point number regardless of the radix. */
1571 else if (!got_dot && *p == '.')
1573 else if (got_e && (p[-1] == 'e' || p[-1] == 'E')
1574 && (*p == '-' || *p == '+'))
1575 /* This is the sign of the exponent, not the end of the
1578 /* We will take any letters or digits. parse_number will
1579 complain if past the radix, or if L or U are not final. */
1580 else if ((*p < '0' || *p > '9')
1581 && ((*p < 'a' || *p > 'z')
1582 && (*p < 'A' || *p > 'Z')))
1585 toktype = parse_number (tokstart, p - tokstart, got_dot|got_e, &yylval);
1586 if (toktype == ERROR)
1588 char *err_copy = (char *) alloca (p - tokstart + 1);
1590 memcpy (err_copy, tokstart, p - tokstart);
1591 err_copy[p - tokstart] = 0;
1592 error ("Invalid number \"%s\".", err_copy);
1624 /* Build the gdb internal form of the input string in tempbuf,
1625 translating any standard C escape forms seen. Note that the
1626 buffer is null byte terminated *only* for the convenience of
1627 debugging gdb itself and printing the buffer contents when
1628 the buffer contains no embedded nulls. Gdb does not depend
1629 upon the buffer being null byte terminated, it uses the length
1630 string instead. This allows gdb to handle C strings (as well
1631 as strings in other languages) with embedded null bytes */
1633 tokptr = ++tokstart;
1637 char *char_start_pos = tokptr;
1639 /* Grow the static temp buffer if necessary, including allocating
1640 the first one on demand. */
1641 if (tempbufindex + 1 >= tempbufsize)
1643 tempbuf = (char *) realloc (tempbuf, tempbufsize += 64);
1649 /* Do nothing, loop will terminate. */
1653 c = parse_escape (&tokptr);
1658 tempbuf[tempbufindex++] = c;
1662 if (! host_char_to_target (c, &c))
1664 int len = tokptr - char_start_pos;
1665 char *copy = alloca (len + 1);
1666 memcpy (copy, char_start_pos, len);
1669 error ("There is no character corresponding to `%s' "
1670 "in the target character set `%s'.",
1671 copy, target_charset ());
1673 tempbuf[tempbufindex++] = c;
1676 } while ((*tokptr != '"') && (*tokptr != '\0'));
1677 if (*tokptr++ != '"')
1679 error ("Unterminated string in expression.");
1681 tempbuf[tempbufindex] = '\0'; /* See note above */
1682 yylval.sval.ptr = tempbuf;
1683 yylval.sval.length = tempbufindex;
1688 if (!(c == '_' || c == '$'
1689 || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')))
1690 /* We must have come across a bad character (e.g. ';'). */
1691 error ("Invalid character '%c' in expression.", c);
1693 /* It's a name. See how long it is. */
1695 for (c = tokstart[namelen];
1696 (c == '_' || c == '$' || (c >= '0' && c <= '9')
1697 || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '<');)
1699 /* Template parameter lists are part of the name.
1700 FIXME: This mishandles `print $a<4&&$a>3'. */
1704 /* Scan ahead to get rest of the template specification. Note
1705 that we look ahead only when the '<' adjoins non-whitespace
1706 characters; for comparison expressions, e.g. "a < b > c",
1707 there must be spaces before the '<', etc. */
1709 char * p = find_template_name_end (tokstart + namelen);
1711 namelen = p - tokstart;
1714 c = tokstart[++namelen];
1717 /* The token "if" terminates the expression and is NOT removed from
1718 the input stream. It doesn't count if it appears in the
1719 expansion of a macro. */
1721 && tokstart[0] == 'i'
1722 && tokstart[1] == 'f'
1723 && ! scanning_macro_expansion ())
1732 /* Catch specific keywords. Should be done with a data structure. */
1736 if (strncmp (tokstart, "unsigned", 8) == 0)
1738 if (parse_language->la_language == language_cplus
1739 && strncmp (tokstart, "template", 8) == 0)
1741 if (strncmp (tokstart, "volatile", 8) == 0)
1742 return VOLATILE_KEYWORD;
1745 if (strncmp (tokstart, "struct", 6) == 0)
1747 if (strncmp (tokstart, "signed", 6) == 0)
1748 return SIGNED_KEYWORD;
1749 if (strncmp (tokstart, "sizeof", 6) == 0)
1751 if (strncmp (tokstart, "double", 6) == 0)
1752 return DOUBLE_KEYWORD;
1755 if (parse_language->la_language == language_cplus)
1757 if (strncmp (tokstart, "false", 5) == 0)
1758 return FALSEKEYWORD;
1759 if (strncmp (tokstart, "class", 5) == 0)
1762 if (strncmp (tokstart, "union", 5) == 0)
1764 if (strncmp (tokstart, "short", 5) == 0)
1766 if (strncmp (tokstart, "const", 5) == 0)
1767 return CONST_KEYWORD;
1770 if (strncmp (tokstart, "enum", 4) == 0)
1772 if (strncmp (tokstart, "long", 4) == 0)
1774 if (parse_language->la_language == language_cplus)
1776 if (strncmp (tokstart, "true", 4) == 0)
1781 if (strncmp (tokstart, "int", 3) == 0)
1788 yylval.sval.ptr = tokstart;
1789 yylval.sval.length = namelen;
1791 if (*tokstart == '$')
1793 write_dollar_variable (yylval.sval);
1797 /* Use token-type BLOCKNAME for symbols that happen to be defined as
1798 functions or symtabs. If this is not so, then ...
1799 Use token-type TYPENAME for symbols that happen to be defined
1800 currently as names of types; NAME for other symbols.
1801 The caller is not constrained to care about the distinction. */
1803 char *tmp = copy_name (yylval.sval);
1805 int is_a_field_of_this = 0;
1808 sym = lookup_symbol (tmp, expression_context_block,
1810 parse_language->la_language == language_cplus
1811 ? &is_a_field_of_this : (int *) NULL);
1812 /* Call lookup_symtab, not lookup_partial_symtab, in case there are
1813 no psymtabs (coff, xcoff, or some future change to blow away the
1814 psymtabs once once symbols are read). */
1815 if (sym && SYMBOL_CLASS (sym) == LOC_BLOCK)
1817 yylval.ssym.sym = sym;
1818 yylval.ssym.is_a_field_of_this = is_a_field_of_this;
1822 { /* See if it's a file name. */
1823 struct symtab *symtab;
1825 symtab = lookup_symtab (tmp);
1829 yylval.bval = BLOCKVECTOR_BLOCK (BLOCKVECTOR (symtab), STATIC_BLOCK);
1834 if (sym && SYMBOL_CLASS (sym) == LOC_TYPEDEF)
1836 /* NOTE: carlton/2003-09-25: There used to be code here to
1837 handle nested types. It didn't work very well. See the
1838 comment before qualified_type for more info. */
1839 yylval.tsym.type = SYMBOL_TYPE (sym);
1843 = language_lookup_primitive_type_by_name (parse_language,
1844 parse_gdbarch, tmp);
1845 if (yylval.tsym.type != NULL)
1848 /* Input names that aren't symbols but ARE valid hex numbers,
1849 when the input radix permits them, can be names or numbers
1850 depending on the parse. Note we support radixes > 16 here. */
1852 ((tokstart[0] >= 'a' && tokstart[0] < 'a' + input_radix - 10) ||
1853 (tokstart[0] >= 'A' && tokstart[0] < 'A' + input_radix - 10)))
1855 YYSTYPE newlval; /* Its value is ignored. */
1856 hextype = parse_number (tokstart, namelen, 0, &newlval);
1859 yylval.ssym.sym = sym;
1860 yylval.ssym.is_a_field_of_this = is_a_field_of_this;
1865 /* Any other kind of symbol */
1866 yylval.ssym.sym = sym;
1867 yylval.ssym.is_a_field_of_this = is_a_field_of_this;
1868 if (in_parse_field && *lexptr == '\0')
1869 saw_name_at_eof = 1;
1877 last_was_structop = 0;
1878 saw_name_at_eof = 0;
1887 lexptr = prev_lexptr;
1889 error ("A %s in expression, near `%s'.", (msg ? msg : "error"), lexptr);