@@ -1892,6 +1892,35 @@ class parser_base
1892
1892
return true ;
1893
1893
}
1894
1894
1895
+ [[nodiscard]] error_response do_return_from_raise (raise_frame const & frame, syntax const & sx, error_response rec_res)
1896
+ {
1897
+ error_response err_res{rec_res};
1898
+ error_context err{*environment_, sx, frame.label , err_res};
1899
+ auto handler_index = static_cast <std::size_t >(frame.eh );
1900
+ auto next_frame = stack_frames_.rbegin ();
1901
+ auto const last_frame = stack_frames_.rend ();
1902
+ while (handler_index < program_->handlers .size ()) {
1903
+ err_res = program_->handlers [handler_index](err);
1904
+ if (err_res != error_response::rethrow)
1905
+ break ;
1906
+ err_res = error_response::halt;
1907
+ handler_index = (std::numeric_limits<std::size_t >::max)();
1908
+ for (++next_frame; next_frame != last_frame; ++next_frame) {
1909
+ if (auto const * const next_report_frame = std::get_if<report_frame>(&*next_frame); next_report_frame != nullptr ) {
1910
+ handler_index = static_cast <std::size_t >(next_report_frame->eh );
1911
+ break ;
1912
+ }
1913
+ }
1914
+ }
1915
+ if (err_res >= error_response::backtrack) {
1916
+ registers_.sr = frame.sr ;
1917
+ registers_.rc = frame.rc ;
1918
+ return err_res;
1919
+ }
1920
+ registers_.pc = frame.pc ;
1921
+ return err_res;
1922
+ }
1923
+
1895
1924
void do_accept (std::string_view match)
1896
1925
{
1897
1926
detail::scope_exit const cleanup{[this , prior_call_depth = environment_->start_accept ()]{
@@ -2100,31 +2129,7 @@ class basic_parser : public parser_base
2100
2129
auto const mat = match ();
2101
2130
auto const sub = subject ();
2102
2131
environment_->set_match_and_subject (mat, sub);
2103
- error_response err_res{rec_res};
2104
- error_context err{*environment_, syntax{((sr0 < sr1) ? mat.substr (sr0, sr1 - sr0) : sub), sr0}, frame.label , err_res};
2105
- auto handler_index = static_cast <std::size_t >(frame.eh );
2106
- auto next_frame = stack_frames_.rbegin ();
2107
- auto const last_frame = stack_frames_.rend ();
2108
- while (handler_index < program_->handlers .size ()) {
2109
- err_res = program_->handlers [handler_index](err);
2110
- if (err_res != error_response::rethrow)
2111
- break ;
2112
- err_res = error_response::halt;
2113
- handler_index = (std::numeric_limits<std::size_t >::max)();
2114
- for (++next_frame; next_frame != last_frame; ++next_frame) {
2115
- if (auto const * const next_report_frame = std::get_if<report_frame>(&*next_frame); next_report_frame != nullptr ) {
2116
- handler_index = static_cast <std::size_t >(next_report_frame->eh );
2117
- break ;
2118
- }
2119
- }
2120
- }
2121
- if (err_res >= error_response::backtrack) {
2122
- registers_.sr = frame.sr ;
2123
- registers_.rc = frame.rc ;
2124
- return err_res;
2125
- }
2126
- registers_.pc = frame.pc ;
2127
- return err_res;
2132
+ return do_return_from_raise (frame, syntax{((sr0 < sr1) ? mat.substr (sr0, sr1 - sr0) : sub), sr0}, rec_res);
2128
2133
}
2129
2134
2130
2135
[[nodiscard]] std::pair<error_response, std::ptrdiff_t > return_from_call ()
@@ -2264,8 +2269,7 @@ class basic_parser : public parser_base
2264
2269
2265
2270
void accept_or_drain_if_deferred ()
2266
2271
{
2267
- if ((registers_.ci & lug::registers::count_mask) == 0 )
2268
- {
2272
+ if ((registers_.ci & lug::registers::count_mask) == 0 ) {
2269
2273
bool const should_cut = (registers_.ci & lug::registers::inhibited_flag) != 0 ;
2270
2274
bool const should_accept = (registers_.ci & lug::registers::ignore_errors_flag) != 0 ;
2271
2275
if (should_cut || should_accept) {
0 commit comments