]> www.ginac.de Git - ginac.git/blobdiff - ginac/input_parser.yy
* Include the operators.h header file in the source files, not in ex.h.
[ginac.git] / ginac / input_parser.yy
index bbc07647e80d5459f634c9890a2b336d2799e43a..778b8347da3c88a239b8c83a4a4fa4a123ba2e18 100644 (file)
@@ -4,7 +4,7 @@
  *  This file must be processed with yacc/bison. */
 
 /*
- *  GiNaC Copyright (C) 1999-2001 Johannes Gutenberg University Mainz, Germany
+ *  GiNaC Copyright (C) 1999-2002 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
@@ -32,6 +32,7 @@
 #include "input_lexer.h"
 #include "ex.h"
 #include "relational.h"
+#include "operators.h"
 #include "symbol.h"
 #include "lst.h"
 #include "power.h"
@@ -94,8 +95,15 @@ exp  : T_NUMBER              {$$ = $1;}
        | T_LITERAL             {$$ = $1;}
        | T_DIGITS              {$$ = $1;}
        | T_SYMBOL '(' exprseq ')' {
-               unsigned i = function::find_function(ex_to<symbol>($1).get_name(), $3.nops());
-               $$ = function(i, ex_to<exprseq>($3)).eval(1);
+               std::string n = ex_to<symbol>($1).get_name();
+               if (n == "sqrt") {
+                       if ($3.nops() != 1)
+                               throw (std::runtime_error("too many arguments to sqrt()"));
+                       $$ = sqrt($3.op(0));
+               } else {
+                       unsigned i = function::find_function(n, $3.nops());
+                       $$ = function(i, ex_to<exprseq>($3)).eval(1);
+               }
        }
        | exp T_EQUAL exp       {$$ = $1 == $3;}
        | exp T_NOTEQ exp       {$$ = $1 != $3;}