X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=blobdiff_plain;f=ginac%2Foperators.cpp;h=6cf750cefa7005542175ee6d46f2178a18a34787;hp=9a681b5ea2e2e68f263e40caad0c3956af4cc476;hb=956a3ad3779759028bfd742456ed9eafc3e85063;hpb=79eebbd4ebb7b5f7c6517298c728a16a68282ace diff --git a/ginac/operators.cpp b/ginac/operators.cpp index 9a681b5e..6cf750ce 100644 --- a/ginac/operators.cpp +++ b/ginac/operators.cpp @@ -29,6 +29,7 @@ #include "numeric.h" #include "power.h" #include "relational.h" +#include "input_lexer.h" #include "debugmsg.h" #include "utils.h" @@ -335,9 +336,21 @@ ostream & operator<<(ostream & os, const ex & e) return os; } +/** Input (parse) expression from stream. The input grammar is similar to the + * GiNaC output format. If 'e' contains a list of symbols upon entry, these + * symbols are used in the parsed expression in all places where symbols with + * the same names appear. All other encountered symbols will be newly created. */ istream & operator>>(istream & is, ex & e) { - throw(std::logic_error("input from streams not yet implemented")); + string s; + getline(is, s); + set_lexer_string(s); + set_lexer_symbols(e); + ginac_yyrestart(NULL); + if (yyparse()) + throw (std::runtime_error(get_parser_error())); + else + e = parsed_ex; } #ifndef NO_NAMESPACE_GINAC