Class: PatternMatch::MatchingStateStream
Instance Method Summary collapse
-
#initialize(pat, tgt) ⇒ MatchingStateStream
constructor
A new instance of MatchingStateStream.
- #match(&block) ⇒ Object
- #process(process_iter, &block) ⇒ Object
Constructor Details
#initialize(pat, tgt) ⇒ MatchingStateStream
Returns a new instance of MatchingStateStream.
51 52 53 54 |
# File 'lib/egison/core.rb', line 51 def initialize(pat, tgt) @state = MatchingState.new(pat, tgt) @processes = [] end |
Instance Method Details
#match(&block) ⇒ Object
56 57 58 59 60 61 |
# File 'lib/egison/core.rb', line 56 def match(&block) @processes << Egison::LazyArray.new(@state.process_stream) until @processes.empty? process(@processes.shift, &block) end end |
#process(process_iter, &block) ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/egison/core.rb', line 63 def process(process_iter, &block) unless process_iter.empty? ret = process_iter.shift if ret.atoms.empty? block.(ret.bindings) else @processes << Egison::LazyArray.new(ret.process_stream) end @processes << process_iter end end |