/* YACC parser for Fortran expressions, for GDB.
- Copyright (C) 1986, 1989, 1990, 1991, 1993, 1994, 1995, 1996, 2000, 2001,
- 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
- Free Software Foundation, Inc.
+ Copyright (C) 1986-2014 Free Software Foundation, Inc.
Contributed by Motorola. Adapted from the C parser by Farooq Butt
(fmbutt@engage.sps.mot.com).
%{
#include "defs.h"
-#include "gdb_string.h"
+#include <string.h>
#include "expression.h"
#include "value.h"
#include "parser-defs.h"
#define yygindex f_yygindex
#define yytable f_yytable
#define yycheck f_yycheck
+#define yyss f_yyss
+#define yysslim f_yysslim
+#define yyssp f_yyssp
+#define yystacksize f_yystacksize
+#define yyvs f_yyvs
+#define yyvsp f_yyvsp
#ifndef YYDEBUG
#define YYDEBUG 1 /* Default to yydebug support */
%{
/* YYSTYPE gets defined by %union */
-static int parse_number (char *, int, int, YYSTYPE *);
+static int parse_number (const char *, int, int, YYSTYPE *);
%}
%type <voidval> exp type_exp start variable
}
else
{
- struct minimal_symbol *msymbol;
+ struct bound_minimal_symbol msymbol;
char *arg = copy_name ($1.stoken);
msymbol =
- lookup_minimal_symbol (arg, NULL, NULL);
- if (msymbol != NULL)
+ lookup_bound_minimal_symbol (arg);
+ if (msymbol.minsym != NULL)
write_exp_msymbol (msymbol);
else if (!have_full_symbols () && !have_partial_symbols ())
error (_("No symbol table is loaded. Use the \"file\" command."));
/*** 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 (const char *p, int len, int parsed_float, YYSTYPE *putithere)
{
LONGEST n = 0;
LONGEST prevn = 0;
/* If the number is too big to be an int, or it's got an l suffix
then it's a long. Work out if this has to be a long by
- shifting right and and seeing if anything remains, and the
+ shifting right and seeing if anything remains, and the
target int size is different to the target long size.
In the expression below, we could have tested
first one on demand. */
static void
-growbuf_by_size (count)
- int count;
+growbuf_by_size (int count)
{
int growby;
static int
match_string_literal (void)
{
- char *tokptr = lexptr;
+ const char *tokptr = lexptr;
for (tempbufindex = 0, tokptr++; *tokptr != '\0'; tokptr++)
{
int c;
int namelen;
unsigned int i,token;
- char *tokstart;
+ const char *tokstart;
retry:
{
/* It's a number. */
int got_dot = 0, got_e = 0, got_d = 0, toktype;
- char *p = tokstart;
+ const char *p = tokstart;
int hex = input_radix > 10;
if (c == '0' && (p[1] == 'x' || p[1] == 'X'))
{
char *tmp = copy_name (yylval.sval);
struct symbol *sym;
- int is_a_field_of_this = 0;
+ struct field_of_this_result is_a_field_of_this;
+ enum domain_enum_tag lookup_domains[] =
+ {
+ STRUCT_DOMAIN,
+ VAR_DOMAIN,
+ MODULE_DOMAIN
+ };
+ int i;
int hextype;
-
- sym = lookup_symbol (tmp, expression_context_block,
- VAR_DOMAIN,
- parse_language->la_language == language_cplus
- ? &is_a_field_of_this : NULL);
- if (sym && SYMBOL_CLASS (sym) == LOC_TYPEDEF)
+
+ for (i = 0; i < ARRAY_SIZE (lookup_domains); ++i)
{
- yylval.tsym.type = SYMBOL_TYPE (sym);
- return TYPENAME;
+ /* Initialize this in case we *don't* use it in this call; that
+ way we can refer to it unconditionally below. */
+ memset (&is_a_field_of_this, 0, sizeof (is_a_field_of_this));
+
+ sym = lookup_symbol (tmp, expression_context_block,
+ lookup_domains[i],
+ parse_language->la_language == language_cplus
+ ? &is_a_field_of_this : NULL);
+ if (sym && SYMBOL_CLASS (sym) == LOC_TYPEDEF)
+ {
+ yylval.tsym.type = SYMBOL_TYPE (sym);
+ return TYPENAME;
+ }
+
+ if (sym)
+ break;
}
+
yylval.tsym.type
= language_lookup_primitive_type_by_name (parse_language,
parse_gdbarch, tmp);
if (hextype == INT)
{
yylval.ssym.sym = sym;
- yylval.ssym.is_a_field_of_this = is_a_field_of_this;
+ yylval.ssym.is_a_field_of_this = is_a_field_of_this.type != NULL;
return NAME_OR_INT;
}
}
/* Any other kind of symbol */
yylval.ssym.sym = sym;
- yylval.ssym.is_a_field_of_this = is_a_field_of_this;
+ yylval.ssym.is_a_field_of_this = is_a_field_of_this.type != NULL;
return NAME;
}
}
void
-yyerror (msg)
- char *msg;
+yyerror (char *msg)
{
if (prev_lexptr)
lexptr = prev_lexptr;