1 /// @file parser_a_b.cpp Check for some silly bugs in the parser.
9 // - a - b was misparsed as -a + b due to a bug in parser::parse_unary_expr()
10 static int check1(std::ostream& err_str)
12 const std::string srep("-a-b");
15 ex a = reader.get_syms()["a"];
16 ex b = reader.get_syms()["b"];
18 ex d = (e - g).expand();
20 err_str << "\"" << srep << "\" was misparsed as \""
21 << e << "\"" << std::endl;
27 /// Parser was rejecting the valid expression '5 - (3*x)/10'.
28 static int check2(std::ostream& err_str)
30 const std::string srep("5-(3*x)/10");
33 ex x = reader.get_syms()["x"];
35 ex d = (e - g).expand();
37 err_str << "\"" << srep << "\" was misparsed as \""
38 << e << "\"" << std::endl;
44 int main(int argc, char** argv)
46 std::cout << "checking for parser bugs. " << std::flush;
47 std::ostringstream err_str;
49 errors += check1(err_str);
50 errors += check2(err_str);
52 std::cout << "Yes, unfortunately:" << std::endl;
53 std::cout << err_str.str();
55 std::cout << "Not found. ";