mode, _, rest = OpenURI.scan_open_optional_arguments(*rest) options = rest.shift if !rest.empty? && Hash === rest.first match(OpenURI.scan_open_optional_arguments(*rest)) do with(_[mode, _, _[options & Hash]]) do end end
p = Patm r.on [:x, p._1, p._2] do|m| [m._1, m._2] end end end A.new.match1([:x, 1, 2]) match_all([1, 2, 3]) do with(List.(*_hs, _x, *_ts)) do [hs, x, ts] end end
callccศར class Pattern module Backtrackable def match(vals) matched = super if root? and not matched and not choice_points.empty? restore_choice_point end matched end def repeating_match(vals, is_greedy) super do |vs, rest| cont = nil if callcc {|c| cont = c; yield vs, rest } save_choice_point(cont) true else false end end end end ... prepend Backtrackable end