-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Currently, the only way to yield expectation failure is from normal parsers:
constexpr auto p = a > b;
constexpr auto p = a >> x4::expect[b];We need some facility to yield expectation failure in semantic action:
// proposed syntax
constexpr auto p = a >> b[([](auto&& ctx) {
return x4::unexpected("error message");
})];The current workaround is to just throw C++ exception:
constexpr auto p = a >> b[([](auto&& ctx) {
throw std::runtime_error("error message");
})];However this workaround has serious downsides:
- It defeats the purpose of expectation failure and essentially degrades your codebase into X3 era, where it suffered from C++ exception's overheads
- It yields "unreachable code" warning on compilers because all of the X4's internal code which comes after the
x4::actionhandling is correctly analyzed as "unreachable code" on very well optimized compilers
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request