/* YACC parser for C expressions, for GDB.
- Copyright (C) 1986, 1989, 1990, 1991, 1993, 1994
- Free Software Foundation, Inc.
-This file is part of GDB.
+ Copyright 1986, 1989, 1990, 1991, 1993, 1994, 2002 Free Software
+ Foundation, Inc.
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
/* Parse a C expression from text in a string, and return the result
as a struct expression pointer. That structure contains arithmetic
#include "objfiles.h" /* For have_full_symbols and have_partial_symbols. */
#include "top.h"
#include "completer.h" /* For skip_quoted(). */
+#include "block.h"
/* Remap normal yacc parser interface names (yyparse, yylex, yyerror,
etc), as well as gratuitiously global symbol names, so we can have
%token <opcode> ASSIGN_MODIFY
-/* C++ */
-%token THIS
-
%left ','
%left ABOVE_COMMA
%right '=' ASSIGN_MODIFY
/* Expressions, not including the comma operator. */
exp : '*' exp %prec UNARY
{ write_exp_elt_opcode (UNOP_IND); }
+ ;
exp : '&' exp %prec UNARY
{ write_exp_elt_opcode (UNOP_ADDR); }
+ ;
exp : '-' exp %prec UNARY
{ write_exp_elt_opcode (UNOP_NEG); }
start_msglist();
}
msglist ']'
- { write_exp_elt_opcode (OP_MSGCALL);
+ { write_exp_elt_opcode (OP_OBJC_MSGCALL);
end_msglist();
- write_exp_elt_opcode (OP_MSGCALL);
+ write_exp_elt_opcode (OP_OBJC_MSGCALL);
}
;
start_msglist();
}
msglist ']'
- { write_exp_elt_opcode (OP_MSGCALL);
+ { write_exp_elt_opcode (OP_OBJC_MSGCALL);
end_msglist();
- write_exp_elt_opcode (OP_MSGCALL);
+ write_exp_elt_opcode (OP_OBJC_MSGCALL);
}
;
exp : '[' exp
{ start_msglist(); }
msglist ']'
- { write_exp_elt_opcode (OP_MSGCALL);
+ { write_exp_elt_opcode (OP_OBJC_MSGCALL);
end_msglist();
- write_exp_elt_opcode (OP_MSGCALL);
+ write_exp_elt_opcode (OP_OBJC_MSGCALL);
}
;
exp : SELECTOR
{
- write_exp_elt_opcode (OP_SELECTOR);
+ write_exp_elt_opcode (OP_OBJC_SELECTOR);
write_exp_string ($1);
- write_exp_elt_opcode (OP_SELECTOR); }
+ write_exp_elt_opcode (OP_OBJC_SELECTOR); }
+ ;
exp : SIZEOF '(' type ')' %prec UNARY
{ write_exp_elt_opcode (OP_LONG);
exp : NSSTRING /* ObjC NextStep NSString constant
* of the form '@' '"' string '"'.
*/
- { write_exp_elt_opcode (OP_NSSTRING);
+ { write_exp_elt_opcode (OP_OBJC_NSSTRING);
write_exp_string ($1);
- write_exp_elt_opcode (OP_NSSTRING); }
- ;
-
-/* C++. */
-exp : THIS
- { write_exp_elt_opcode (OP_THIS);
- write_exp_elt_opcode (OP_THIS); }
+ write_exp_elt_opcode (OP_OBJC_NSSTRING); }
;
-/* end of C++. */
-
block : BLOCKNAME
{
if ($1.sym != 0)
block : block COLONCOLON name
{ struct symbol *tem
= lookup_symbol (copy_name ($3), $1,
- VAR_NAMESPACE, (int *) NULL,
+ VAR_DOMAIN, (int *) NULL,
(struct symtab **) NULL);
if (!tem || SYMBOL_CLASS (tem) != LOC_BLOCK)
error ("No function \"%s\" in specified context.",
variable: block COLONCOLON name
{ struct symbol *sym;
sym = lookup_symbol (copy_name ($3), $1,
- VAR_NAMESPACE, (int *) NULL,
+ VAR_DOMAIN, (int *) NULL,
(struct symtab **) NULL);
if (sym == 0)
error ("No symbol \"%s\" in specified context.",
sym =
lookup_symbol (name, (const struct block *) NULL,
- VAR_NAMESPACE, (int *) NULL,
+ VAR_DOMAIN, (int *) NULL,
(struct symtab **) NULL);
if (sym)
{
if (innermost_block == 0 ||
contained_in (block_found, innermost_block))
innermost_block = block_found;
- write_exp_elt_opcode (OP_SELF);
- write_exp_elt_opcode (OP_SELF);
+ write_exp_elt_opcode (OP_OBJC_SELF);
+ write_exp_elt_opcode (OP_OBJC_SELF);
write_exp_elt_opcode (STRUCTOP_PTR);
write_exp_string ($1.stoken);
write_exp_elt_opcode (STRUCTOP_PTR);
else
{
struct minimal_symbol *msymbol;
- register char *arg = copy_name ($1.stoken);
+ char *arg = copy_name ($1.stoken);
msymbol =
lookup_minimal_symbol (arg, NULL, NULL);
func_mod: '(' ')'
{ $$ = 0; }
| '(' nonempty_typelist ')'
- { free ((PTR)$2); $$ = 0; }
+ { free ($2); $$ = 0; }
;
/* We used to try to recognize more pointer to member types here, but
name_not_typename (=variable, =exp) or just an exp. If
name_not_typename was ever used in an lvalue context where only a
name could occur, this might be useful. */
- | NAME_OR_INT */
+/* | NAME_OR_INT */
;
%%
static int
parse_number (p, len, parsed_float, putithere)
- register char *p;
- register int len;
+ char *p;
+ int len;
int parsed_float;
YYSTYPE *putithere;
{
/* FIXME: Shouldn't these be unsigned? We don't deal with negative
values here, and we do kind of silly things like cast to
unsigned. */
- register LONGEST n = 0;
- register LONGEST prevn = 0;
+ LONGEST n = 0;
+ LONGEST prevn = 0;
unsigned LONGEST un;
- register int i = 0;
- register int c;
- register int base = input_radix;
+ int i = 0;
+ int c;
+ int base = input_radix;
int unsigned_p = 0;
/* Number of "L" suffixes encountered. */
/* It's a float since it contains a point or an exponent. */
if (sizeof (putithere->typed_val_float.dval) <= sizeof (float))
- sscanf (p, "%g", &putithere->typed_val_float.dval);
+ sscanf (p, "%g", (float *)&putithere->typed_val_float.dval);
else if (sizeof (putithere->typed_val_float.dval) <= sizeof (double))
- sscanf (p, "%lg", &putithere->typed_val_float.dval);
+ sscanf (p, "%lg", (double *)&putithere->typed_val_float.dval);
else
{
#ifdef PRINTF_HAS_LONG_DOUBLE
return tokentab2[i].token;
}
+ c = 0;
switch (tokchr = *tokstart)
{
case 0:
c = *lexptr++;
if (c != '\'')
{
- namelen = skip_quoted (tokstart,
- get_gdb_completer_word_break_characters())
- - tokstart;
+ namelen = skip_quoted (tokstart) - tokstart;
if (namelen > 2)
{
lexptr = tokstart + namelen;
/* It's a number. */
int got_dot = 0, got_e = 0, toktype = FLOAT;
/* Initialize toktype to anything other than ERROR. */
- register char *p = tokstart;
+ char *p = tokstart;
int hex = input_radix > 10;
int local_radix = input_radix;
if (tokchr == '0' && (p[1] == 'x' || p[1] == 'X'))
if (STREQN (tokstart, "unsigned", 8))
return UNSIGNED;
if (current_language->la_language == language_cplus
- && STREQN (tokstart, "template", 8))
+ && strncmp (tokstart, "template", 8) == 0)
return TEMPLATE;
if (STREQN (tokstart, "volatile", 8))
return VOLATILE_KEYWORD;
break;
case 5:
if ((current_language->la_language == language_cplus)
- && STREQN (tokstart, "class", 5))
+ && strncmp (tokstart, "class", 5) == 0)
return CLASS;
if (STREQN (tokstart, "union", 5))
return UNION;
return ENUM;
if (STREQN (tokstart, "long", 4))
return LONG;
- if (current_language->la_language == language_cplus
- && STREQN (tokstart, "this", 4))
- {
- static const char this_name[] = {
- CPLUS_MARKER, 't', 'h', 'i', 's', '\0'
- };
-
- if (lookup_symbol (this_name, expression_context_block,
- VAR_NAMESPACE, (int *) NULL,
- (struct symtab **) NULL))
- return THIS;
- }
break;
case 3:
if (STREQN (tokstart, "int", 3))
need_this = (int *) NULL;
sym = lookup_symbol (tmp, expression_context_block,
- VAR_NAMESPACE,
+ VAR_DOMAIN,
need_this,
(struct symtab **) NULL);
/* Call lookup_symtab, not lookup_partial_symtab, in case there
tmp1[p - namestart] = '\0';
cur_sym = lookup_symbol (ncopy,
expression_context_block,
- VAR_NAMESPACE, (int *) NULL,
+ VAR_DOMAIN, (int *) NULL,
(struct symtab **) NULL);
if (cur_sym)
{
CORE_ADDR Class = lookup_objc_class(tmp);
if (Class)
{
- extern struct symbol *lookup_struct_typedef();
yylval.class.class = Class;
if ((sym = lookup_struct_typedef (tmp,
expression_context_block,