/* YACC parser for Ada expressions, for GDB.
- Copyright (C) 1986-2014 Free Software Foundation, Inc.
+ Copyright (C) 1986-2017 Free Software Foundation, Inc.
This file is part of GDB.
#define parse_type(ps) builtin_type (parse_gdbarch (ps))
-/* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc),
- as well as gratuitiously global symbol names, so we can have multiple
- yacc generated parsers in gdb. These are only the variables
- produced by yacc. If other parser generators (bison, byacc, etc) produce
- additional global names that conflict at link time, then those parser
- generators need to be fixed instead of adding those names to this list. */
-
-/* NOTE: This is clumsy, especially since BISON and FLEX provide --prefix
- options. I presume we are maintaining it to accommodate systems
- without BISON? (PNH) */
-
-#define yymaxdepth ada_maxdepth
-/* ada_parse calls this after initialization */
-#define yyparse ada_parse_internal
-#define yylex ada_lex
-#define yyerror ada_error
-#define yylval ada_lval
-#define yychar ada_char
-#define yydebug ada_debug
-#define yypact ada_pact
-#define yyr1 ada_r1
-#define yyr2 ada_r2
-#define yydef ada_def
-#define yychk ada_chk
-#define yypgo ada_pgo
-#define yyact ada_act
-#define yyexca ada_exca
-#define yyerrflag ada_errflag
-#define yynerrs ada_nerrs
-#define yyps ada_ps
-#define yypv ada_pv
-#define yys ada_s
-#define yy_yys ada_yys
-#define yystate ada_state
-#define yytmp ada_tmp
-#define yyv ada_v
-#define yy_yyv ada_yyv
-#define yyval ada_val
-#define yylloc ada_lloc
-#define yyreds ada_reds /* With YYDEBUG defined */
-#define yytoks ada_toks /* With YYDEBUG defined */
-#define yyname ada_name /* With YYDEBUG defined */
-#define yyrule ada_rule /* With YYDEBUG defined */
-#define yyss ada_yyss
-#define yysslim ada_yysslim
-#define yyssp ada_yyssp
-#define yystacksize ada_yystacksize
-#define yyvs ada_yyvs
-#define yyvsp ada_yyvsp
-
-#ifndef YYDEBUG
-#define YYDEBUG 1 /* Default to yydebug support */
-#endif
-
-#define YYFPRINTF parser_fprintf
+/* Remap normal yacc parser interface names (yyparse, yylex, yyerror,
+ etc). */
+#define GDB_YY_REMAP_PREFIX ada_
+#include "yy-remap.h"
struct name_info {
struct symbol *sym;
static int yylex (void);
-void yyerror (char *);
+void yyerror (const char *);
static void write_int (struct parser_state *, LONGEST, struct type *);
}
void
-yyerror (char *msg)
+yyerror (const char *msg)
{
error (_("Error in expression, near `%s'."), lexptr);
}
{
char *name;
enum { SIMPLE_INDEX, LOWER_BOUND, UPPER_BOUND } slice_state;
- struct ada_symbol_info sym_info;
+ struct block_symbol sym_info;
if (max_depth <= 0)
error (_("Could not find renamed symbol"));
if (orig_left_context == NULL)
orig_left_context = get_selected_block (NULL);
- name = obstack_copy0 (&temp_parse_space, renamed_entity, renamed_entity_len);
+ name = (char *) obstack_copy0 (&temp_parse_space, renamed_entity,
+ renamed_entity_len);
ada_lookup_encoded_symbol (name, orig_left_context, VAR_DOMAIN, &sym_info);
- if (sym_info.sym == NULL)
+ if (sym_info.symbol == NULL)
error (_("Could not find renamed variable: %s"), ada_decode (name));
- else if (SYMBOL_CLASS (sym_info.sym) == LOC_TYPEDEF)
+ else if (SYMBOL_CLASS (sym_info.symbol) == LOC_TYPEDEF)
/* We have a renaming of an old-style renaming symbol. Don't
trust the block information. */
sym_info.block = orig_left_context;
int inner_renamed_entity_len;
const char *inner_renaming_expr;
- switch (ada_parse_renaming (sym_info.sym, &inner_renamed_entity,
+ switch (ada_parse_renaming (sym_info.symbol, &inner_renamed_entity,
&inner_renamed_entity_len,
&inner_renaming_expr))
{
case ADA_NOT_RENAMING:
write_var_from_sym (par_state, orig_left_context, sym_info.block,
- sym_info.sym);
+ sym_info.symbol);
break;
case ADA_OBJECT_RENAMING:
write_object_renaming (par_state, sym_info.block,
{
const char *end;
char *index_name;
- struct ada_symbol_info index_sym_info;
+ struct block_symbol index_sym_info;
end = strchr (renaming_expr, 'X');
if (end == NULL)
end = renaming_expr + strlen (renaming_expr);
- index_name =
- obstack_copy0 (&temp_parse_space, renaming_expr,
- end - renaming_expr);
+ index_name
+ = (char *) obstack_copy0 (&temp_parse_space, renaming_expr,
+ end - renaming_expr);
renaming_expr = end;
ada_lookup_encoded_symbol (index_name, NULL, VAR_DOMAIN,
&index_sym_info);
- if (index_sym_info.sym == NULL)
+ if (index_sym_info.symbol == NULL)
error (_("Could not find %s"), index_name);
- else if (SYMBOL_CLASS (index_sym_info.sym) == LOC_TYPEDEF)
+ else if (SYMBOL_CLASS (index_sym_info.symbol) == LOC_TYPEDEF)
/* Index is an old-style renaming symbol. */
index_sym_info.block = orig_left_context;
write_var_from_sym (par_state, NULL, index_sym_info.block,
- index_sym_info.sym);
+ index_sym_info.symbol);
}
if (slice_state == SIMPLE_INDEX)
{
if (end == NULL)
end = renaming_expr + strlen (renaming_expr);
field_name.length = end - renaming_expr;
- buf = malloc (end - renaming_expr + 1);
+ buf = (char *) malloc (end - renaming_expr + 1);
field_name.ptr = buf;
strncpy (buf, renaming_expr, end - renaming_expr);
buf[end - renaming_expr] = '\000';
block_lookup (const struct block *context, const char *raw_name)
{
const char *name;
- struct ada_symbol_info *syms;
+ struct block_symbol *syms;
int nsyms;
struct symtab *symtab;
nsyms = ada_lookup_symbol_list (name, context, VAR_DOMAIN, &syms);
if (context == NULL
- && (nsyms == 0 || SYMBOL_CLASS (syms[0].sym) != LOC_BLOCK))
+ && (nsyms == 0 || SYMBOL_CLASS (syms[0].symbol) != LOC_BLOCK))
symtab = lookup_symtab (name);
else
symtab = NULL;
if (symtab != NULL)
return BLOCKVECTOR_BLOCK (SYMTAB_BLOCKVECTOR (symtab), STATIC_BLOCK);
- else if (nsyms == 0 || SYMBOL_CLASS (syms[0].sym) != LOC_BLOCK)
+ else if (nsyms == 0 || SYMBOL_CLASS (syms[0].symbol) != LOC_BLOCK)
{
if (context == NULL)
error (_("No file or function \"%s\"."), raw_name);
{
if (nsyms > 1)
warning (_("Function name \"%s\" ambiguous here"), raw_name);
- return SYMBOL_BLOCK_VALUE (syms[0].sym);
+ return SYMBOL_BLOCK_VALUE (syms[0].symbol);
}
}
static struct symbol*
-select_possible_type_sym (struct ada_symbol_info *syms, int nsyms)
+select_possible_type_sym (struct block_symbol *syms, int nsyms)
{
int i;
int preferred_index;
preferred_index = -1; preferred_type = NULL;
for (i = 0; i < nsyms; i += 1)
- switch (SYMBOL_CLASS (syms[i].sym))
+ switch (SYMBOL_CLASS (syms[i].symbol))
{
case LOC_TYPEDEF:
- if (ada_prefer_type (SYMBOL_TYPE (syms[i].sym), preferred_type))
+ if (ada_prefer_type (SYMBOL_TYPE (syms[i].symbol), preferred_type))
{
preferred_index = i;
- preferred_type = SYMBOL_TYPE (syms[i].sym);
+ preferred_type = SYMBOL_TYPE (syms[i].symbol);
}
break;
case LOC_REGISTER:
}
if (preferred_type == NULL)
return NULL;
- return syms[preferred_index].sym;
+ return syms[preferred_index].symbol;
}
static struct type*
find_primitive_type (struct parser_state *par_state, char *name)
{
struct type *type;
- type = language_lookup_primitive_type_by_name (parse_language (par_state),
- parse_gdbarch (par_state),
- name);
+ type = language_lookup_primitive_type (parse_language (par_state),
+ parse_gdbarch (par_state),
+ name);
if (type == NULL && strcmp ("system__address", name) == 0)
type = type_system_address (par_state);
(char *) alloca (strlen (name) + sizeof ("standard__"));
strcpy (expanded_name, "standard__");
strcat (expanded_name, name);
- sym = ada_lookup_symbol (expanded_name, NULL, VAR_DOMAIN, NULL);
+ sym = ada_lookup_symbol (expanded_name, NULL, VAR_DOMAIN, NULL).symbol;
if (sym != NULL && SYMBOL_CLASS (sym) == LOC_TYPEDEF)
type = SYMBOL_TYPE (sym);
}
write_ambiguous_var (struct parser_state *par_state,
const struct block *block, char *name, int len)
{
- struct symbol *sym =
- obstack_alloc (&temp_parse_space, sizeof (struct symbol));
+ struct symbol *sym = XOBNEW (&temp_parse_space, struct symbol);
+
memset (sym, 0, sizeof (struct symbol));
SYMBOL_DOMAIN (sym) = UNDEF_DOMAIN;
- SYMBOL_LINKAGE_NAME (sym) = obstack_copy0 (&temp_parse_space, name, len);
+ SYMBOL_LINKAGE_NAME (sym)
+ = (const char *) obstack_copy0 (&temp_parse_space, name, len);
SYMBOL_LANGUAGE (sym) = language_ada;
write_exp_elt_opcode (par_state, OP_VAR_VALUE);
ada_nget_field_index (const struct type *type, const char *field_name0,
int field_name_len, int maybe_missing)
{
- char *field_name = alloca ((field_name_len + 1) * sizeof (char));
+ char *field_name = (char *) alloca ((field_name_len + 1) * sizeof (char));
strncpy (field_name, field_name0, field_name_len);
field_name[field_name_len] = '\0';
encoded_name = ada_encode (name0.ptr);
name_len = strlen (encoded_name);
- encoded_name = obstack_copy0 (&temp_parse_space, encoded_name, name_len);
+ encoded_name
+ = (char *) obstack_copy0 (&temp_parse_space, encoded_name, name_len);
for (depth = 0; depth < MAX_RENAMING_CHAIN_LENGTH; depth += 1)
{
int tail_index;
while (tail_index > 0)
{
int nsyms;
- struct ada_symbol_info *syms;
+ struct block_symbol *syms;
struct symbol *type_sym;
struct symbol *renaming_sym;
const char* renaming;
if (nsyms == 1)
{
struct symbol *ren_sym =
- ada_find_renaming_symbol (syms[0].sym, syms[0].block);
+ ada_find_renaming_symbol (syms[0].symbol, syms[0].block);
if (ren_sym != NULL)
- syms[0].sym = ren_sym;
+ syms[0].symbol = ren_sym;
}
type_sym = select_possible_type_sym (syms, nsyms);
if (type_sym != NULL)
renaming_sym = type_sym;
else if (nsyms == 1)
- renaming_sym = syms[0].sym;
+ renaming_sym = syms[0].symbol;
else
renaming_sym = NULL;
case ADA_EXCEPTION_RENAMING:
case ADA_SUBPROGRAM_RENAMING:
{
+ int alloc_len = renaming_len + name_len - tail_index + 1;
char *new_name
- = obstack_alloc (&temp_parse_space,
- renaming_len + name_len - tail_index + 1);
+ = (char *) obstack_alloc (&temp_parse_space, alloc_len);
strncpy (new_name, renaming, renaming_len);
strcpy (new_name + renaming_len, encoded_name + tail_index);
encoded_name = new_name;
if (nsyms == 1)
{
write_var_from_sym (par_state, block, syms[0].block,
- syms[0].sym);
+ syms[0].symbol);
write_selectors (par_state, encoded_name + tail_index);
return NULL;
}
{
if (strchr (name.ptr, '.') == NULL)
{
- struct ada_symbol_info *syms;
+ struct block_symbol *syms;
int nsyms = ada_lookup_symbol_list (name.ptr, expression_context_block,
VAR_DOMAIN, &syms);
- if (nsyms != 1 || SYMBOL_CLASS (syms[0].sym) == LOC_TYPEDEF)
+
+ if (nsyms != 1 || SYMBOL_CLASS (syms[0].symbol) == LOC_TYPEDEF)
write_exp_op_with_string (par_state, OP_NAME, name);
else
- write_var_from_sym (par_state, NULL, syms[0].block, syms[0].sym);
+ write_var_from_sym (par_state, NULL, syms[0].block, syms[0].symbol);
}
else
if (write_var_or_type (par_state, NULL, name) != NULL)
type_system_address (struct parser_state *par_state)
{
struct type *type
- = language_lookup_primitive_type_by_name (parse_language (par_state),
- parse_gdbarch (par_state),
- "system__address");
+ = language_lookup_primitive_type (parse_language (par_state),
+ parse_gdbarch (par_state),
+ "system__address");
return type != NULL ? type : parse_type (par_state)->builtin_data_ptr;
}