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 /* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc),
59 as well as gratuitiously global symbol names, so we can have multiple
60 yacc generated parsers in gdb. Note that these are only the variables
61 produced by yacc. If other parser generators (bison, byacc, etc) produce
62 additional global names that conflict at link time, then those parser
63 generators need to be fixed instead of adding those names to this list. */
65 #define yymaxdepth c_maxdepth
66 #define yyparse c_parse_internal
68 #define yyerror c_error
71 #define yydebug c_debug
80 #define yyerrflag c_errflag
81 #define yynerrs c_nerrs
86 #define yystate c_state
92 #define yyreds c_reds /* With YYDEBUG defined */
93 #define yytoks c_toks /* With YYDEBUG defined */
94 #define yyname c_name /* With YYDEBUG defined */
95 #define yyrule c_rule /* With YYDEBUG defined */
98 #define yydefred c_yydefred
99 #define yydgoto c_yydgoto
100 #define yysindex c_yysindex
101 #define yyrindex c_yyrindex
102 #define yygindex c_yygindex
103 #define yytable c_yytable
104 #define yycheck c_yycheck
107 #define YYDEBUG 1 /* Default to yydebug support */
110 #define YYFPRINTF parser_fprintf
114 static int yylex (void);
116 void yyerror (char *);
120 /* Although the yacc "value" of an expression is not used,
121 since the result is stored in the structure being created,
122 other node types do have values. */
138 } typed_val_decfloat;
143 struct symtoken ssym;
146 enum exp_opcode opcode;
147 struct internalvar *ivar;
154 /* YYSTYPE gets defined by %union */
155 static int parse_number (char *, int, int, YYSTYPE *);
158 %type <voidval> exp exp1 type_exp start variable qualified_name lcurly
160 %type <tval> type typebase qualified_type
161 %type <tvec> nonempty_typelist
162 /* %type <bval> block */
164 /* Fancy type parsing. */
165 %type <voidval> func_mod direct_abs_decl abs_decl
167 %type <lval> array_mod
169 %token <typed_val_int> INT
170 %token <typed_val_float> FLOAT
171 %token <typed_val_decfloat> DECFLOAT
173 /* Both NAME and TYPENAME tokens represent symbols in the input,
174 and both convey their data as strings.
175 But a TYPENAME is a string that happens to be defined as a typedef
176 or builtin type name (such as int or char)
177 and a NAME is any other symbol.
178 Contexts where this distinction is not important can use the
179 nonterminal "name", which matches either NAME or TYPENAME. */
182 %token <ssym> NAME /* BLOCKNAME defined below to give it higher precedence. */
183 %token <voidval> COMPLETE
184 %token <tsym> TYPENAME
186 %type <ssym> name_not_typename
187 %type <tsym> typename
189 /* A NAME_OR_INT is a symbol which is not known in the symbol table,
190 but which would parse as a valid number in the current input radix.
191 E.g. "c" when input_radix==16. Depending on the parse, it will be
192 turned into a name or into a number. */
194 %token <ssym> NAME_OR_INT
196 %token STRUCT CLASS UNION ENUM SIZEOF UNSIGNED COLONCOLON
200 /* Special type cases, put in to allow the parser to distinguish different
202 %token SIGNED_KEYWORD LONG SHORT INT_KEYWORD CONST_KEYWORD VOLATILE_KEYWORD DOUBLE_KEYWORD
204 %token <voidval> VARIABLE
206 %token <opcode> ASSIGN_MODIFY
215 %right '=' ASSIGN_MODIFY
223 %left '<' '>' LEQ GEQ
228 %right UNARY INCREMENT DECREMENT
229 %right ARROW '.' '[' '('
230 %token <ssym> BLOCKNAME
231 %token <bval> FILENAME
243 { write_exp_elt_opcode(OP_TYPE);
244 write_exp_elt_type($1);
245 write_exp_elt_opcode(OP_TYPE);}
248 /* Expressions, including the comma operator. */
251 { write_exp_elt_opcode (BINOP_COMMA); }
254 /* Expressions, not including the comma operator. */
255 exp : '*' exp %prec UNARY
256 { write_exp_elt_opcode (UNOP_IND); }
259 exp : '&' exp %prec UNARY
260 { write_exp_elt_opcode (UNOP_ADDR); }
263 exp : '-' exp %prec UNARY
264 { write_exp_elt_opcode (UNOP_NEG); }
267 exp : '+' exp %prec UNARY
268 { write_exp_elt_opcode (UNOP_PLUS); }
271 exp : '!' exp %prec UNARY
272 { write_exp_elt_opcode (UNOP_LOGICAL_NOT); }
275 exp : '~' exp %prec UNARY
276 { write_exp_elt_opcode (UNOP_COMPLEMENT); }
279 exp : INCREMENT exp %prec UNARY
280 { write_exp_elt_opcode (UNOP_PREINCREMENT); }
283 exp : DECREMENT exp %prec UNARY
284 { write_exp_elt_opcode (UNOP_PREDECREMENT); }
287 exp : exp INCREMENT %prec UNARY
288 { write_exp_elt_opcode (UNOP_POSTINCREMENT); }
291 exp : exp DECREMENT %prec UNARY
292 { write_exp_elt_opcode (UNOP_POSTDECREMENT); }
295 exp : SIZEOF exp %prec UNARY
296 { write_exp_elt_opcode (UNOP_SIZEOF); }
300 { write_exp_elt_opcode (STRUCTOP_PTR);
301 write_exp_string ($3);
302 write_exp_elt_opcode (STRUCTOP_PTR); }
305 exp : exp ARROW name COMPLETE
306 { mark_struct_expression ();
307 write_exp_elt_opcode (STRUCTOP_PTR);
308 write_exp_string ($3);
309 write_exp_elt_opcode (STRUCTOP_PTR); }
312 exp : exp ARROW COMPLETE
314 mark_struct_expression ();
315 write_exp_elt_opcode (STRUCTOP_PTR);
318 write_exp_string (s);
319 write_exp_elt_opcode (STRUCTOP_PTR); }
322 exp : exp ARROW qualified_name
323 { /* exp->type::name becomes exp->*(&type::name) */
324 /* Note: this doesn't work if name is a
325 static member! FIXME */
326 write_exp_elt_opcode (UNOP_ADDR);
327 write_exp_elt_opcode (STRUCTOP_MPTR); }
330 exp : exp ARROW '*' exp
331 { write_exp_elt_opcode (STRUCTOP_MPTR); }
335 { write_exp_elt_opcode (STRUCTOP_STRUCT);
336 write_exp_string ($3);
337 write_exp_elt_opcode (STRUCTOP_STRUCT); }
340 exp : exp '.' name COMPLETE
341 { mark_struct_expression ();
342 write_exp_elt_opcode (STRUCTOP_STRUCT);
343 write_exp_string ($3);
344 write_exp_elt_opcode (STRUCTOP_STRUCT); }
347 exp : exp '.' COMPLETE
349 mark_struct_expression ();
350 write_exp_elt_opcode (STRUCTOP_STRUCT);
353 write_exp_string (s);
354 write_exp_elt_opcode (STRUCTOP_STRUCT); }
357 exp : exp '.' qualified_name
358 { /* exp.type::name becomes exp.*(&type::name) */
359 /* Note: this doesn't work if name is a
360 static member! FIXME */
361 write_exp_elt_opcode (UNOP_ADDR);
362 write_exp_elt_opcode (STRUCTOP_MEMBER); }
365 exp : exp '.' '*' exp
366 { write_exp_elt_opcode (STRUCTOP_MEMBER); }
369 exp : exp '[' exp1 ']'
370 { write_exp_elt_opcode (BINOP_SUBSCRIPT); }
374 /* This is to save the value of arglist_len
375 being accumulated by an outer function call. */
376 { start_arglist (); }
377 arglist ')' %prec ARROW
378 { write_exp_elt_opcode (OP_FUNCALL);
379 write_exp_elt_longcst ((LONGEST) end_arglist ());
380 write_exp_elt_opcode (OP_FUNCALL); }
384 { start_arglist (); }
394 arglist : arglist ',' exp %prec ABOVE_COMMA
399 { $$ = end_arglist () - 1; }
401 exp : lcurly arglist rcurly %prec ARROW
402 { write_exp_elt_opcode (OP_ARRAY);
403 write_exp_elt_longcst ((LONGEST) 0);
404 write_exp_elt_longcst ((LONGEST) $3);
405 write_exp_elt_opcode (OP_ARRAY); }
408 exp : lcurly type rcurly exp %prec UNARY
409 { write_exp_elt_opcode (UNOP_MEMVAL);
410 write_exp_elt_type ($2);
411 write_exp_elt_opcode (UNOP_MEMVAL); }
414 exp : '(' type ')' exp %prec UNARY
415 { write_exp_elt_opcode (UNOP_CAST);
416 write_exp_elt_type ($2);
417 write_exp_elt_opcode (UNOP_CAST); }
424 /* Binary operators in order of decreasing precedence. */
427 { write_exp_elt_opcode (BINOP_REPEAT); }
431 { write_exp_elt_opcode (BINOP_MUL); }
435 { write_exp_elt_opcode (BINOP_DIV); }
439 { write_exp_elt_opcode (BINOP_REM); }
443 { write_exp_elt_opcode (BINOP_ADD); }
447 { write_exp_elt_opcode (BINOP_SUB); }
451 { write_exp_elt_opcode (BINOP_LSH); }
455 { write_exp_elt_opcode (BINOP_RSH); }
459 { write_exp_elt_opcode (BINOP_EQUAL); }
462 exp : exp NOTEQUAL exp
463 { write_exp_elt_opcode (BINOP_NOTEQUAL); }
467 { write_exp_elt_opcode (BINOP_LEQ); }
471 { write_exp_elt_opcode (BINOP_GEQ); }
475 { write_exp_elt_opcode (BINOP_LESS); }
479 { write_exp_elt_opcode (BINOP_GTR); }
483 { write_exp_elt_opcode (BINOP_BITWISE_AND); }
487 { write_exp_elt_opcode (BINOP_BITWISE_XOR); }
491 { write_exp_elt_opcode (BINOP_BITWISE_IOR); }
495 { write_exp_elt_opcode (BINOP_LOGICAL_AND); }
499 { write_exp_elt_opcode (BINOP_LOGICAL_OR); }
502 exp : exp '?' exp ':' exp %prec '?'
503 { write_exp_elt_opcode (TERNOP_COND); }
507 { write_exp_elt_opcode (BINOP_ASSIGN); }
510 exp : exp ASSIGN_MODIFY exp
511 { write_exp_elt_opcode (BINOP_ASSIGN_MODIFY);
512 write_exp_elt_opcode ($2);
513 write_exp_elt_opcode (BINOP_ASSIGN_MODIFY); }
517 { write_exp_elt_opcode (OP_LONG);
518 write_exp_elt_type ($1.type);
519 write_exp_elt_longcst ((LONGEST)($1.val));
520 write_exp_elt_opcode (OP_LONG); }
525 parse_number ($1.stoken.ptr, $1.stoken.length, 0, &val);
526 write_exp_elt_opcode (OP_LONG);
527 write_exp_elt_type (val.typed_val_int.type);
528 write_exp_elt_longcst ((LONGEST)val.typed_val_int.val);
529 write_exp_elt_opcode (OP_LONG);
535 { write_exp_elt_opcode (OP_DOUBLE);
536 write_exp_elt_type ($1.type);
537 write_exp_elt_dblcst ($1.dval);
538 write_exp_elt_opcode (OP_DOUBLE); }
542 { write_exp_elt_opcode (OP_DECFLOAT);
543 write_exp_elt_type ($1.type);
544 write_exp_elt_decfloatcst ($1.val);
545 write_exp_elt_opcode (OP_DECFLOAT); }
552 /* Already written by write_dollar_variable. */
555 exp : SIZEOF '(' type ')' %prec UNARY
556 { write_exp_elt_opcode (OP_LONG);
557 write_exp_elt_type (builtin_type (current_gdbarch)->builtin_int);
559 write_exp_elt_longcst ((LONGEST) TYPE_LENGTH ($3));
560 write_exp_elt_opcode (OP_LONG); }
564 { /* C strings are converted into array constants with
565 an explicit null byte added at the end. Thus
566 the array upper bound is the string length.
567 There is no such thing in C as a completely empty
569 char *sp = $1.ptr; int count = $1.length;
572 write_exp_elt_opcode (OP_LONG);
573 write_exp_elt_type (builtin_type (current_gdbarch)->builtin_char);
574 write_exp_elt_longcst ((LONGEST)(*sp++));
575 write_exp_elt_opcode (OP_LONG);
577 write_exp_elt_opcode (OP_LONG);
578 write_exp_elt_type (builtin_type (current_gdbarch)->builtin_char);
579 write_exp_elt_longcst ((LONGEST)'\0');
580 write_exp_elt_opcode (OP_LONG);
581 write_exp_elt_opcode (OP_ARRAY);
582 write_exp_elt_longcst ((LONGEST) 0);
583 write_exp_elt_longcst ((LONGEST) ($1.length));
584 write_exp_elt_opcode (OP_ARRAY); }
589 { write_exp_elt_opcode (OP_LONG);
590 write_exp_elt_type (builtin_type (current_gdbarch)->builtin_bool);
591 write_exp_elt_longcst ((LONGEST) 1);
592 write_exp_elt_opcode (OP_LONG); }
596 { write_exp_elt_opcode (OP_LONG);
597 write_exp_elt_type (builtin_type (current_gdbarch)->builtin_bool);
598 write_exp_elt_longcst ((LONGEST) 0);
599 write_exp_elt_opcode (OP_LONG); }
607 $$ = SYMBOL_BLOCK_VALUE ($1.sym);
609 error ("No file or function \"%s\".",
610 copy_name ($1.stoken));
618 block : block COLONCOLON name
620 = lookup_symbol (copy_name ($3), $1,
621 VAR_DOMAIN, (int *) NULL);
622 if (!tem || SYMBOL_CLASS (tem) != LOC_BLOCK)
623 error ("No function \"%s\" in specified context.",
625 $$ = SYMBOL_BLOCK_VALUE (tem); }
628 variable: block COLONCOLON name
629 { struct symbol *sym;
630 sym = lookup_symbol (copy_name ($3), $1,
631 VAR_DOMAIN, (int *) NULL);
633 error ("No symbol \"%s\" in specified context.",
636 write_exp_elt_opcode (OP_VAR_VALUE);
637 /* block_found is set by lookup_symbol. */
638 write_exp_elt_block (block_found);
639 write_exp_elt_sym (sym);
640 write_exp_elt_opcode (OP_VAR_VALUE); }
643 qualified_name: typebase COLONCOLON name
645 struct type *type = $1;
646 if (TYPE_CODE (type) != TYPE_CODE_STRUCT
647 && TYPE_CODE (type) != TYPE_CODE_UNION
648 && TYPE_CODE (type) != TYPE_CODE_NAMESPACE)
649 error ("`%s' is not defined as an aggregate type.",
652 write_exp_elt_opcode (OP_SCOPE);
653 write_exp_elt_type (type);
654 write_exp_string ($3);
655 write_exp_elt_opcode (OP_SCOPE);
657 | typebase COLONCOLON '~' name
659 struct type *type = $1;
660 struct stoken tmp_token;
661 if (TYPE_CODE (type) != TYPE_CODE_STRUCT
662 && TYPE_CODE (type) != TYPE_CODE_UNION
663 && TYPE_CODE (type) != TYPE_CODE_NAMESPACE)
664 error ("`%s' is not defined as an aggregate type.",
667 tmp_token.ptr = (char*) alloca ($4.length + 2);
668 tmp_token.length = $4.length + 1;
669 tmp_token.ptr[0] = '~';
670 memcpy (tmp_token.ptr+1, $4.ptr, $4.length);
671 tmp_token.ptr[tmp_token.length] = 0;
673 /* Check for valid destructor name. */
674 destructor_name_p (tmp_token.ptr, type);
675 write_exp_elt_opcode (OP_SCOPE);
676 write_exp_elt_type (type);
677 write_exp_string (tmp_token);
678 write_exp_elt_opcode (OP_SCOPE);
682 variable: qualified_name
685 char *name = copy_name ($2);
687 struct minimal_symbol *msymbol;
690 lookup_symbol (name, (const struct block *) NULL,
691 VAR_DOMAIN, (int *) NULL);
694 write_exp_elt_opcode (OP_VAR_VALUE);
695 write_exp_elt_block (NULL);
696 write_exp_elt_sym (sym);
697 write_exp_elt_opcode (OP_VAR_VALUE);
701 msymbol = lookup_minimal_symbol (name, NULL, NULL);
703 write_exp_msymbol (msymbol);
704 else if (!have_full_symbols () && !have_partial_symbols ())
705 error ("No symbol table is loaded. Use the \"file\" command.");
707 error ("No symbol \"%s\" in current context.", name);
711 variable: name_not_typename
712 { struct symbol *sym = $1.sym;
716 if (symbol_read_needs_frame (sym))
718 if (innermost_block == 0 ||
719 contained_in (block_found,
721 innermost_block = block_found;
724 write_exp_elt_opcode (OP_VAR_VALUE);
725 /* We want to use the selected frame, not
726 another more inner frame which happens to
727 be in the same block. */
728 write_exp_elt_block (NULL);
729 write_exp_elt_sym (sym);
730 write_exp_elt_opcode (OP_VAR_VALUE);
732 else if ($1.is_a_field_of_this)
734 /* C++: it hangs off of `this'. Must
735 not inadvertently convert from a method call
737 if (innermost_block == 0 ||
738 contained_in (block_found, innermost_block))
739 innermost_block = block_found;
740 write_exp_elt_opcode (OP_THIS);
741 write_exp_elt_opcode (OP_THIS);
742 write_exp_elt_opcode (STRUCTOP_PTR);
743 write_exp_string ($1.stoken);
744 write_exp_elt_opcode (STRUCTOP_PTR);
748 struct minimal_symbol *msymbol;
749 char *arg = copy_name ($1.stoken);
752 lookup_minimal_symbol (arg, NULL, NULL);
754 write_exp_msymbol (msymbol);
755 else if (!have_full_symbols () && !have_partial_symbols ())
756 error ("No symbol table is loaded. Use the \"file\" command.");
758 error ("No symbol \"%s\" in current context.",
759 copy_name ($1.stoken));
764 space_identifier : '@' NAME
765 { push_type_address_space (copy_name ($2.stoken));
766 push_type (tp_space_identifier);
770 const_or_volatile: const_or_volatile_noopt
774 cv_with_space_id : const_or_volatile space_identifier const_or_volatile
777 const_or_volatile_or_space_identifier_noopt: cv_with_space_id
778 | const_or_volatile_noopt
781 const_or_volatile_or_space_identifier:
782 const_or_volatile_or_space_identifier_noopt
787 { push_type (tp_pointer); $$ = 0; }
789 { push_type (tp_pointer); $$ = $2; }
791 { push_type (tp_reference); $$ = 0; }
793 { push_type (tp_reference); $$ = $2; }
797 direct_abs_decl: '(' abs_decl ')'
799 | direct_abs_decl array_mod
802 push_type (tp_array);
807 push_type (tp_array);
811 | direct_abs_decl func_mod
812 { push_type (tp_function); }
814 { push_type (tp_function); }
825 | '(' nonempty_typelist ')'
826 { free ($2); $$ = 0; }
829 /* We used to try to recognize pointer to member types here, but
830 that didn't work (shift/reduce conflicts meant that these rules never
831 got executed). The problem is that
832 int (foo::bar::baz::bizzle)
833 is a function type but
834 int (foo::bar::baz::bizzle::*)
835 is a pointer to member type. Stroustrup loses again! */
840 typebase /* Implements (approximately): (type-qualifier)* type-specifier */
844 { $$ = builtin_type (current_gdbarch)->builtin_int; }
846 { $$ = builtin_type (current_gdbarch)->builtin_long; }
848 { $$ = builtin_type (current_gdbarch)->builtin_short; }
850 { $$ = builtin_type (current_gdbarch)->builtin_long; }
851 | LONG SIGNED_KEYWORD INT_KEYWORD
852 { $$ = builtin_type (current_gdbarch)->builtin_long; }
853 | LONG SIGNED_KEYWORD
854 { $$ = builtin_type (current_gdbarch)->builtin_long; }
855 | SIGNED_KEYWORD LONG INT_KEYWORD
856 { $$ = builtin_type (current_gdbarch)->builtin_long; }
857 | UNSIGNED LONG INT_KEYWORD
858 { $$ = builtin_type (current_gdbarch)->builtin_unsigned_long; }
859 | LONG UNSIGNED INT_KEYWORD
860 { $$ = builtin_type (current_gdbarch)->builtin_unsigned_long; }
862 { $$ = builtin_type (current_gdbarch)->builtin_unsigned_long; }
864 { $$ = builtin_type (current_gdbarch)->builtin_long_long; }
865 | LONG LONG INT_KEYWORD
866 { $$ = builtin_type (current_gdbarch)->builtin_long_long; }
867 | LONG LONG SIGNED_KEYWORD INT_KEYWORD
868 { $$ = builtin_type (current_gdbarch)->builtin_long_long; }
869 | LONG LONG SIGNED_KEYWORD
870 { $$ = builtin_type (current_gdbarch)->builtin_long_long; }
871 | SIGNED_KEYWORD LONG LONG
872 { $$ = builtin_type (current_gdbarch)->builtin_long_long; }
873 | SIGNED_KEYWORD LONG LONG INT_KEYWORD
874 { $$ = builtin_type (current_gdbarch)->builtin_long_long; }
876 { $$ = builtin_type (current_gdbarch)->builtin_unsigned_long_long; }
877 | UNSIGNED LONG LONG INT_KEYWORD
878 { $$ = builtin_type (current_gdbarch)->builtin_unsigned_long_long; }
880 { $$ = builtin_type (current_gdbarch)->builtin_unsigned_long_long; }
881 | LONG LONG UNSIGNED INT_KEYWORD
882 { $$ = builtin_type (current_gdbarch)->builtin_unsigned_long_long; }
884 { $$ = builtin_type (current_gdbarch)->builtin_short; }
885 | SHORT SIGNED_KEYWORD INT_KEYWORD
886 { $$ = builtin_type (current_gdbarch)->builtin_short; }
887 | SHORT SIGNED_KEYWORD
888 { $$ = builtin_type (current_gdbarch)->builtin_short; }
889 | UNSIGNED SHORT INT_KEYWORD
890 { $$ = builtin_type (current_gdbarch)->builtin_unsigned_short; }
892 { $$ = builtin_type (current_gdbarch)->builtin_unsigned_short; }
893 | SHORT UNSIGNED INT_KEYWORD
894 { $$ = builtin_type (current_gdbarch)->builtin_unsigned_short; }
896 { $$ = builtin_type (current_gdbarch)->builtin_double; }
897 | LONG DOUBLE_KEYWORD
898 { $$ = builtin_type (current_gdbarch)->builtin_long_double; }
900 { $$ = lookup_struct (copy_name ($2),
901 expression_context_block); }
903 { $$ = lookup_struct (copy_name ($2),
904 expression_context_block); }
906 { $$ = lookup_union (copy_name ($2),
907 expression_context_block); }
909 { $$ = lookup_enum (copy_name ($2),
910 expression_context_block); }
912 { $$ = lookup_unsigned_typename (TYPE_NAME($2.type)); }
914 { $$ = builtin_type (current_gdbarch)->builtin_unsigned_int; }
915 | SIGNED_KEYWORD typename
916 { $$ = lookup_signed_typename (TYPE_NAME($2.type)); }
918 { $$ = builtin_type (current_gdbarch)->builtin_int; }
919 /* It appears that this rule for templates is never
920 reduced; template recognition happens by lookahead
921 in the token processing code in yylex. */
922 | TEMPLATE name '<' type '>'
923 { $$ = lookup_template_type(copy_name($2), $4,
924 expression_context_block);
926 | const_or_volatile_or_space_identifier_noopt typebase
927 { $$ = follow_types ($2); }
928 | typebase const_or_volatile_or_space_identifier_noopt
929 { $$ = follow_types ($1); }
933 /* FIXME: carlton/2003-09-25: This next bit leads to lots of
934 reduce-reduce conflicts, because the parser doesn't know whether or
935 not to use qualified_name or qualified_type: the rules are
936 identical. If the parser is parsing 'A::B::x', then, when it sees
937 the second '::', it knows that the expression to the left of it has
938 to be a type, so it uses qualified_type. But if it is parsing just
939 'A::B', then it doesn't have any way of knowing which rule to use,
940 so there's a reduce-reduce conflict; it picks qualified_name, since
941 that occurs earlier in this file than qualified_type.
943 There's no good way to fix this with the grammar as it stands; as
944 far as I can tell, some of the problems arise from ambiguities that
945 GDB introduces ('start' can be either an expression or a type), but
946 some of it is inherent to the nature of C++ (you want to treat the
947 input "(FOO)" fairly differently depending on whether FOO is an
948 expression or a type, and if FOO is a complex expression, this can
949 be hard to determine at the right time). Fortunately, it works
950 pretty well in most cases. For example, if you do 'ptype A::B',
951 where A::B is a nested type, then the parser will mistakenly
952 misidentify it as an expression; but evaluate_subexp will get
953 called with 'noside' set to EVAL_AVOID_SIDE_EFFECTS, and everything
954 will work out anyways. But there are situations where the parser
955 will get confused: the most common one that I've run into is when
960 where the parser doesn't realize that A::B has to be a type until
961 it hits the first right paren, at which point it's too late. (The
962 workaround is to type "print *(('A::B' *) x)" instead.) (And
963 another solution is to fix our symbol-handling code so that the
964 user never wants to type something like that in the first place,
965 because we get all the types right without the user's help!)
967 Perhaps we could fix this by making the lexer smarter. Some of
968 this functionality used to be in the lexer, but in a way that
969 worked even less well than the current solution: that attempt
970 involved having the parser sometimes handle '::' and having the
971 lexer sometimes handle it, and without a clear division of
972 responsibility, it quickly degenerated into a big mess. Probably
973 the eventual correct solution will give more of a role to the lexer
974 (ideally via code that is shared between the lexer and
975 decode_line_1), but I'm not holding my breath waiting for somebody
976 to get around to cleaning this up... */
978 qualified_type: typebase COLONCOLON name
980 struct type *type = $1;
981 struct type *new_type;
982 char *ncopy = alloca ($3.length + 1);
984 memcpy (ncopy, $3.ptr, $3.length);
985 ncopy[$3.length] = '\0';
987 if (TYPE_CODE (type) != TYPE_CODE_STRUCT
988 && TYPE_CODE (type) != TYPE_CODE_UNION
989 && TYPE_CODE (type) != TYPE_CODE_NAMESPACE)
990 error ("`%s' is not defined as an aggregate type.",
993 new_type = cp_lookup_nested_type (type, ncopy,
994 expression_context_block);
995 if (new_type == NULL)
996 error ("No type \"%s\" within class or namespace \"%s\".",
997 ncopy, TYPE_NAME (type));
1006 $$.stoken.ptr = "int";
1007 $$.stoken.length = 3;
1008 $$.type = builtin_type (current_gdbarch)->builtin_int;
1012 $$.stoken.ptr = "long";
1013 $$.stoken.length = 4;
1014 $$.type = builtin_type (current_gdbarch)->builtin_long;
1018 $$.stoken.ptr = "short";
1019 $$.stoken.length = 5;
1020 $$.type = builtin_type (current_gdbarch)->builtin_short;
1026 { $$ = (struct type **) malloc (sizeof (struct type *) * 2);
1027 $<ivec>$[0] = 1; /* Number of types in vector */
1030 | nonempty_typelist ',' type
1031 { int len = sizeof (struct type *) * (++($<ivec>1[0]) + 1);
1032 $$ = (struct type **) realloc ((char *) $1, len);
1033 $$[$<ivec>$[0]] = $3;
1038 | ptype const_or_volatile_or_space_identifier abs_decl const_or_volatile_or_space_identifier
1039 { $$ = follow_types ($1); }
1042 const_and_volatile: CONST_KEYWORD VOLATILE_KEYWORD
1043 | VOLATILE_KEYWORD CONST_KEYWORD
1046 const_or_volatile_noopt: const_and_volatile
1047 { push_type (tp_const);
1048 push_type (tp_volatile);
1051 { push_type (tp_const); }
1053 { push_type (tp_volatile); }
1056 name : NAME { $$ = $1.stoken; }
1057 | BLOCKNAME { $$ = $1.stoken; }
1058 | TYPENAME { $$ = $1.stoken; }
1059 | NAME_OR_INT { $$ = $1.stoken; }
1062 name_not_typename : NAME
1064 /* These would be useful if name_not_typename was useful, but it is just
1065 a fake for "variable", so these cause reduce/reduce conflicts because
1066 the parser can't tell whether NAME_OR_INT is a name_not_typename (=variable,
1067 =exp) or just an exp. If name_not_typename was ever used in an lvalue
1068 context where only a name could occur, this might be useful.
1075 /* Take care of parsing a number (anything that starts with a digit).
1076 Set yylval and return the token type; update lexptr.
1077 LEN is the number of characters in it. */
1079 /*** Needs some error checking for the float case ***/
1082 parse_number (p, len, parsed_float, putithere)
1088 /* FIXME: Shouldn't these be unsigned? We don't deal with negative values
1089 here, and we do kind of silly things like cast to unsigned. */
1096 int base = input_radix;
1099 /* Number of "L" suffixes encountered. */
1102 /* We have found a "L" or "U" suffix. */
1103 int found_suffix = 0;
1106 struct type *signed_type;
1107 struct type *unsigned_type;
1111 /* It's a float since it contains a point or an exponent. */
1113 int num; /* number of tokens scanned by scanf */
1116 /* If it ends at "df", "dd" or "dl", take it as type of decimal floating
1117 point. Return DECFLOAT. */
1119 if (len >= 2 && p[len - 2] == 'd' && p[len - 1] == 'f')
1122 putithere->typed_val_decfloat.type
1123 = builtin_type (current_gdbarch)->builtin_decfloat;
1124 decimal_from_string (putithere->typed_val_decfloat.val, 4, p);
1129 if (len >= 2 && p[len - 2] == 'd' && p[len - 1] == 'd')
1132 putithere->typed_val_decfloat.type
1133 = builtin_type (current_gdbarch)->builtin_decdouble;
1134 decimal_from_string (putithere->typed_val_decfloat.val, 8, p);
1139 if (len >= 2 && p[len - 2] == 'd' && p[len - 1] == 'l')
1142 putithere->typed_val_decfloat.type
1143 = builtin_type (current_gdbarch)->builtin_declong;
1144 decimal_from_string (putithere->typed_val_decfloat.val, 16, p);
1150 saved_char = p[len];
1151 p[len] = 0; /* null-terminate the token */
1152 num = sscanf (p, "%" DOUBLEST_SCAN_FORMAT "%s",
1153 &putithere->typed_val_float.dval, s);
1154 p[len] = saved_char; /* restore the input stream */
1157 putithere->typed_val_float.type =
1158 builtin_type (current_gdbarch)->builtin_double;
1162 /* See if it has any float suffix: 'f' for float, 'l' for long
1164 if (!strcasecmp (s, "f"))
1165 putithere->typed_val_float.type =
1166 builtin_type (current_gdbarch)->builtin_float;
1167 else if (!strcasecmp (s, "l"))
1168 putithere->typed_val_float.type =
1169 builtin_type (current_gdbarch)->builtin_long_double;
1181 /* Handle base-switching prefixes 0x, 0t, 0d, 0 */
1215 if (c >= 'A' && c <= 'Z')
1217 if (c != 'l' && c != 'u')
1219 if (c >= '0' && c <= '9')
1227 if (base > 10 && c >= 'a' && c <= 'f')
1231 n += i = c - 'a' + 10;
1244 return ERROR; /* Char not a digit */
1247 return ERROR; /* Invalid digit in this base */
1249 /* Portably test for overflow (only works for nonzero values, so make
1250 a second check for zero). FIXME: Can't we just make n and prevn
1251 unsigned and avoid this? */
1252 if (c != 'l' && c != 'u' && (prevn >= n) && n != 0)
1253 unsigned_p = 1; /* Try something unsigned */
1255 /* Portably test for unsigned overflow.
1256 FIXME: This check is wrong; for example it doesn't find overflow
1257 on 0x123456789 when LONGEST is 32 bits. */
1258 if (c != 'l' && c != 'u' && n != 0)
1260 if ((unsigned_p && (ULONGEST) prevn >= (ULONGEST) n))
1261 error ("Numeric constant too large.");
1266 /* An integer constant is an int, a long, or a long long. An L
1267 suffix forces it to be long; an LL suffix forces it to be long
1268 long. If not forced to a larger size, it gets the first type of
1269 the above that it fits in. To figure out whether it fits, we
1270 shift it right and see whether anything remains. Note that we
1271 can't shift sizeof (LONGEST) * HOST_CHAR_BIT bits or more in one
1272 operation, because many compilers will warn about such a shift
1273 (which always produces a zero result). Sometimes gdbarch_int_bit
1274 or gdbarch_long_bit will be that big, sometimes not. To deal with
1275 the case where it is we just always shift the value more than
1276 once, with fewer bits each time. */
1278 un = (ULONGEST)n >> 2;
1280 && (un >> (gdbarch_int_bit (current_gdbarch) - 2)) == 0)
1282 high_bit = ((ULONGEST)1) << (gdbarch_int_bit (current_gdbarch) - 1);
1284 /* A large decimal (not hex or octal) constant (between INT_MAX
1285 and UINT_MAX) is a long or unsigned long, according to ANSI,
1286 never an unsigned int, but this code treats it as unsigned
1287 int. This probably should be fixed. GCC gives a warning on
1290 unsigned_type = builtin_type (current_gdbarch)->builtin_unsigned_int;
1291 signed_type = builtin_type (current_gdbarch)->builtin_int;
1293 else if (long_p <= 1
1294 && (un >> (gdbarch_long_bit (current_gdbarch) - 2)) == 0)
1296 high_bit = ((ULONGEST)1) << (gdbarch_long_bit (current_gdbarch) - 1);
1297 unsigned_type = builtin_type (current_gdbarch)->builtin_unsigned_long;
1298 signed_type = builtin_type (current_gdbarch)->builtin_long;
1303 if (sizeof (ULONGEST) * HOST_CHAR_BIT
1304 < gdbarch_long_long_bit (current_gdbarch))
1305 /* A long long does not fit in a LONGEST. */
1306 shift = (sizeof (ULONGEST) * HOST_CHAR_BIT - 1);
1308 shift = (gdbarch_long_long_bit (current_gdbarch) - 1);
1309 high_bit = (ULONGEST) 1 << shift;
1310 unsigned_type = builtin_type (current_gdbarch)->builtin_unsigned_long_long;
1311 signed_type = builtin_type (current_gdbarch)->builtin_long_long;
1314 putithere->typed_val_int.val = n;
1316 /* If the high bit of the worked out type is set then this number
1317 has to be unsigned. */
1319 if (unsigned_p || (n & high_bit))
1321 putithere->typed_val_int.type = unsigned_type;
1325 putithere->typed_val_int.type = signed_type;
1335 enum exp_opcode opcode;
1338 static const struct token tokentab3[] =
1340 {">>=", ASSIGN_MODIFY, BINOP_RSH},
1341 {"<<=", ASSIGN_MODIFY, BINOP_LSH}
1344 static const struct token tokentab2[] =
1346 {"+=", ASSIGN_MODIFY, BINOP_ADD},
1347 {"-=", ASSIGN_MODIFY, BINOP_SUB},
1348 {"*=", ASSIGN_MODIFY, BINOP_MUL},
1349 {"/=", ASSIGN_MODIFY, BINOP_DIV},
1350 {"%=", ASSIGN_MODIFY, BINOP_REM},
1351 {"|=", ASSIGN_MODIFY, BINOP_BITWISE_IOR},
1352 {"&=", ASSIGN_MODIFY, BINOP_BITWISE_AND},
1353 {"^=", ASSIGN_MODIFY, BINOP_BITWISE_XOR},
1354 {"++", INCREMENT, BINOP_END},
1355 {"--", DECREMENT, BINOP_END},
1356 {"->", ARROW, BINOP_END},
1357 {"&&", ANDAND, BINOP_END},
1358 {"||", OROR, BINOP_END},
1359 {"::", COLONCOLON, BINOP_END},
1360 {"<<", LSH, BINOP_END},
1361 {">>", RSH, BINOP_END},
1362 {"==", EQUAL, BINOP_END},
1363 {"!=", NOTEQUAL, BINOP_END},
1364 {"<=", LEQ, BINOP_END},
1365 {">=", GEQ, BINOP_END}
1368 /* This is set if a NAME token appeared at the very end of the input
1369 string, with no whitespace separating the name from the EOF. This
1370 is used only when parsing to do field name completion. */
1371 static int saw_name_at_eof;
1373 /* This is set if the previously-returned token was a structure
1374 operator -- either '.' or ARROW. This is used only when parsing to
1375 do field name completion. */
1376 static int last_was_structop;
1378 /* Read one token, getting characters through lexptr. */
1389 static char *tempbuf;
1390 static int tempbufsize;
1391 char * token_string = NULL;
1392 int class_prefix = 0;
1393 int saw_structop = last_was_structop;
1395 last_was_structop = 0;
1399 /* Check if this is a macro invocation that we need to expand. */
1400 if (! scanning_macro_expansion ())
1402 char *expanded = macro_expand_next (&lexptr,
1403 expression_macro_lookup_func,
1404 expression_macro_lookup_baton);
1407 scan_macro_expansion (expanded);
1410 prev_lexptr = lexptr;
1413 /* See if it is a special token of length 3. */
1414 for (i = 0; i < sizeof tokentab3 / sizeof tokentab3[0]; i++)
1415 if (strncmp (tokstart, tokentab3[i].operator, 3) == 0)
1418 yylval.opcode = tokentab3[i].opcode;
1419 return tokentab3[i].token;
1422 /* See if it is a special token of length 2. */
1423 for (i = 0; i < sizeof tokentab2 / sizeof tokentab2[0]; i++)
1424 if (strncmp (tokstart, tokentab2[i].operator, 2) == 0)
1427 yylval.opcode = tokentab2[i].opcode;
1428 if (in_parse_field && tokentab2[i].token == ARROW)
1429 last_was_structop = 1;
1430 return tokentab2[i].token;
1433 switch (c = *tokstart)
1436 /* If we were just scanning the result of a macro expansion,
1437 then we need to resume scanning the original text.
1438 If we're parsing for field name completion, and the previous
1439 token allows such completion, return a COMPLETE token.
1440 Otherwise, we were already scanning the original text, and
1441 we're really done. */
1442 if (scanning_macro_expansion ())
1444 finished_macro_expansion ();
1447 else if (saw_name_at_eof)
1449 saw_name_at_eof = 0;
1452 else if (saw_structop)
1464 /* We either have a character constant ('0' or '\177' for example)
1465 or we have a quoted symbol reference ('foo(int,int)' in C++
1470 c = parse_escape (&lexptr);
1472 error ("Empty character constant.");
1473 else if (! host_char_to_target (c, &c))
1475 int toklen = lexptr - tokstart + 1;
1476 char *tok = alloca (toklen + 1);
1477 memcpy (tok, tokstart, toklen);
1479 error ("There is no character corresponding to %s in the target "
1480 "character set `%s'.", tok, target_charset ());
1483 yylval.typed_val_int.val = c;
1484 yylval.typed_val_int.type = builtin_type (current_gdbarch)->builtin_char;
1489 namelen = skip_quoted (tokstart) - tokstart;
1492 lexptr = tokstart + namelen;
1493 if (lexptr[-1] != '\'')
1494 error ("Unmatched single quote.");
1499 error ("Invalid character constant.");
1509 if (paren_depth == 0)
1516 if (comma_terminates
1518 && ! scanning_macro_expansion ())
1524 /* Might be a floating point number. */
1525 if (lexptr[1] < '0' || lexptr[1] > '9')
1528 last_was_structop = 1;
1529 goto symbol; /* Nope, must be a symbol. */
1531 /* FALL THRU into number case. */
1544 /* It's a number. */
1545 int got_dot = 0, got_e = 0, toktype;
1547 int hex = input_radix > 10;
1549 if (c == '0' && (p[1] == 'x' || p[1] == 'X'))
1554 else if (c == '0' && (p[1]=='t' || p[1]=='T' || p[1]=='d' || p[1]=='D'))
1562 /* This test includes !hex because 'e' is a valid hex digit
1563 and thus does not indicate a floating point number when
1564 the radix is hex. */
1565 if (!hex && !got_e && (*p == 'e' || *p == 'E'))
1566 got_dot = got_e = 1;
1567 /* This test does not include !hex, because a '.' always indicates
1568 a decimal floating point number regardless of the radix. */
1569 else if (!got_dot && *p == '.')
1571 else if (got_e && (p[-1] == 'e' || p[-1] == 'E')
1572 && (*p == '-' || *p == '+'))
1573 /* This is the sign of the exponent, not the end of the
1576 /* We will take any letters or digits. parse_number will
1577 complain if past the radix, or if L or U are not final. */
1578 else if ((*p < '0' || *p > '9')
1579 && ((*p < 'a' || *p > 'z')
1580 && (*p < 'A' || *p > 'Z')))
1583 toktype = parse_number (tokstart, p - tokstart, got_dot|got_e, &yylval);
1584 if (toktype == ERROR)
1586 char *err_copy = (char *) alloca (p - tokstart + 1);
1588 memcpy (err_copy, tokstart, p - tokstart);
1589 err_copy[p - tokstart] = 0;
1590 error ("Invalid number \"%s\".", err_copy);
1622 /* Build the gdb internal form of the input string in tempbuf,
1623 translating any standard C escape forms seen. Note that the
1624 buffer is null byte terminated *only* for the convenience of
1625 debugging gdb itself and printing the buffer contents when
1626 the buffer contains no embedded nulls. Gdb does not depend
1627 upon the buffer being null byte terminated, it uses the length
1628 string instead. This allows gdb to handle C strings (as well
1629 as strings in other languages) with embedded null bytes */
1631 tokptr = ++tokstart;
1635 char *char_start_pos = tokptr;
1637 /* Grow the static temp buffer if necessary, including allocating
1638 the first one on demand. */
1639 if (tempbufindex + 1 >= tempbufsize)
1641 tempbuf = (char *) realloc (tempbuf, tempbufsize += 64);
1647 /* Do nothing, loop will terminate. */
1651 c = parse_escape (&tokptr);
1656 tempbuf[tempbufindex++] = c;
1660 if (! host_char_to_target (c, &c))
1662 int len = tokptr - char_start_pos;
1663 char *copy = alloca (len + 1);
1664 memcpy (copy, char_start_pos, len);
1667 error ("There is no character corresponding to `%s' "
1668 "in the target character set `%s'.",
1669 copy, target_charset ());
1671 tempbuf[tempbufindex++] = c;
1674 } while ((*tokptr != '"') && (*tokptr != '\0'));
1675 if (*tokptr++ != '"')
1677 error ("Unterminated string in expression.");
1679 tempbuf[tempbufindex] = '\0'; /* See note above */
1680 yylval.sval.ptr = tempbuf;
1681 yylval.sval.length = tempbufindex;
1686 if (!(c == '_' || c == '$'
1687 || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')))
1688 /* We must have come across a bad character (e.g. ';'). */
1689 error ("Invalid character '%c' in expression.", c);
1691 /* It's a name. See how long it is. */
1693 for (c = tokstart[namelen];
1694 (c == '_' || c == '$' || (c >= '0' && c <= '9')
1695 || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '<');)
1697 /* Template parameter lists are part of the name.
1698 FIXME: This mishandles `print $a<4&&$a>3'. */
1702 /* Scan ahead to get rest of the template specification. Note
1703 that we look ahead only when the '<' adjoins non-whitespace
1704 characters; for comparison expressions, e.g. "a < b > c",
1705 there must be spaces before the '<', etc. */
1707 char * p = find_template_name_end (tokstart + namelen);
1709 namelen = p - tokstart;
1712 c = tokstart[++namelen];
1715 /* The token "if" terminates the expression and is NOT removed from
1716 the input stream. It doesn't count if it appears in the
1717 expansion of a macro. */
1719 && tokstart[0] == 'i'
1720 && tokstart[1] == 'f'
1721 && ! scanning_macro_expansion ())
1730 /* Catch specific keywords. Should be done with a data structure. */
1734 if (strncmp (tokstart, "unsigned", 8) == 0)
1736 if (current_language->la_language == language_cplus
1737 && strncmp (tokstart, "template", 8) == 0)
1739 if (strncmp (tokstart, "volatile", 8) == 0)
1740 return VOLATILE_KEYWORD;
1743 if (strncmp (tokstart, "struct", 6) == 0)
1745 if (strncmp (tokstart, "signed", 6) == 0)
1746 return SIGNED_KEYWORD;
1747 if (strncmp (tokstart, "sizeof", 6) == 0)
1749 if (strncmp (tokstart, "double", 6) == 0)
1750 return DOUBLE_KEYWORD;
1753 if (current_language->la_language == language_cplus)
1755 if (strncmp (tokstart, "false", 5) == 0)
1756 return FALSEKEYWORD;
1757 if (strncmp (tokstart, "class", 5) == 0)
1760 if (strncmp (tokstart, "union", 5) == 0)
1762 if (strncmp (tokstart, "short", 5) == 0)
1764 if (strncmp (tokstart, "const", 5) == 0)
1765 return CONST_KEYWORD;
1768 if (strncmp (tokstart, "enum", 4) == 0)
1770 if (strncmp (tokstart, "long", 4) == 0)
1772 if (current_language->la_language == language_cplus)
1774 if (strncmp (tokstart, "true", 4) == 0)
1779 if (strncmp (tokstart, "int", 3) == 0)
1786 yylval.sval.ptr = tokstart;
1787 yylval.sval.length = namelen;
1789 if (*tokstart == '$')
1791 write_dollar_variable (yylval.sval);
1795 /* Use token-type BLOCKNAME for symbols that happen to be defined as
1796 functions or symtabs. If this is not so, then ...
1797 Use token-type TYPENAME for symbols that happen to be defined
1798 currently as names of types; NAME for other symbols.
1799 The caller is not constrained to care about the distinction. */
1801 char *tmp = copy_name (yylval.sval);
1803 int is_a_field_of_this = 0;
1806 sym = lookup_symbol (tmp, expression_context_block,
1808 current_language->la_language == language_cplus
1809 ? &is_a_field_of_this : (int *) NULL);
1810 /* Call lookup_symtab, not lookup_partial_symtab, in case there are
1811 no psymtabs (coff, xcoff, or some future change to blow away the
1812 psymtabs once once symbols are read). */
1813 if (sym && SYMBOL_CLASS (sym) == LOC_BLOCK)
1815 yylval.ssym.sym = sym;
1816 yylval.ssym.is_a_field_of_this = is_a_field_of_this;
1820 { /* See if it's a file name. */
1821 struct symtab *symtab;
1823 symtab = lookup_symtab (tmp);
1827 yylval.bval = BLOCKVECTOR_BLOCK (BLOCKVECTOR (symtab), STATIC_BLOCK);
1832 if (sym && SYMBOL_CLASS (sym) == LOC_TYPEDEF)
1834 /* NOTE: carlton/2003-09-25: There used to be code here to
1835 handle nested types. It didn't work very well. See the
1836 comment before qualified_type for more info. */
1837 yylval.tsym.type = SYMBOL_TYPE (sym);
1841 = language_lookup_primitive_type_by_name (current_language,
1842 current_gdbarch, tmp);
1843 if (yylval.tsym.type != NULL)
1846 /* Input names that aren't symbols but ARE valid hex numbers,
1847 when the input radix permits them, can be names or numbers
1848 depending on the parse. Note we support radixes > 16 here. */
1850 ((tokstart[0] >= 'a' && tokstart[0] < 'a' + input_radix - 10) ||
1851 (tokstart[0] >= 'A' && tokstart[0] < 'A' + input_radix - 10)))
1853 YYSTYPE newlval; /* Its value is ignored. */
1854 hextype = parse_number (tokstart, namelen, 0, &newlval);
1857 yylval.ssym.sym = sym;
1858 yylval.ssym.is_a_field_of_this = is_a_field_of_this;
1863 /* Any other kind of symbol */
1864 yylval.ssym.sym = sym;
1865 yylval.ssym.is_a_field_of_this = is_a_field_of_this;
1866 if (in_parse_field && *lexptr == '\0')
1867 saw_name_at_eof = 1;
1875 last_was_structop = 0;
1876 saw_name_at_eof = 0;
1885 lexptr = prev_lexptr;
1887 error ("A %s in expression, near `%s'.", (msg ? msg : "error"), lexptr);