X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=blobdiff_plain;f=check%2Fparser_bugs.cpp;h=a83f668a4b620a7bcbbcb74ab75306aa4fd4127c;hp=340fe20fb2cc4da5b038172e0e5d8204e8bbb16c;hb=d4593e1981a168677f98e4d3b098696bd31088e2;hpb=05157f89a3db97fff79e33fd53156b380107011f diff --git a/check/parser_bugs.cpp b/check/parser_bugs.cpp index 340fe20f..a83f668a 100644 --- a/check/parser_bugs.cpp +++ b/check/parser_bugs.cpp @@ -41,6 +41,23 @@ static int check2(std::ostream& err_str) return 0; } +/// parse_literal_expr forget to consume the token, so parser get +/// very confused. +static int check3(std::ostream& err_str) +{ + const std::string srep("5-(2*I)/3"); + parser reader; + ex e = reader(srep); + ex g = numeric(5) - (numeric(2)*I)/3; + ex d = (e - g).expand(); + if (!d.is_zero()) { + err_str << "\"" << srep << "\" was misparsed as \"" + << e << "\"" << std::endl; + return 1; + } + return 0; +} + int main(int argc, char** argv) { std::cout << "checking for parser bugs. " << std::flush; @@ -48,6 +65,7 @@ int main(int argc, char** argv) int errors = 0; errors += check1(err_str); errors += check2(err_str); + errors += check3(err_str); if (errors) { std::cout << "Yes, unfortunately:" << std::endl; std::cout << err_str.str();