* f-exp.y (yyparse): Add code to support exponentiation expression.
(yylex): Add code to scan exponentiation operator. * eval.c (evaluate_subexp_standard): Add support for BINOP_EXP. * valarith.c (value_binop): Reset errno to 0 before calling pow to do exponentiation operation.
This commit is contained in:
parent
a0c5fbcf0e
commit
bd49c137fe
4 changed files with 43 additions and 17 deletions
|
@ -1,3 +1,11 @@
|
||||||
|
2005-07-06 Wu Zhou <woodzltc@cn.ibm.com>
|
||||||
|
|
||||||
|
* f-exp.y (yyparse): Add code to support exponentiation expression.
|
||||||
|
(yylex): Add code to scan exponentiation operator.
|
||||||
|
* eval.c (evaluate_subexp_standard): Add support for BINOP_EXP.
|
||||||
|
* valarith.c (value_binop): Reset errno to 0 before calling pow
|
||||||
|
to do exponentiation operation.
|
||||||
|
|
||||||
2005-07-04 Mark Kettenis <kettenis@gnu.org>
|
2005-07-04 Mark Kettenis <kettenis@gnu.org>
|
||||||
|
|
||||||
* i386nbsd-nat.c (i386nbsd_supply_pcb): Cast to 'gdb_byte *' in
|
* i386nbsd-nat.c (i386nbsd_supply_pcb): Cast to 'gdb_byte *' in
|
||||||
|
|
|
@ -1510,6 +1510,7 @@ evaluate_subexp_standard (struct type *expect_type,
|
||||||
else
|
else
|
||||||
return value_sub (arg1, arg2);
|
return value_sub (arg1, arg2);
|
||||||
|
|
||||||
|
case BINOP_EXP:
|
||||||
case BINOP_MUL:
|
case BINOP_MUL:
|
||||||
case BINOP_DIV:
|
case BINOP_DIV:
|
||||||
case BINOP_REM:
|
case BINOP_REM:
|
||||||
|
|
20
gdb/f-exp.y
20
gdb/f-exp.y
|
@ -1,6 +1,6 @@
|
||||||
/* YACC parser for Fortran expressions, for GDB.
|
/* YACC parser for Fortran expressions, for GDB.
|
||||||
Copyright 1986, 1989, 1990, 1991, 1993, 1994, 1995, 1996, 2000, 2001
|
Copyright 1986, 1989, 1990, 1991, 1993, 1994, 1995, 1996, 2000, 2001,
|
||||||
Free Software Foundation, Inc.
|
2002, 2003, 2004, 2005 Free Software Foundation, Inc.
|
||||||
|
|
||||||
Contributed by Motorola. Adapted from the C parser by Farooq Butt
|
Contributed by Motorola. Adapted from the C parser by Farooq Butt
|
||||||
(fmbutt@engage.sps.mot.com).
|
(fmbutt@engage.sps.mot.com).
|
||||||
|
@ -217,6 +217,7 @@ static int parse_number (char *, int, int, YYSTYPE *);
|
||||||
%left '@'
|
%left '@'
|
||||||
%left '+' '-'
|
%left '+' '-'
|
||||||
%left '*' '/' '%'
|
%left '*' '/' '%'
|
||||||
|
%right STARSTAR
|
||||||
%right UNARY
|
%right UNARY
|
||||||
%right '('
|
%right '('
|
||||||
|
|
||||||
|
@ -315,6 +316,10 @@ exp : exp '@' exp
|
||||||
{ write_exp_elt_opcode (BINOP_REPEAT); }
|
{ write_exp_elt_opcode (BINOP_REPEAT); }
|
||||||
;
|
;
|
||||||
|
|
||||||
|
exp : exp STARSTAR exp
|
||||||
|
{ write_exp_elt_opcode (BINOP_EXP); }
|
||||||
|
;
|
||||||
|
|
||||||
exp : exp '*' exp
|
exp : exp '*' exp
|
||||||
{ write_exp_elt_opcode (BINOP_MUL); }
|
{ write_exp_elt_opcode (BINOP_MUL); }
|
||||||
;
|
;
|
||||||
|
@ -941,7 +946,7 @@ yylex ()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* See if it is a special .foo. operator */
|
/* See if it is a special .foo. operator. */
|
||||||
|
|
||||||
for (i = 0; dot_ops[i].operator != NULL; i++)
|
for (i = 0; dot_ops[i].operator != NULL; i++)
|
||||||
if (strncmp (tokstart, dot_ops[i].operator, strlen (dot_ops[i].operator)) == 0)
|
if (strncmp (tokstart, dot_ops[i].operator, strlen (dot_ops[i].operator)) == 0)
|
||||||
|
@ -951,6 +956,15 @@ yylex ()
|
||||||
return dot_ops[i].token;
|
return dot_ops[i].token;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* See if it is an exponentiation operator. */
|
||||||
|
|
||||||
|
if (strncmp (tokstart, "**", 2) == 0)
|
||||||
|
{
|
||||||
|
lexptr += 2;
|
||||||
|
yylval.opcode = BINOP_EXP;
|
||||||
|
return STARSTAR;
|
||||||
|
}
|
||||||
|
|
||||||
switch (c = *tokstart)
|
switch (c = *tokstart)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
|
|
|
@ -791,11 +791,12 @@ value_binop (struct value *arg1, struct value *arg2, enum exp_opcode op)
|
||||||
v = v1 / v2;
|
v = v1 / v2;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BINOP_EXP:
|
case BINOP_EXP:
|
||||||
v = pow (v1, v2);
|
errno = 0;
|
||||||
if (errno)
|
v = pow (v1, v2);
|
||||||
error (_("Cannot perform exponentiation: %s"), safe_strerror (errno));
|
if (errno)
|
||||||
break;
|
error (_("Cannot perform exponentiation: %s"), safe_strerror (errno));
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
error (_("Integer-only operation on floating point number."));
|
error (_("Integer-only operation on floating point number."));
|
||||||
|
@ -929,11 +930,12 @@ value_binop (struct value *arg1, struct value *arg2, enum exp_opcode op)
|
||||||
v = v1 / v2;
|
v = v1 / v2;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BINOP_EXP:
|
case BINOP_EXP:
|
||||||
v = pow (v1, v2);
|
errno = 0;
|
||||||
if (errno)
|
v = pow (v1, v2);
|
||||||
error (_("Cannot perform exponentiation: %s"), safe_strerror (errno));
|
if (errno)
|
||||||
break;
|
error (_("Cannot perform exponentiation: %s"), safe_strerror (errno));
|
||||||
|
break;
|
||||||
|
|
||||||
case BINOP_REM:
|
case BINOP_REM:
|
||||||
v = v1 % v2;
|
v = v1 % v2;
|
||||||
|
@ -1050,10 +1052,11 @@ value_binop (struct value *arg1, struct value *arg2, enum exp_opcode op)
|
||||||
error (_("Division by zero"));
|
error (_("Division by zero"));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BINOP_EXP:
|
case BINOP_EXP:
|
||||||
v = pow (v1, v2);
|
errno = 0;
|
||||||
if (errno)
|
v = pow (v1, v2);
|
||||||
error (_("Cannot perform exponentiation: %s"), safe_strerror (errno));
|
if (errno)
|
||||||
|
error (_("Cannot perform exponentiation: %s"), safe_strerror (errno));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BINOP_REM:
|
case BINOP_REM:
|
||||||
|
|
Loading…
Add table
Reference in a new issue