make grammar to not throw on expectation failure

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

make grammar to not throw on expectation failure

Orient
This post has NOT been accepted by the mailing list yet.
How can I make grammar to just return false, when parsed by x3::phrase_parse, instead of throwing the x3::expectation_failure exception? The grammar definitely should contain '>' expectation parser at that place where it already is, but in case of expectation failure I just want to simply finish the parsing overall, instead of checking another alternative of the same level or something similar what parser '>>' do. And I want to do it without involving any exceptions.

BTW embracing x3::phrase_parse into
try {
  if (x3::phrase_parse(...)) { 
    ... 
  } 
} catch (x3::expectation_failure< input_iterator_type > const & ef) { 
  ... 
}
  does nothing. In debugger I catch SIGABRT when running in debug mode above code (without break points). The place, where debugger stopped is line
throw enable_current_exception(enable_error_info(e));
in <boost/throw_exception.hpp> file. Previous entry in call stack is body of if (!r) { ... } in  boost/spirit/home/x3/directive/expect.hpp:expect_directive::parse function. Why program cannot unwind stack till the above catch? Is it my own local problem or is it the common issue?