I try to parse the string "1-2" using a grammar that is constructed with the following rules:
spirit::qi::rule<Iterator, spirit::utf8_symbol_type()> op1 = "-";
spirit::qi::rule<Iterator, spirit::utf8_symbol_type()> op2 = "+";
spirit::qi::rule<Iterator, spirit::utree(), spirit::qi::space_type> numberParser = boost::spirit::qi::double_;
spirit::qi::rule<Iterator, spirit::utree(), spirit::qi::space_type> expressionParser;
expressionParser = numberParser >> -( (op1 >> expressionParser) | (op2 >> expressionParser));
start = expressionParser.alias();
where start is a member of my grammar class:
spirit::qi::rule<Iterator, spirit::utree(), spirit::qi::space_type> start;
with the rules here, I want to create a node for each of the binary operations + and - from left to right.
When I now parse the string "1-2" using the following method:
void Parse(const std::string& testString, const CDynamicExpressionSyntaxParser<const char*>& parser)
{
char const* first = testString.c_str();
char const* last = &first[testString.size()];
boost::spirit::utree tree;
bool success = boost::spirit::qi::phrase_parse(first,last,parser, boost::spirit::qi::space,tree);
std::cout << "tree: " << tree << '\n';
}
I get an access violation in rule.hpp. What am I doing wrong?