]> www.ginac.de Git - ginac.git/blobdiff - ginac/ex.cpp
- the ex stream >> operator is gone
[ginac.git] / ginac / ex.cpp
index 4eb3d15d32210f2142533a6f558daa85bcadb5e4..d53cb9585b94b22a3d82257a13fdee58e5d33b41 100644 (file)
@@ -21,6 +21,7 @@
  */
 
 #include <iostream>
+#include <stdexcept>
 
 #include "ex.h"
 #include "add.h"
@@ -29,6 +30,7 @@
 #include "numeric.h"
 #include "power.h"
 #include "relational.h"
+#include "input_lexer.h"
 #include "debugmsg.h"
 #include "utils.h"
 
@@ -133,6 +135,12 @@ ex::ex(double const d)
     construct_from_double(d);
 }
 
+ex::ex(const string &s, const ex &l)
+{
+    debugmsg("ex constructor from string,lst",LOGLEVEL_CONSTRUCT);
+    construct_from_string_and_lst(s, l);
+}
+
 #endif // ndef INLINE_EX_CONSTRUCTORS
 
 //////////
@@ -623,6 +631,21 @@ void ex::construct_from_double(double d)
     GINAC_ASSERT((bp->flags) & status_flags::dynallocated);
     GINAC_ASSERT(bp->refcount=1);
 }
+
+void ex::construct_from_string_and_lst(const string &s, const ex &l)
+{
+    set_lexer_string(s);
+    set_lexer_symbols(l);
+    ginac_yyrestart(NULL);
+    if (ginac_yyparse())
+        throw (std::runtime_error(get_parser_error()));
+    else {
+        bp = parsed_ex.bp;
+        GINAC_ASSERT(bp!=0);
+        GINAC_ASSERT((bp->flags) & status_flags::dynallocated);
+        ++bp->refcount;
+    }
+}
     
 //////////
 // static member variables