+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>
* i386nbsd-nat.c (i386nbsd_supply_pcb): Cast to 'gdb_byte *' in
/* YACC parser for Fortran expressions, for GDB.
- Copyright 1986, 1989, 1990, 1991, 1993, 1994, 1995, 1996, 2000, 2001
- Free Software Foundation, Inc.
+ Copyright 1986, 1989, 1990, 1991, 1993, 1994, 1995, 1996, 2000, 2001,
+ 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
Contributed by Motorola. Adapted from the C parser by Farooq Butt
(fmbutt@engage.sps.mot.com).
%left '@'
%left '+' '-'
%left '*' '/' '%'
+%right STARSTAR
%right UNARY
%right '('
{ write_exp_elt_opcode (BINOP_REPEAT); }
;
+exp : exp STARSTAR exp
+ { write_exp_elt_opcode (BINOP_EXP); }
+ ;
+
exp : exp '*' exp
{ write_exp_elt_opcode (BINOP_MUL); }
;
}
}
- /* 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++)
if (strncmp (tokstart, dot_ops[i].operator, strlen (dot_ops[i].operator)) == 0)
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)
{
case 0:
v = v1 / v2;
break;
- case BINOP_EXP:
- v = pow (v1, v2);
- if (errno)
- error (_("Cannot perform exponentiation: %s"), safe_strerror (errno));
- break;
+ case BINOP_EXP:
+ errno = 0;
+ v = pow (v1, v2);
+ if (errno)
+ error (_("Cannot perform exponentiation: %s"), safe_strerror (errno));
+ break;
default:
error (_("Integer-only operation on floating point number."));
v = v1 / v2;
break;
- case BINOP_EXP:
- v = pow (v1, v2);
- if (errno)
- error (_("Cannot perform exponentiation: %s"), safe_strerror (errno));
- break;
+ case BINOP_EXP:
+ errno = 0;
+ v = pow (v1, v2);
+ if (errno)
+ error (_("Cannot perform exponentiation: %s"), safe_strerror (errno));
+ break;
case BINOP_REM:
v = v1 % v2;
error (_("Division by zero"));
break;
- case BINOP_EXP:
- v = pow (v1, v2);
- if (errno)
- error (_("Cannot perform exponentiation: %s"), safe_strerror (errno));
+ case BINOP_EXP:
+ errno = 0;
+ v = pow (v1, v2);
+ if (errno)
+ error (_("Cannot perform exponentiation: %s"), safe_strerror (errno));
break;
case BINOP_REM: