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
187 %type <sval> name string_exp
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); }
568 /* We copy the string here, and not in the
569 lexer, to guarantee that we do not leak a
570 string. Note that we follow the
571 NUL-termination convention of the
573 $$.length = $1.length;
574 $$.ptr = malloc ($1.length + 1);
575 memcpy ($$.ptr, $1.ptr, $1.length + 1);
580 /* Note that we NUL-terminate here, but just
583 t.length = $1.length + $2.length;
584 t.ptr = malloc (t.length + 1);
585 memcpy (t.ptr, $1.ptr, $1.length);
586 memcpy (t.ptr + $1.length, $2.ptr, $2.length + 1);
593 { /* C strings are converted into array constants with
594 an explicit null byte added at the end. Thus
595 the array upper bound is the string length.
596 There is no such thing in C as a completely empty
598 char *sp = $1.ptr; int count = $1.length;
601 write_exp_elt_opcode (OP_LONG);
602 write_exp_elt_type (parse_type->builtin_char);
603 write_exp_elt_longcst ((LONGEST)(*sp++));
604 write_exp_elt_opcode (OP_LONG);
606 write_exp_elt_opcode (OP_LONG);
607 write_exp_elt_type (parse_type->builtin_char);
608 write_exp_elt_longcst ((LONGEST)'\0');
609 write_exp_elt_opcode (OP_LONG);
610 write_exp_elt_opcode (OP_ARRAY);
611 write_exp_elt_longcst ((LONGEST) 0);
612 write_exp_elt_longcst ((LONGEST) ($1.length));
613 write_exp_elt_opcode (OP_ARRAY);
620 { write_exp_elt_opcode (OP_LONG);
621 write_exp_elt_type (parse_type->builtin_bool);
622 write_exp_elt_longcst ((LONGEST) 1);
623 write_exp_elt_opcode (OP_LONG); }
627 { write_exp_elt_opcode (OP_LONG);
628 write_exp_elt_type (parse_type->builtin_bool);
629 write_exp_elt_longcst ((LONGEST) 0);
630 write_exp_elt_opcode (OP_LONG); }
638 $$ = SYMBOL_BLOCK_VALUE ($1.sym);
640 error ("No file or function \"%s\".",
641 copy_name ($1.stoken));
649 block : block COLONCOLON name
651 = lookup_symbol (copy_name ($3), $1,
652 VAR_DOMAIN, (int *) NULL);
653 if (!tem || SYMBOL_CLASS (tem) != LOC_BLOCK)
654 error ("No function \"%s\" in specified context.",
656 $$ = SYMBOL_BLOCK_VALUE (tem); }
659 variable: block COLONCOLON name
660 { struct symbol *sym;
661 sym = lookup_symbol (copy_name ($3), $1,
662 VAR_DOMAIN, (int *) NULL);
664 error ("No symbol \"%s\" in specified context.",
667 write_exp_elt_opcode (OP_VAR_VALUE);
668 /* block_found is set by lookup_symbol. */
669 write_exp_elt_block (block_found);
670 write_exp_elt_sym (sym);
671 write_exp_elt_opcode (OP_VAR_VALUE); }
674 qualified_name: typebase COLONCOLON name
676 struct type *type = $1;
677 if (TYPE_CODE (type) != TYPE_CODE_STRUCT
678 && TYPE_CODE (type) != TYPE_CODE_UNION
679 && TYPE_CODE (type) != TYPE_CODE_NAMESPACE)
680 error ("`%s' is not defined as an aggregate type.",
683 write_exp_elt_opcode (OP_SCOPE);
684 write_exp_elt_type (type);
685 write_exp_string ($3);
686 write_exp_elt_opcode (OP_SCOPE);
688 | typebase COLONCOLON '~' name
690 struct type *type = $1;
691 struct stoken tmp_token;
692 if (TYPE_CODE (type) != TYPE_CODE_STRUCT
693 && TYPE_CODE (type) != TYPE_CODE_UNION
694 && TYPE_CODE (type) != TYPE_CODE_NAMESPACE)
695 error ("`%s' is not defined as an aggregate type.",
698 tmp_token.ptr = (char*) alloca ($4.length + 2);
699 tmp_token.length = $4.length + 1;
700 tmp_token.ptr[0] = '~';
701 memcpy (tmp_token.ptr+1, $4.ptr, $4.length);
702 tmp_token.ptr[tmp_token.length] = 0;
704 /* Check for valid destructor name. */
705 destructor_name_p (tmp_token.ptr, type);
706 write_exp_elt_opcode (OP_SCOPE);
707 write_exp_elt_type (type);
708 write_exp_string (tmp_token);
709 write_exp_elt_opcode (OP_SCOPE);
713 variable: qualified_name
716 char *name = copy_name ($2);
718 struct minimal_symbol *msymbol;
721 lookup_symbol (name, (const struct block *) NULL,
722 VAR_DOMAIN, (int *) NULL);
725 write_exp_elt_opcode (OP_VAR_VALUE);
726 write_exp_elt_block (NULL);
727 write_exp_elt_sym (sym);
728 write_exp_elt_opcode (OP_VAR_VALUE);
732 msymbol = lookup_minimal_symbol (name, NULL, NULL);
734 write_exp_msymbol (msymbol);
735 else if (!have_full_symbols () && !have_partial_symbols ())
736 error ("No symbol table is loaded. Use the \"file\" command.");
738 error ("No symbol \"%s\" in current context.", name);
742 variable: name_not_typename
743 { struct symbol *sym = $1.sym;
747 if (symbol_read_needs_frame (sym))
749 if (innermost_block == 0 ||
750 contained_in (block_found,
752 innermost_block = block_found;
755 write_exp_elt_opcode (OP_VAR_VALUE);
756 /* We want to use the selected frame, not
757 another more inner frame which happens to
758 be in the same block. */
759 write_exp_elt_block (NULL);
760 write_exp_elt_sym (sym);
761 write_exp_elt_opcode (OP_VAR_VALUE);
763 else if ($1.is_a_field_of_this)
765 /* C++: it hangs off of `this'. Must
766 not inadvertently convert from a method call
768 if (innermost_block == 0 ||
769 contained_in (block_found, innermost_block))
770 innermost_block = block_found;
771 write_exp_elt_opcode (OP_THIS);
772 write_exp_elt_opcode (OP_THIS);
773 write_exp_elt_opcode (STRUCTOP_PTR);
774 write_exp_string ($1.stoken);
775 write_exp_elt_opcode (STRUCTOP_PTR);
779 struct minimal_symbol *msymbol;
780 char *arg = copy_name ($1.stoken);
783 lookup_minimal_symbol (arg, NULL, NULL);
785 write_exp_msymbol (msymbol);
786 else if (!have_full_symbols () && !have_partial_symbols ())
787 error ("No symbol table is loaded. Use the \"file\" command.");
789 error ("No symbol \"%s\" in current context.",
790 copy_name ($1.stoken));
795 space_identifier : '@' NAME
796 { push_type_address_space (copy_name ($2.stoken));
797 push_type (tp_space_identifier);
801 const_or_volatile: const_or_volatile_noopt
805 cv_with_space_id : const_or_volatile space_identifier const_or_volatile
808 const_or_volatile_or_space_identifier_noopt: cv_with_space_id
809 | const_or_volatile_noopt
812 const_or_volatile_or_space_identifier:
813 const_or_volatile_or_space_identifier_noopt
818 { push_type (tp_pointer); $$ = 0; }
820 { push_type (tp_pointer); $$ = $2; }
822 { push_type (tp_reference); $$ = 0; }
824 { push_type (tp_reference); $$ = $2; }
828 direct_abs_decl: '(' abs_decl ')'
830 | direct_abs_decl array_mod
833 push_type (tp_array);
838 push_type (tp_array);
842 | direct_abs_decl func_mod
843 { push_type (tp_function); }
845 { push_type (tp_function); }
856 | '(' nonempty_typelist ')'
857 { free ($2); $$ = 0; }
860 /* We used to try to recognize pointer to member types here, but
861 that didn't work (shift/reduce conflicts meant that these rules never
862 got executed). The problem is that
863 int (foo::bar::baz::bizzle)
864 is a function type but
865 int (foo::bar::baz::bizzle::*)
866 is a pointer to member type. Stroustrup loses again! */
871 typebase /* Implements (approximately): (type-qualifier)* type-specifier */
875 { $$ = parse_type->builtin_int; }
877 { $$ = parse_type->builtin_long; }
879 { $$ = parse_type->builtin_short; }
881 { $$ = parse_type->builtin_long; }
882 | LONG SIGNED_KEYWORD INT_KEYWORD
883 { $$ = parse_type->builtin_long; }
884 | LONG SIGNED_KEYWORD
885 { $$ = parse_type->builtin_long; }
886 | SIGNED_KEYWORD LONG INT_KEYWORD
887 { $$ = parse_type->builtin_long; }
888 | UNSIGNED LONG INT_KEYWORD
889 { $$ = parse_type->builtin_unsigned_long; }
890 | LONG UNSIGNED INT_KEYWORD
891 { $$ = parse_type->builtin_unsigned_long; }
893 { $$ = parse_type->builtin_unsigned_long; }
895 { $$ = parse_type->builtin_long_long; }
896 | LONG LONG INT_KEYWORD
897 { $$ = parse_type->builtin_long_long; }
898 | LONG LONG SIGNED_KEYWORD INT_KEYWORD
899 { $$ = parse_type->builtin_long_long; }
900 | LONG LONG SIGNED_KEYWORD
901 { $$ = parse_type->builtin_long_long; }
902 | SIGNED_KEYWORD LONG LONG
903 { $$ = parse_type->builtin_long_long; }
904 | SIGNED_KEYWORD LONG LONG INT_KEYWORD
905 { $$ = parse_type->builtin_long_long; }
907 { $$ = parse_type->builtin_unsigned_long_long; }
908 | UNSIGNED LONG LONG INT_KEYWORD
909 { $$ = parse_type->builtin_unsigned_long_long; }
911 { $$ = parse_type->builtin_unsigned_long_long; }
912 | LONG LONG UNSIGNED INT_KEYWORD
913 { $$ = parse_type->builtin_unsigned_long_long; }
915 { $$ = parse_type->builtin_short; }
916 | SHORT SIGNED_KEYWORD INT_KEYWORD
917 { $$ = parse_type->builtin_short; }
918 | SHORT SIGNED_KEYWORD
919 { $$ = parse_type->builtin_short; }
920 | UNSIGNED SHORT INT_KEYWORD
921 { $$ = parse_type->builtin_unsigned_short; }
923 { $$ = parse_type->builtin_unsigned_short; }
924 | SHORT UNSIGNED INT_KEYWORD
925 { $$ = parse_type->builtin_unsigned_short; }
927 { $$ = parse_type->builtin_double; }
928 | LONG DOUBLE_KEYWORD
929 { $$ = parse_type->builtin_long_double; }
931 { $$ = lookup_struct (copy_name ($2),
932 expression_context_block); }
934 { $$ = lookup_struct (copy_name ($2),
935 expression_context_block); }
937 { $$ = lookup_union (copy_name ($2),
938 expression_context_block); }
940 { $$ = lookup_enum (copy_name ($2),
941 expression_context_block); }
943 { $$ = lookup_unsigned_typename (TYPE_NAME($2.type)); }
945 { $$ = parse_type->builtin_unsigned_int; }
946 | SIGNED_KEYWORD typename
947 { $$ = lookup_signed_typename (TYPE_NAME($2.type)); }
949 { $$ = parse_type->builtin_int; }
950 /* It appears that this rule for templates is never
951 reduced; template recognition happens by lookahead
952 in the token processing code in yylex. */
953 | TEMPLATE name '<' type '>'
954 { $$ = lookup_template_type(copy_name($2), $4,
955 expression_context_block);
957 | const_or_volatile_or_space_identifier_noopt typebase
958 { $$ = follow_types ($2); }
959 | typebase const_or_volatile_or_space_identifier_noopt
960 { $$ = follow_types ($1); }
964 /* FIXME: carlton/2003-09-25: This next bit leads to lots of
965 reduce-reduce conflicts, because the parser doesn't know whether or
966 not to use qualified_name or qualified_type: the rules are
967 identical. If the parser is parsing 'A::B::x', then, when it sees
968 the second '::', it knows that the expression to the left of it has
969 to be a type, so it uses qualified_type. But if it is parsing just
970 'A::B', then it doesn't have any way of knowing which rule to use,
971 so there's a reduce-reduce conflict; it picks qualified_name, since
972 that occurs earlier in this file than qualified_type.
974 There's no good way to fix this with the grammar as it stands; as
975 far as I can tell, some of the problems arise from ambiguities that
976 GDB introduces ('start' can be either an expression or a type), but
977 some of it is inherent to the nature of C++ (you want to treat the
978 input "(FOO)" fairly differently depending on whether FOO is an
979 expression or a type, and if FOO is a complex expression, this can
980 be hard to determine at the right time). Fortunately, it works
981 pretty well in most cases. For example, if you do 'ptype A::B',
982 where A::B is a nested type, then the parser will mistakenly
983 misidentify it as an expression; but evaluate_subexp will get
984 called with 'noside' set to EVAL_AVOID_SIDE_EFFECTS, and everything
985 will work out anyways. But there are situations where the parser
986 will get confused: the most common one that I've run into is when
991 where the parser doesn't realize that A::B has to be a type until
992 it hits the first right paren, at which point it's too late. (The
993 workaround is to type "print *(('A::B' *) x)" instead.) (And
994 another solution is to fix our symbol-handling code so that the
995 user never wants to type something like that in the first place,
996 because we get all the types right without the user's help!)
998 Perhaps we could fix this by making the lexer smarter. Some of
999 this functionality used to be in the lexer, but in a way that
1000 worked even less well than the current solution: that attempt
1001 involved having the parser sometimes handle '::' and having the
1002 lexer sometimes handle it, and without a clear division of
1003 responsibility, it quickly degenerated into a big mess. Probably
1004 the eventual correct solution will give more of a role to the lexer
1005 (ideally via code that is shared between the lexer and
1006 decode_line_1), but I'm not holding my breath waiting for somebody
1007 to get around to cleaning this up... */
1009 qualified_type: typebase COLONCOLON name
1011 struct type *type = $1;
1012 struct type *new_type;
1013 char *ncopy = alloca ($3.length + 1);
1015 memcpy (ncopy, $3.ptr, $3.length);
1016 ncopy[$3.length] = '\0';
1018 if (TYPE_CODE (type) != TYPE_CODE_STRUCT
1019 && TYPE_CODE (type) != TYPE_CODE_UNION
1020 && TYPE_CODE (type) != TYPE_CODE_NAMESPACE)
1021 error ("`%s' is not defined as an aggregate type.",
1024 new_type = cp_lookup_nested_type (type, ncopy,
1025 expression_context_block);
1026 if (new_type == NULL)
1027 error ("No type \"%s\" within class or namespace \"%s\".",
1028 ncopy, TYPE_NAME (type));
1037 $$.stoken.ptr = "int";
1038 $$.stoken.length = 3;
1039 $$.type = parse_type->builtin_int;
1043 $$.stoken.ptr = "long";
1044 $$.stoken.length = 4;
1045 $$.type = parse_type->builtin_long;
1049 $$.stoken.ptr = "short";
1050 $$.stoken.length = 5;
1051 $$.type = parse_type->builtin_short;
1057 { $$ = (struct type **) malloc (sizeof (struct type *) * 2);
1058 $<ivec>$[0] = 1; /* Number of types in vector */
1061 | nonempty_typelist ',' type
1062 { int len = sizeof (struct type *) * (++($<ivec>1[0]) + 1);
1063 $$ = (struct type **) realloc ((char *) $1, len);
1064 $$[$<ivec>$[0]] = $3;
1069 | ptype const_or_volatile_or_space_identifier abs_decl const_or_volatile_or_space_identifier
1070 { $$ = follow_types ($1); }
1073 const_and_volatile: CONST_KEYWORD VOLATILE_KEYWORD
1074 | VOLATILE_KEYWORD CONST_KEYWORD
1077 const_or_volatile_noopt: const_and_volatile
1078 { push_type (tp_const);
1079 push_type (tp_volatile);
1082 { push_type (tp_const); }
1084 { push_type (tp_volatile); }
1087 name : NAME { $$ = $1.stoken; }
1088 | BLOCKNAME { $$ = $1.stoken; }
1089 | TYPENAME { $$ = $1.stoken; }
1090 | NAME_OR_INT { $$ = $1.stoken; }
1093 name_not_typename : NAME
1095 /* These would be useful if name_not_typename was useful, but it is just
1096 a fake for "variable", so these cause reduce/reduce conflicts because
1097 the parser can't tell whether NAME_OR_INT is a name_not_typename (=variable,
1098 =exp) or just an exp. If name_not_typename was ever used in an lvalue
1099 context where only a name could occur, this might be useful.
1106 /* Take care of parsing a number (anything that starts with a digit).
1107 Set yylval and return the token type; update lexptr.
1108 LEN is the number of characters in it. */
1110 /*** Needs some error checking for the float case ***/
1113 parse_number (p, len, parsed_float, putithere)
1119 /* FIXME: Shouldn't these be unsigned? We don't deal with negative values
1120 here, and we do kind of silly things like cast to unsigned. */
1127 int base = input_radix;
1130 /* Number of "L" suffixes encountered. */
1133 /* We have found a "L" or "U" suffix. */
1134 int found_suffix = 0;
1137 struct type *signed_type;
1138 struct type *unsigned_type;
1142 /* It's a float since it contains a point or an exponent. */
1144 int num; /* number of tokens scanned by scanf */
1147 /* If it ends at "df", "dd" or "dl", take it as type of decimal floating
1148 point. Return DECFLOAT. */
1150 if (len >= 2 && p[len - 2] == 'd' && p[len - 1] == 'f')
1153 putithere->typed_val_decfloat.type
1154 = parse_type->builtin_decfloat;
1155 decimal_from_string (putithere->typed_val_decfloat.val, 4, p);
1160 if (len >= 2 && p[len - 2] == 'd' && p[len - 1] == 'd')
1163 putithere->typed_val_decfloat.type
1164 = parse_type->builtin_decdouble;
1165 decimal_from_string (putithere->typed_val_decfloat.val, 8, p);
1170 if (len >= 2 && p[len - 2] == 'd' && p[len - 1] == 'l')
1173 putithere->typed_val_decfloat.type
1174 = parse_type->builtin_declong;
1175 decimal_from_string (putithere->typed_val_decfloat.val, 16, p);
1181 saved_char = p[len];
1182 p[len] = 0; /* null-terminate the token */
1183 num = sscanf (p, "%" DOUBLEST_SCAN_FORMAT "%s",
1184 &putithere->typed_val_float.dval, s);
1185 p[len] = saved_char; /* restore the input stream */
1188 putithere->typed_val_float.type =
1189 parse_type->builtin_double;
1193 /* See if it has any float suffix: 'f' for float, 'l' for long
1195 if (!strcasecmp (s, "f"))
1196 putithere->typed_val_float.type =
1197 parse_type->builtin_float;
1198 else if (!strcasecmp (s, "l"))
1199 putithere->typed_val_float.type =
1200 parse_type->builtin_long_double;
1212 /* Handle base-switching prefixes 0x, 0t, 0d, 0 */
1246 if (c >= 'A' && c <= 'Z')
1248 if (c != 'l' && c != 'u')
1250 if (c >= '0' && c <= '9')
1258 if (base > 10 && c >= 'a' && c <= 'f')
1262 n += i = c - 'a' + 10;
1275 return ERROR; /* Char not a digit */
1278 return ERROR; /* Invalid digit in this base */
1280 /* Portably test for overflow (only works for nonzero values, so make
1281 a second check for zero). FIXME: Can't we just make n and prevn
1282 unsigned and avoid this? */
1283 if (c != 'l' && c != 'u' && (prevn >= n) && n != 0)
1284 unsigned_p = 1; /* Try something unsigned */
1286 /* Portably test for unsigned overflow.
1287 FIXME: This check is wrong; for example it doesn't find overflow
1288 on 0x123456789 when LONGEST is 32 bits. */
1289 if (c != 'l' && c != 'u' && n != 0)
1291 if ((unsigned_p && (ULONGEST) prevn >= (ULONGEST) n))
1292 error ("Numeric constant too large.");
1297 /* An integer constant is an int, a long, or a long long. An L
1298 suffix forces it to be long; an LL suffix forces it to be long
1299 long. If not forced to a larger size, it gets the first type of
1300 the above that it fits in. To figure out whether it fits, we
1301 shift it right and see whether anything remains. Note that we
1302 can't shift sizeof (LONGEST) * HOST_CHAR_BIT bits or more in one
1303 operation, because many compilers will warn about such a shift
1304 (which always produces a zero result). Sometimes gdbarch_int_bit
1305 or gdbarch_long_bit will be that big, sometimes not. To deal with
1306 the case where it is we just always shift the value more than
1307 once, with fewer bits each time. */
1309 un = (ULONGEST)n >> 2;
1311 && (un >> (gdbarch_int_bit (parse_gdbarch) - 2)) == 0)
1313 high_bit = ((ULONGEST)1) << (gdbarch_int_bit (parse_gdbarch) - 1);
1315 /* A large decimal (not hex or octal) constant (between INT_MAX
1316 and UINT_MAX) is a long or unsigned long, according to ANSI,
1317 never an unsigned int, but this code treats it as unsigned
1318 int. This probably should be fixed. GCC gives a warning on
1321 unsigned_type = parse_type->builtin_unsigned_int;
1322 signed_type = parse_type->builtin_int;
1324 else if (long_p <= 1
1325 && (un >> (gdbarch_long_bit (parse_gdbarch) - 2)) == 0)
1327 high_bit = ((ULONGEST)1) << (gdbarch_long_bit (parse_gdbarch) - 1);
1328 unsigned_type = parse_type->builtin_unsigned_long;
1329 signed_type = parse_type->builtin_long;
1334 if (sizeof (ULONGEST) * HOST_CHAR_BIT
1335 < gdbarch_long_long_bit (parse_gdbarch))
1336 /* A long long does not fit in a LONGEST. */
1337 shift = (sizeof (ULONGEST) * HOST_CHAR_BIT - 1);
1339 shift = (gdbarch_long_long_bit (parse_gdbarch) - 1);
1340 high_bit = (ULONGEST) 1 << shift;
1341 unsigned_type = parse_type->builtin_unsigned_long_long;
1342 signed_type = parse_type->builtin_long_long;
1345 putithere->typed_val_int.val = n;
1347 /* If the high bit of the worked out type is set then this number
1348 has to be unsigned. */
1350 if (unsigned_p || (n & high_bit))
1352 putithere->typed_val_int.type = unsigned_type;
1356 putithere->typed_val_int.type = signed_type;
1366 enum exp_opcode opcode;
1369 static const struct token tokentab3[] =
1371 {">>=", ASSIGN_MODIFY, BINOP_RSH},
1372 {"<<=", ASSIGN_MODIFY, BINOP_LSH}
1375 static const struct token tokentab2[] =
1377 {"+=", ASSIGN_MODIFY, BINOP_ADD},
1378 {"-=", ASSIGN_MODIFY, BINOP_SUB},
1379 {"*=", ASSIGN_MODIFY, BINOP_MUL},
1380 {"/=", ASSIGN_MODIFY, BINOP_DIV},
1381 {"%=", ASSIGN_MODIFY, BINOP_REM},
1382 {"|=", ASSIGN_MODIFY, BINOP_BITWISE_IOR},
1383 {"&=", ASSIGN_MODIFY, BINOP_BITWISE_AND},
1384 {"^=", ASSIGN_MODIFY, BINOP_BITWISE_XOR},
1385 {"++", INCREMENT, BINOP_END},
1386 {"--", DECREMENT, BINOP_END},
1387 {"->", ARROW, BINOP_END},
1388 {"&&", ANDAND, BINOP_END},
1389 {"||", OROR, BINOP_END},
1390 {"::", COLONCOLON, BINOP_END},
1391 {"<<", LSH, BINOP_END},
1392 {">>", RSH, BINOP_END},
1393 {"==", EQUAL, BINOP_END},
1394 {"!=", NOTEQUAL, BINOP_END},
1395 {"<=", LEQ, BINOP_END},
1396 {">=", GEQ, BINOP_END}
1399 /* This is set if a NAME token appeared at the very end of the input
1400 string, with no whitespace separating the name from the EOF. This
1401 is used only when parsing to do field name completion. */
1402 static int saw_name_at_eof;
1404 /* This is set if the previously-returned token was a structure
1405 operator -- either '.' or ARROW. This is used only when parsing to
1406 do field name completion. */
1407 static int last_was_structop;
1409 /* Read one token, getting characters through lexptr. */
1420 static char *tempbuf;
1421 static int tempbufsize;
1422 char * token_string = NULL;
1423 int class_prefix = 0;
1424 int saw_structop = last_was_structop;
1426 last_was_structop = 0;
1430 /* Check if this is a macro invocation that we need to expand. */
1431 if (! scanning_macro_expansion ())
1433 char *expanded = macro_expand_next (&lexptr,
1434 expression_macro_lookup_func,
1435 expression_macro_lookup_baton);
1438 scan_macro_expansion (expanded);
1441 prev_lexptr = lexptr;
1444 /* See if it is a special token of length 3. */
1445 for (i = 0; i < sizeof tokentab3 / sizeof tokentab3[0]; i++)
1446 if (strncmp (tokstart, tokentab3[i].operator, 3) == 0)
1449 yylval.opcode = tokentab3[i].opcode;
1450 return tokentab3[i].token;
1453 /* See if it is a special token of length 2. */
1454 for (i = 0; i < sizeof tokentab2 / sizeof tokentab2[0]; i++)
1455 if (strncmp (tokstart, tokentab2[i].operator, 2) == 0)
1458 yylval.opcode = tokentab2[i].opcode;
1459 if (in_parse_field && tokentab2[i].token == ARROW)
1460 last_was_structop = 1;
1461 return tokentab2[i].token;
1464 switch (c = *tokstart)
1467 /* If we were just scanning the result of a macro expansion,
1468 then we need to resume scanning the original text.
1469 If we're parsing for field name completion, and the previous
1470 token allows such completion, return a COMPLETE token.
1471 Otherwise, we were already scanning the original text, and
1472 we're really done. */
1473 if (scanning_macro_expansion ())
1475 finished_macro_expansion ();
1478 else if (saw_name_at_eof)
1480 saw_name_at_eof = 0;
1483 else if (saw_structop)
1495 /* We either have a character constant ('0' or '\177' for example)
1496 or we have a quoted symbol reference ('foo(int,int)' in C++
1501 c = parse_escape (&lexptr);
1503 error ("Empty character constant.");
1504 else if (! host_char_to_target (c, &c))
1506 int toklen = lexptr - tokstart + 1;
1507 char *tok = alloca (toklen + 1);
1508 memcpy (tok, tokstart, toklen);
1510 error ("There is no character corresponding to %s in the target "
1511 "character set `%s'.", tok, target_charset ());
1514 yylval.typed_val_int.val = c;
1515 yylval.typed_val_int.type = parse_type->builtin_char;
1520 namelen = skip_quoted (tokstart) - tokstart;
1523 lexptr = tokstart + namelen;
1524 if (lexptr[-1] != '\'')
1525 error ("Unmatched single quote.");
1530 error ("Invalid character constant.");
1540 if (paren_depth == 0)
1547 if (comma_terminates
1549 && ! scanning_macro_expansion ())
1555 /* Might be a floating point number. */
1556 if (lexptr[1] < '0' || lexptr[1] > '9')
1559 last_was_structop = 1;
1560 goto symbol; /* Nope, must be a symbol. */
1562 /* FALL THRU into number case. */
1575 /* It's a number. */
1576 int got_dot = 0, got_e = 0, toktype;
1578 int hex = input_radix > 10;
1580 if (c == '0' && (p[1] == 'x' || p[1] == 'X'))
1585 else if (c == '0' && (p[1]=='t' || p[1]=='T' || p[1]=='d' || p[1]=='D'))
1593 /* This test includes !hex because 'e' is a valid hex digit
1594 and thus does not indicate a floating point number when
1595 the radix is hex. */
1596 if (!hex && !got_e && (*p == 'e' || *p == 'E'))
1597 got_dot = got_e = 1;
1598 /* This test does not include !hex, because a '.' always indicates
1599 a decimal floating point number regardless of the radix. */
1600 else if (!got_dot && *p == '.')
1602 else if (got_e && (p[-1] == 'e' || p[-1] == 'E')
1603 && (*p == '-' || *p == '+'))
1604 /* This is the sign of the exponent, not the end of the
1607 /* We will take any letters or digits. parse_number will
1608 complain if past the radix, or if L or U are not final. */
1609 else if ((*p < '0' || *p > '9')
1610 && ((*p < 'a' || *p > 'z')
1611 && (*p < 'A' || *p > 'Z')))
1614 toktype = parse_number (tokstart, p - tokstart, got_dot|got_e, &yylval);
1615 if (toktype == ERROR)
1617 char *err_copy = (char *) alloca (p - tokstart + 1);
1619 memcpy (err_copy, tokstart, p - tokstart);
1620 err_copy[p - tokstart] = 0;
1621 error ("Invalid number \"%s\".", err_copy);
1653 /* Build the gdb internal form of the input string in tempbuf,
1654 translating any standard C escape forms seen. Note that the
1655 buffer is null byte terminated *only* for the convenience of
1656 debugging gdb itself and printing the buffer contents when
1657 the buffer contains no embedded nulls. Gdb does not depend
1658 upon the buffer being null byte terminated, it uses the length
1659 string instead. This allows gdb to handle C strings (as well
1660 as strings in other languages) with embedded null bytes */
1662 tokptr = ++tokstart;
1666 char *char_start_pos = tokptr;
1668 /* Grow the static temp buffer if necessary, including allocating
1669 the first one on demand. */
1670 if (tempbufindex + 1 >= tempbufsize)
1672 tempbuf = (char *) realloc (tempbuf, tempbufsize += 64);
1678 /* Do nothing, loop will terminate. */
1682 c = parse_escape (&tokptr);
1687 tempbuf[tempbufindex++] = c;
1691 if (! host_char_to_target (c, &c))
1693 int len = tokptr - char_start_pos;
1694 char *copy = alloca (len + 1);
1695 memcpy (copy, char_start_pos, len);
1698 error ("There is no character corresponding to `%s' "
1699 "in the target character set `%s'.",
1700 copy, target_charset ());
1702 tempbuf[tempbufindex++] = c;
1705 } while ((*tokptr != '"') && (*tokptr != '\0'));
1706 if (*tokptr++ != '"')
1708 error ("Unterminated string in expression.");
1710 tempbuf[tempbufindex] = '\0'; /* See note above */
1711 yylval.sval.ptr = tempbuf;
1712 yylval.sval.length = tempbufindex;
1717 if (!(c == '_' || c == '$'
1718 || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')))
1719 /* We must have come across a bad character (e.g. ';'). */
1720 error ("Invalid character '%c' in expression.", c);
1722 /* It's a name. See how long it is. */
1724 for (c = tokstart[namelen];
1725 (c == '_' || c == '$' || (c >= '0' && c <= '9')
1726 || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '<');)
1728 /* Template parameter lists are part of the name.
1729 FIXME: This mishandles `print $a<4&&$a>3'. */
1733 /* Scan ahead to get rest of the template specification. Note
1734 that we look ahead only when the '<' adjoins non-whitespace
1735 characters; for comparison expressions, e.g. "a < b > c",
1736 there must be spaces before the '<', etc. */
1738 char * p = find_template_name_end (tokstart + namelen);
1740 namelen = p - tokstart;
1743 c = tokstart[++namelen];
1746 /* The token "if" terminates the expression and is NOT removed from
1747 the input stream. It doesn't count if it appears in the
1748 expansion of a macro. */
1750 && tokstart[0] == 'i'
1751 && tokstart[1] == 'f'
1752 && ! scanning_macro_expansion ())
1761 /* Catch specific keywords. Should be done with a data structure. */
1765 if (strncmp (tokstart, "unsigned", 8) == 0)
1767 if (parse_language->la_language == language_cplus
1768 && strncmp (tokstart, "template", 8) == 0)
1770 if (strncmp (tokstart, "volatile", 8) == 0)
1771 return VOLATILE_KEYWORD;
1774 if (strncmp (tokstart, "struct", 6) == 0)
1776 if (strncmp (tokstart, "signed", 6) == 0)
1777 return SIGNED_KEYWORD;
1778 if (strncmp (tokstart, "sizeof", 6) == 0)
1780 if (strncmp (tokstart, "double", 6) == 0)
1781 return DOUBLE_KEYWORD;
1784 if (parse_language->la_language == language_cplus)
1786 if (strncmp (tokstart, "false", 5) == 0)
1787 return FALSEKEYWORD;
1788 if (strncmp (tokstart, "class", 5) == 0)
1791 if (strncmp (tokstart, "union", 5) == 0)
1793 if (strncmp (tokstart, "short", 5) == 0)
1795 if (strncmp (tokstart, "const", 5) == 0)
1796 return CONST_KEYWORD;
1799 if (strncmp (tokstart, "enum", 4) == 0)
1801 if (strncmp (tokstart, "long", 4) == 0)
1803 if (parse_language->la_language == language_cplus)
1805 if (strncmp (tokstart, "true", 4) == 0)
1810 if (strncmp (tokstart, "int", 3) == 0)
1817 yylval.sval.ptr = tokstart;
1818 yylval.sval.length = namelen;
1820 if (*tokstart == '$')
1822 write_dollar_variable (yylval.sval);
1826 /* Use token-type BLOCKNAME for symbols that happen to be defined as
1827 functions or symtabs. If this is not so, then ...
1828 Use token-type TYPENAME for symbols that happen to be defined
1829 currently as names of types; NAME for other symbols.
1830 The caller is not constrained to care about the distinction. */
1832 char *tmp = copy_name (yylval.sval);
1834 int is_a_field_of_this = 0;
1837 sym = lookup_symbol (tmp, expression_context_block,
1839 parse_language->la_language == language_cplus
1840 ? &is_a_field_of_this : (int *) NULL);
1841 /* Call lookup_symtab, not lookup_partial_symtab, in case there are
1842 no psymtabs (coff, xcoff, or some future change to blow away the
1843 psymtabs once once symbols are read). */
1844 if (sym && SYMBOL_CLASS (sym) == LOC_BLOCK)
1846 yylval.ssym.sym = sym;
1847 yylval.ssym.is_a_field_of_this = is_a_field_of_this;
1851 { /* See if it's a file name. */
1852 struct symtab *symtab;
1854 symtab = lookup_symtab (tmp);
1858 yylval.bval = BLOCKVECTOR_BLOCK (BLOCKVECTOR (symtab), STATIC_BLOCK);
1863 if (sym && SYMBOL_CLASS (sym) == LOC_TYPEDEF)
1865 /* NOTE: carlton/2003-09-25: There used to be code here to
1866 handle nested types. It didn't work very well. See the
1867 comment before qualified_type for more info. */
1868 yylval.tsym.type = SYMBOL_TYPE (sym);
1872 = language_lookup_primitive_type_by_name (parse_language,
1873 parse_gdbarch, tmp);
1874 if (yylval.tsym.type != NULL)
1877 /* Input names that aren't symbols but ARE valid hex numbers,
1878 when the input radix permits them, can be names or numbers
1879 depending on the parse. Note we support radixes > 16 here. */
1881 ((tokstart[0] >= 'a' && tokstart[0] < 'a' + input_radix - 10) ||
1882 (tokstart[0] >= 'A' && tokstart[0] < 'A' + input_radix - 10)))
1884 YYSTYPE newlval; /* Its value is ignored. */
1885 hextype = parse_number (tokstart, namelen, 0, &newlval);
1888 yylval.ssym.sym = sym;
1889 yylval.ssym.is_a_field_of_this = is_a_field_of_this;
1894 /* Any other kind of symbol */
1895 yylval.ssym.sym = sym;
1896 yylval.ssym.is_a_field_of_this = is_a_field_of_this;
1897 if (in_parse_field && *lexptr == '\0')
1898 saw_name_at_eof = 1;
1906 last_was_structop = 0;
1907 saw_name_at_eof = 0;
1916 lexptr = prev_lexptr;
1918 error ("A %s in expression, near `%s'.", (msg ? msg : "error"), lexptr);