aboutsummaryrefslogtreecommitdiff
path: root/gdb/f-exp.y
diff options
context:
space:
mode:
authorWu Zhou <woodzltc@cn.ibm.com>2005-07-06 06:52:25 +0000
committerWu Zhou <woodzltc@cn.ibm.com>2005-07-06 06:52:25 +0000
commitbd49c137fee8212c7e64ce62cc07d398b1278b14 (patch)
tree1e41f9c36b171df9b614b3e443aaee1fbbe020ab /gdb/f-exp.y
parenta0c5fbcf0e1c6fdb3672d3bfc071b1a57a7b27bf (diff)
downloadgdb-bd49c137fee8212c7e64ce62cc07d398b1278b14.zip
gdb-bd49c137fee8212c7e64ce62cc07d398b1278b14.tar.gz
gdb-bd49c137fee8212c7e64ce62cc07d398b1278b14.tar.bz2
* 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.
Diffstat (limited to 'gdb/f-exp.y')
-rw-r--r--gdb/f-exp.y20
1 files changed, 17 insertions, 3 deletions
diff --git a/gdb/f-exp.y b/gdb/f-exp.y
index a066c5a..0deb816 100644
--- a/gdb/f-exp.y
+++ b/gdb/f-exp.y
@@ -1,6 +1,6 @@
/* 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).
@@ -217,6 +217,7 @@ static int parse_number (char *, int, int, YYSTYPE *);
%left '@'
%left '+' '-'
%left '*' '/' '%'
+%right STARSTAR
%right UNARY
%right '('
@@ -315,6 +316,10 @@ exp : exp '@' exp
{ 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); }
;
@@ -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++)
if (strncmp (tokstart, dot_ops[i].operator, strlen (dot_ops[i].operator)) == 0)
@@ -951,6 +956,15 @@ yylex ()
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: