diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2004-05-21 20:23:44 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2004-05-21 20:23:44 +0000 |
commit | 54c8dbbf02ab898df1251a6323efffebe68c55e0 (patch) | |
tree | 32e0c38ddde06552627ea6acab0da40618c89575 /gnu/usr.bin/binutils/gdb/f-exp.y | |
parent | 7069eb4ee48ce3c8978f86920c62292e57f239da (diff) |
Resolve conflicts for GDB 6.1. Add local patches.
ok deraadt@
Diffstat (limited to 'gnu/usr.bin/binutils/gdb/f-exp.y')
-rw-r--r-- | gnu/usr.bin/binutils/gdb/f-exp.y | 104 |
1 files changed, 59 insertions, 45 deletions
diff --git a/gnu/usr.bin/binutils/gdb/f-exp.y b/gnu/usr.bin/binutils/gdb/f-exp.y index caf0ca6548e..adff33b4dd3 100644 --- a/gnu/usr.bin/binutils/gdb/f-exp.y +++ b/gnu/usr.bin/binutils/gdb/f-exp.y @@ -1,6 +1,7 @@ /* YACC parser for Fortran expressions, for GDB. - Copyright 1986, 1989, 1990, 1991, 1993, 1994 - Free Software Foundation, Inc. + Copyright 1986, 1989, 1990, 1991, 1993, 1994, 1995, 1996, 2000, 2001 + Free Software Foundation, Inc. + Contributed by Motorola. Adapted from the C parser by Farooq Butt (fmbutt@engage.sps.mot.com). @@ -52,6 +53,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "bfd.h" /* Required by objfiles.h. */ #include "symfile.h" /* Required by objfiles.h. */ #include "objfiles.h" /* For have_full_symbols and have_partial_symbols */ +#include "block.h" +#include <ctype.h> /* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc), as well as gratuitiously global symbol names, so we can have multiple @@ -89,6 +92,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #define yylloc f_lloc #define yyreds f_reds /* With YYDEBUG defined */ #define yytoks f_toks /* With YYDEBUG defined */ +#define yyname f_name /* With YYDEBUG defined */ +#define yyrule f_rule /* With YYDEBUG defined */ #define yylhs f_yylhs #define yylen f_yylen #define yydefred f_yydefred @@ -100,18 +105,20 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #define yycheck f_yycheck #ifndef YYDEBUG -#define YYDEBUG 1 /* Default to no yydebug support */ +#define YYDEBUG 1 /* Default to yydebug support */ #endif -int yyparse PARAMS ((void)); +#define YYFPRINTF parser_fprintf + +int yyparse (void); -static int yylex PARAMS ((void)); +static int yylex (void); -void yyerror PARAMS ((char *)); +void yyerror (char *); -static void growbuf_by_size PARAMS ((int)); +static void growbuf_by_size (int); -static int match_string_literal PARAMS ((void)); +static int match_string_literal (void); %} @@ -143,7 +150,7 @@ static int match_string_literal PARAMS ((void)); %{ /* YYSTYPE gets defined by %union */ -static int parse_number PARAMS ((char *, int, int, YYSTYPE *)); +static int parse_number (char *, int, int, YYSTYPE *); %} %type <voidval> exp type_exp start variable @@ -235,9 +242,11 @@ exp : '(' exp ')' /* 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); } @@ -277,6 +286,7 @@ arglist : exp arglist : substring { arglist_len = 2;} + ; arglist : arglist ',' exp %prec ABOVE_COMMA { arglist_len++; } @@ -466,7 +476,7 @@ variable: name_not_typename 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); @@ -555,7 +565,7 @@ direct_abs_decl: '(' abs_decl ')' func_mod: '(' ')' { $$ = 0; } | '(' nonempty_typelist ')' - { free ((PTR)$2); $$ = 0; } + { free ($2); $$ = 0; } ; typebase /* Implements (approximately): (type-qualifier)* type-specifier */ @@ -631,19 +641,18 @@ name_not_typename : NAME static int parse_number (p, len, parsed_float, putithere) - register char *p; - register int len; + char *p; + int len; int parsed_float; YYSTYPE *putithere; { - register LONGEST n = 0; - register LONGEST prevn = 0; - register int i; - register int c; - register int base = input_radix; + LONGEST n = 0; + LONGEST prevn = 0; + int c; + int base = input_radix; int unsigned_p = 0; int long_p = 0; - unsigned LONGEST high_bit; + ULONGEST high_bit; struct type *signed_type; struct type *unsigned_type; @@ -653,7 +662,7 @@ parse_number (p, len, parsed_float, putithere) /* [dD] is not understood as an exponent by atof, change it to 'e'. */ char *tmp, *tmp2; - tmp = strsave (p); + tmp = xstrdup (p); for (tmp2 = tmp; *tmp2; ++tmp2) if (*tmp2 == 'd' || *tmp2 == 'D') *tmp2 = 'e'; @@ -696,26 +705,26 @@ parse_number (p, len, parsed_float, putithere) while (len-- > 0) { c = *p++; - if (c >= 'A' && c <= 'Z') - c += 'a' - 'A'; - if (c != 'l' && c != 'u') - n *= base; - if (c >= '0' && c <= '9') - n += i = c - '0'; + if (isupper (c)) + c = tolower (c); + if (len == 0 && c == 'l') + long_p = 1; + else if (len == 0 && c == 'u') + unsigned_p = 1; else { - if (base > 10 && c >= 'a' && c <= 'f') - n += i = c - 'a' + 10; - else if (len == 0 && c == 'l') - long_p = 1; - else if (len == 0 && c == 'u') - unsigned_p = 1; + int i; + if (c >= '0' && c <= '9') + i = c - '0'; + else if (c >= 'a' && c <= 'f') + i = c - 'a' + 10; else return ERROR; /* Char not a digit */ + if (i >= base) + return ERROR; /* Invalid digit in this base */ + n *= base; + n += i; } - if (i >= base) - return ERROR; /* Invalid digit in this base */ - /* Portably test for overflow (only works for nonzero values, so make a second check for zero). */ if ((prevn >= n) && n != 0) @@ -745,13 +754,13 @@ parse_number (p, len, parsed_float, putithere) && ((n >> 2) >> (TARGET_INT_BIT-2))) /* Avoid shift warning */ || long_p) { - high_bit = ((unsigned LONGEST)1) << (TARGET_LONG_BIT-1); + high_bit = ((ULONGEST)1) << (TARGET_LONG_BIT-1); unsigned_type = builtin_type_unsigned_long; signed_type = builtin_type_long; } else { - high_bit = ((unsigned LONGEST)1) << (TARGET_INT_BIT-1); + high_bit = ((ULONGEST)1) << (TARGET_INT_BIT-1); unsigned_type = builtin_type_unsigned_int; signed_type = builtin_type_int; } @@ -923,7 +932,9 @@ yylex () char *tokstart; retry: - + + prev_lexptr = lexptr; + tokstart = lexptr; /* First of all, let us make sure we are not dealing with the @@ -933,8 +944,8 @@ yylex () { for (i = 0; boolean_values[i].name != NULL; i++) { - if STREQN (tokstart, boolean_values[i].name, - strlen (boolean_values[i].name)) + if (strncmp (tokstart, boolean_values[i].name, + strlen (boolean_values[i].name)) == 0) { lexptr += strlen (boolean_values[i].name); yylval.lval = boolean_values[i].value; @@ -946,7 +957,7 @@ yylex () /* See if it is a special .foo. operator */ for (i = 0; dot_ops[i].operator != NULL; i++) - if (STREQN (tokstart, dot_ops[i].operator, strlen (dot_ops[i].operator))) + if (strncmp (tokstart, dot_ops[i].operator, strlen (dot_ops[i].operator)) == 0) { lexptr += strlen (dot_ops[i].operator); yylval.opcode = dot_ops[i].opcode; @@ -1007,7 +1018,7 @@ yylex () { /* It's a number. */ int got_dot = 0, got_e = 0, got_d = 0, toktype; - register char *p = tokstart; + char *p = tokstart; int hex = input_radix > 10; if (c == '0' && (p[1] == 'x' || p[1] == 'X')) @@ -1103,8 +1114,8 @@ yylex () /* Catch specific keywords. */ for (i = 0; f77_keywords[i].operator != NULL; i++) - if (STREQN(tokstart, f77_keywords[i].operator, - strlen(f77_keywords[i].operator))) + if (strncmp (tokstart, f77_keywords[i].operator, + strlen(f77_keywords[i].operator)) == 0) { /* lexptr += strlen(f77_keywords[i].operator); */ yylval.opcode = f77_keywords[i].opcode; @@ -1130,7 +1141,7 @@ yylex () int hextype; sym = lookup_symbol (tmp, expression_context_block, - VAR_NAMESPACE, + VAR_DOMAIN, current_language->la_language == language_cplus ? &is_a_field_of_this : NULL, NULL); @@ -1170,5 +1181,8 @@ void yyerror (msg) char *msg; { + if (prev_lexptr) + lexptr = prev_lexptr; + error ("A %s in expression, near `%s'.", (msg ? msg : "error"), lexptr); } |