]> www.ginac.de Git - ginac.git/blobdiff - ginac/input_parser.yy
input_parser accepts also pow() [A.Sheplyakov]
[ginac.git] / ginac / input_parser.yy
index c4f69c26d39aeb7c13121242d4a23c59de7ce938..74beb4c54f44464ff78ccfd97f726186b384269f 100644 (file)
@@ -4,7 +4,7 @@
  *  This file must be processed with yacc/bison. */
 
 /*
- *  GiNaC Copyright (C) 1999-2003 Johannes Gutenberg University Mainz, Germany
+ *  GiNaC Copyright (C) 1999-2007 Johannes Gutenberg University Mainz, Germany
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -18,7 +18,7 @@
  *
  *  You should have received a copy of the GNU General Public License
  *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
 
 %{
 #include <stdexcept>
 
-#include "input_lexer.h"
 #include "ex.h"
+#include "input_lexer.h"
 #include "relational.h"
+#include "operators.h"
 #include "symbol.h"
 #include "lst.h"
 #include "power.h"
@@ -104,6 +105,10 @@ exp        : T_NUMBER              {$$ = $1;}
                        if ($3.nops() != 1)
                                throw (std::runtime_error("too many arguments to sqrt()"));
                        $$ = sqrt($3.op(0));
+               } else if (n == "pow" || n == "power") {
+                 if ($3.nops() != 2) 
+                         throw std::invalid_argument("wrong number of arguments to pow()");
+                       $$ = power($3.op(0), $3.op(0));
                } else {
                        unsigned i = function::find_function(n, $3.nops());
                        $$ = function(i, ex_to<exprseq>($3)).eval(1);