/* YACC parser for C expressions, for GDB.
- Copyright (C) 1986, 1989, 1990, 1991, 1993, 1994, 2002, 2006, 2007, 2008
- Free Software Foundation, Inc.
+ Copyright (C) 1986, 1989-1991, 1993-1994, 2002, 2006-2012 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
+ the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
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., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA. */
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* Parse a C expression from text in a string, and return the result
as a struct expression pointer. That structure contains arithmetic
#define YYDEBUG 0 /* Default to no yydebug support. */
#endif
-int
-yyparse (void);
+int yyparse (void);
-static int
-yylex (void);
+static int yylex (void);
-void
-yyerror (char *);
+void yyerror (char *);
%}
%{
/* YYSTYPE gets defined by %union. */
-static int
-parse_number (char *, int, int, YYSTYPE *);
+static int parse_number (char *, int, int, YYSTYPE *);
%}
%type <voidval> exp exp1 type_exp start variable qualified_name lcurly
%token <sval> STRING
%token <sval> NSSTRING /* ObjC Foundation "NSString" literal */
%token <sval> SELECTOR /* ObjC "@selector" pseudo-operator */
-%token <ssym> NAME /* BLOCKNAME defined below to give it higher precedence. */
+%token <ssym> NAME /* BLOCKNAME defined below to give it higher precedence. */
%token <tsym> TYPENAME
%token <class> CLASSNAME /* ObjC Class name */
%type <sval> name
{
CORE_ADDR class;
- class = lookup_objc_class (copy_name ($2.stoken));
+ class = lookup_objc_class (parse_gdbarch,
+ copy_name ($2.stoken));
if (class == 0)
- error ("%s is not an ObjC Class",
+ error (_("%s is not an ObjC Class"),
copy_name ($2.stoken));
write_exp_elt_opcode (OP_LONG);
write_exp_elt_type (parse_type->builtin_int);
exp : NAME_OR_INT
{ YYSTYPE val;
- parse_number ($1.stoken.ptr, $1.stoken.length, 0, &val);
+ parse_number ($1.stoken.ptr,
+ $1.stoken.length, 0, &val);
write_exp_elt_opcode (OP_LONG);
write_exp_elt_type (val.typed_val_int.type);
- write_exp_elt_longcst ((LONGEST)val.typed_val_int.val);
+ write_exp_elt_longcst ((LONGEST)
+ val.typed_val_int.val);
write_exp_elt_opcode (OP_LONG);
}
;
struct symtab *tem =
lookup_symtab (copy_name ($1.stoken));
if (tem)
- $$ = BLOCKVECTOR_BLOCK (BLOCKVECTOR (tem), STATIC_BLOCK);
+ $$ = BLOCKVECTOR_BLOCK (BLOCKVECTOR (tem),
+ STATIC_BLOCK);
else
- error ("No file or function \"%s\".",
+ error (_("No file or function \"%s\"."),
copy_name ($1.stoken));
}
}
= lookup_symbol (copy_name ($3), $1,
VAR_DOMAIN, (int *) NULL);
if (!tem || SYMBOL_CLASS (tem) != LOC_BLOCK)
- error ("No function \"%s\" in specified context.",
+ error (_("No function \"%s\" in specified context."),
copy_name ($3));
$$ = SYMBOL_BLOCK_VALUE (tem); }
;
sym = lookup_symbol (copy_name ($3), $1,
VAR_DOMAIN, (int *) NULL);
if (sym == 0)
- error ("No symbol \"%s\" in specified context.",
+ error (_("No symbol \"%s\" in specified context."),
copy_name ($3));
+ if (symbol_read_needs_frame (sym))
+ {
+ if (innermost_block == 0
+ || contained_in (block_found,
+ innermost_block))
+ innermost_block = block_found;
+ }
write_exp_elt_opcode (OP_VAR_VALUE);
/* block_found is set by lookup_symbol. */
struct type *type = $1;
if (TYPE_CODE (type) != TYPE_CODE_STRUCT
&& TYPE_CODE (type) != TYPE_CODE_UNION)
- error ("`%s' is not defined as an aggregate type.",
+ error (_("`%s' is not defined as an aggregate type."),
TYPE_NAME (type));
write_exp_elt_opcode (OP_SCOPE);
struct stoken tmp_token;
if (TYPE_CODE (type) != TYPE_CODE_STRUCT
&& TYPE_CODE (type) != TYPE_CODE_UNION)
- error ("`%s' is not defined as an aggregate type.",
+ error (_("`%s' is not defined as an aggregate type."),
TYPE_NAME (type));
if (strcmp (type_name_no_tag (type), $4.ptr) != 0)
- error ("invalid destructor `%s::~%s'",
+ error (_("invalid destructor `%s::~%s'"),
type_name_no_tag (type), $4.ptr);
tmp_token.ptr = (char*) alloca ($4.length + 2);
msymbol = lookup_minimal_symbol (name, NULL, NULL);
if (msymbol != NULL)
write_exp_msymbol (msymbol);
- else if (!have_full_symbols () && !have_partial_symbols ())
- error ("No symbol table is loaded. Use the \"file\" command.");
+ else if (!have_full_symbols ()
+ && !have_partial_symbols ())
+ error (_("No symbol table is loaded. "
+ "Use the \"file\" command."));
else
- error ("No symbol \"%s\" in current context.", name);
+ error (_("No symbol \"%s\" in current context."),
+ name);
}
;
if (innermost_block == 0 ||
contained_in (block_found, innermost_block))
innermost_block = block_found;
- write_exp_elt_opcode (OP_OBJC_SELF);
- write_exp_elt_opcode (OP_OBJC_SELF);
+ write_exp_elt_opcode (OP_THIS);
+ write_exp_elt_opcode (OP_THIS);
write_exp_elt_opcode (STRUCTOP_PTR);
write_exp_string ($1.stoken);
write_exp_elt_opcode (STRUCTOP_PTR);
write_exp_msymbol (msymbol);
else if (!have_full_symbols () &&
!have_partial_symbols ())
- error ("No symbol table is loaded. Use the \"file\" command.");
+ error (_("No symbol table is loaded. "
+ "Use the \"file\" command."));
else
- error ("No symbol \"%s\" in current context.",
+ error (_("No symbol \"%s\" in current context."),
copy_name ($1.stoken));
}
}
| CLASSNAME
{
if ($1.type == NULL)
- error ("No symbol \"%s\" in current context.",
+ error (_("No symbol \"%s\" in current context."),
copy_name($1.stoken));
else
$$ = $1.type;
{ $$ = lookup_enum (copy_name ($2),
expression_context_block); }
| UNSIGNED typename
- { $$ = lookup_unsigned_typename (TYPE_NAME($2.type)); }
+ { $$ = lookup_unsigned_typename (parse_language,
+ parse_gdbarch,
+ TYPE_NAME($2.type)); }
| UNSIGNED
{ $$ = parse_type->builtin_unsigned_int; }
| SIGNED_KEYWORD typename
- { $$ = lookup_signed_typename (TYPE_NAME($2.type)); }
+ { $$ = lookup_signed_typename (parse_language,
+ parse_gdbarch,
+ TYPE_NAME($2.type)); }
| SIGNED_KEYWORD
{ $$ = parse_type->builtin_int; }
| TEMPLATE name '<' type '>'
/*** Needs some error checking for the float case. ***/
static int
-parse_number (p, len, parsed_float, putithere)
- char *p;
- int len;
- int parsed_float;
- YYSTYPE *putithere;
+parse_number (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
if (parsed_float)
{
- char c;
-
- /* It's a float since it contains a point or an exponent. */
-
- sscanf (p, "%" DOUBLEST_SCAN_FORMAT "%c",
- &putithere->typed_val_float.dval, &c);
-
- /* See if it has `f' or `l' suffix (float or long double). */
-
- c = tolower (p[len - 1]);
-
- if (c == 'f')
- putithere->typed_val_float.type = parse_type->builtin_float;
- else if (c == 'l')
- putithere->typed_val_float.type = parse_type->builtin_long_double;
- else if (isdigit (c) || c == '.')
- putithere->typed_val_float.type = parse_type->builtin_double;
- else
+ if (! parse_c_float (parse_gdbarch, p, len,
+ &putithere->typed_val_float.dval,
+ &putithere->typed_val_float.type))
return ERROR;
-
return FLOAT;
}
if (c != 'l' && c != 'u' && n != 0)
{
if ((unsigned_p && (unsigned LONGEST) prevn >= (unsigned LONGEST) n))
- error ("Numeric constant too large.");
+ error (_("Numeric constant too large."));
}
prevn = n;
}
if (long_p == 0
&& (un >> (gdbarch_int_bit (parse_gdbarch) - 2)) == 0)
{
- high_bit = ((unsigned LONGEST)1) << (gdbarch_int_bit (parse_gdbarch) - 1);
+ high_bit
+ = ((unsigned LONGEST)1) << (gdbarch_int_bit (parse_gdbarch) - 1);
/* A large decimal (not hex or octal) constant (between INT_MAX
and UINT_MAX) is a long or unsigned long, according to ANSI,
else if (long_p <= 1
&& (un >> (gdbarch_long_bit (parse_gdbarch) - 2)) == 0)
{
- high_bit = ((unsigned LONGEST)1) << (gdbarch_long_bit (parse_gdbarch) - 1);
+ high_bit
+ = ((unsigned LONGEST)1) << (gdbarch_long_bit (parse_gdbarch) - 1);
unsigned_type = parse_type->builtin_unsigned_long;
signed_type = parse_type->builtin_long;
}
/* Read one token, getting characters through lexptr. */
static int
-yylex ()
+yylex (void)
{
int c, tokchr;
int namelen;
lexptr++;
c = *lexptr++;
if (c == '\\')
- c = parse_escape (&lexptr);
+ c = parse_escape (parse_gdbarch, &lexptr);
else if (c == '\'')
- error ("Empty character constant.");
+ error (_("Empty character constant."));
yylval.typed_val_int.val = c;
yylval.typed_val_int.type = parse_type->builtin_char;
{
lexptr = tokstart + namelen;
if (lexptr[-1] != '\'')
- error ("Unmatched single quote.");
+ error (_("Unmatched single quote."));
namelen -= 2;
tokstart++;
goto tryname;
}
- error ("Invalid character constant.");
+ error (_("Invalid character constant."));
}
return INT;
hex = 1;
local_radix = 16;
}
- else if (tokchr == '0' && (p[1]=='t' || p[1]=='T' || p[1]=='d' || p[1]=='D'))
+ else if (tokchr == '0' && (p[1]=='t' || p[1]=='T'
+ || p[1]=='d' || p[1]=='D'))
{
p += 2;
hex = 0;
memcpy (err_copy, tokstart, p - tokstart);
err_copy[p - tokstart] = 0;
- error ("Invalid number \"%s\".", err_copy);
+ error (_("Invalid number \"%s\"."), err_copy);
}
lexptr = p;
return toktype;
case '^':
case '~':
case '!':
-#if 0
- case '@': /* Moved out below. */
-#endif
case '<':
case '>':
case '[':
tokptr = strchr(tokstart, '(');
if (tokptr == NULL)
{
- error ("Missing '(' in @selector(...)");
+ error (_("Missing '(' in @selector(...)"));
}
tempbufindex = 0;
tokptr++; /* Skip the '('. */
} while ((*tokptr != ')') && (*tokptr != '\0'));
if (*tokptr++ != ')')
{
- error ("Missing ')' in @selector(...)");
+ error (_("Missing ')' in @selector(...)"));
}
tempbuf[tempbufindex] = '\0';
yylval.sval.ptr = tempbuf;
break;
case '\\':
tokptr++;
- c = parse_escape (&tokptr);
+ c = parse_escape (parse_gdbarch, &tokptr);
if (c == -1)
{
continue;
} while ((*tokptr != '"') && (*tokptr != '\0'));
if (*tokptr++ != '"')
{
- error ("Unterminated string in expression.");
+ error (_("Unterminated string in expression."));
}
tempbuf[tempbufindex] = '\0'; /* See note above. */
yylval.sval.ptr = tempbuf;
if (!(tokchr == '_' || tokchr == '$' ||
(tokchr >= 'a' && tokchr <= 'z') || (tokchr >= 'A' && tokchr <= 'Z')))
/* We must have come across a bad character (e.g. ';'). */
- error ("Invalid character '%c' in expression.", c);
+ error (_("Invalid character '%c' in expression."), c);
/* It's a name. See how long it is. */
namelen = 0;
/* See if it's an ObjC classname. */
if (!sym)
{
- CORE_ADDR Class = lookup_objc_class(tmp);
+ CORE_ADDR Class = lookup_objc_class (parse_gdbarch, tmp);
if (Class)
{
yylval.class.class = Class;
}
void
-yyerror (msg)
- char *msg;
+yyerror (char *msg)
{
if (*lexptr == '\0')
- error("A %s near end of expression.", (msg ? msg : "error"));
+ error(_("A %s near end of expression."), (msg ? msg : "error"));
else
- error ("A %s in expression, near `%s'.", (msg ? msg : "error"),
+ error (_("A %s in expression, near `%s'."), (msg ? msg : "error"),
lexptr);
}