Method: ParsingMachine#handle_run_time_capture_result
- Defined in:
- lib/rpeg/parsing_machine.rb
#handle_run_time_capture_result(results) ⇒ Object
From the ICloseRuntIme main-loop switch statement in lpvm.c
372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 |
# File 'lib/rpeg/parsing_machine.rb', line 372 def handle_run_time_capture_result(results) directive, *dyn_captures = results unless directive handle_fail_ptr return end @subject_index = if directive == true @subject_index else directive.must_be_a(Integer) if directive < @subject_index || directive > @subject_size raise 'invalid position returned by match-time capture' end directive end if dyn_captures.empty? # no dynamic captures. Just get rid of the OPEN capture we still have @bread_count -= 1 else # This is LPEG's adddyncaptures in lpvm.c @breadcrumbs[@bread_count - 1].data = nil # make the group capture an anonymous group dyn_captures.each do |cap_val| # LPEG uses a special RUNTIME capture kind here to help find these things later if they need to be removed. We don't appear # to need it - we could just use a CONST capture. But let's follow LPEG just in case. add_capture Capture::Breadcrumb.new(1, @subject_index, cap_val, Capture::RUNTIME) end add_capture Capture::Breadcrumb.new(1, @subject_index, nil, Capture::CLOSE) # close the group end @i_ptr += 1 end |