X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?a=blobdiff_plain;ds=sidebyside;f=ginac%2Fex.cpp;h=d53cb9585b94b22a3d82257a13fdee58e5d33b41;hb=61e847cdfd8455a7ba67a0038add8dd35b4e0bff;hp=4eb3d15d32210f2142533a6f558daa85bcadb5e4;hpb=f6f99c4d47762da9e3d73a2f5ec6f062e82505b8;p=ginac.git diff --git a/ginac/ex.cpp b/ginac/ex.cpp index 4eb3d15d..d53cb958 100644 --- a/ginac/ex.cpp +++ b/ginac/ex.cpp @@ -21,6 +21,7 @@ */ #include +#include #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