Class: PatternMatch::MatchingStateStack
Instance Attribute Summary collapse
-
#results ⇒ Object
Returns the value of attribute results.
-
#states ⇒ Object
Returns the value of attribute states.
Instance Method Summary collapse
-
#initialize(pat, tgt) ⇒ MatchingStateStack
constructor
A new instance of MatchingStateStack.
- #match ⇒ Object
- #process ⇒ Object
Constructor Details
#initialize(pat, tgt) ⇒ MatchingStateStack
Returns a new instance of MatchingStateStack.
23 24 25 26 |
# File 'lib/egison/core.rb', line 23 def initialize(pat, tgt) @states = [MatchingState.new(pat, tgt)] @results = [] end |
Instance Attribute Details
#results ⇒ Object
Returns the value of attribute results.
21 22 23 |
# File 'lib/egison/core.rb', line 21 def results @results end |
#states ⇒ Object
Returns the value of attribute states.
20 21 22 |
# File 'lib/egison/core.rb', line 20 def states @states end |
Instance Method Details
#match ⇒ Object
28 29 30 31 32 33 |
# File 'lib/egison/core.rb', line 28 def match until @states.empty? do process end @results end |
#process ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/egison/core.rb', line 35 def process state = @states.shift rets = state.process new_states = [] rets.each do |ret| if ret.atoms.empty? @results += [ret.bindings] else new_states += [ret] end end @states = new_states + @states end |