Class: PatternMatch::MatchingState
Instance Attribute Summary collapse
-
#atoms ⇒ Object
Returns the value of attribute atoms.
-
#bindings ⇒ Object
Returns the value of attribute bindings.
Instance Method Summary collapse
-
#initialize(pat, tgt) ⇒ MatchingState
constructor
A new instance of MatchingState.
- #process ⇒ Object
Constructor Details
#initialize(pat, tgt) ⇒ MatchingState
53 54 55 56 |
# File 'lib/egison/core.rb', line 53 def initialize(pat, tgt) @atoms = [[pat, tgt]] @bindings = [] end |
Instance Attribute Details
#atoms ⇒ Object
Returns the value of attribute atoms.
51 52 53 |
# File 'lib/egison/core.rb', line 51 def atoms @atoms end |
#bindings ⇒ Object
Returns the value of attribute bindings.
51 52 53 |
# File 'lib/egison/core.rb', line 51 def bindings @bindings end |
Instance Method Details
#process ⇒ Object
58 59 60 61 62 63 64 65 66 67 |
# File 'lib/egison/core.rb', line 58 def process atom = @atoms.shift rets = atom.first.match(atom.last, @bindings) rets.map { |new_atoms, new_bindings| new_state = self.clone new_state.atoms = new_atoms + new_state.atoms new_state.bindings = new_state.bindings + new_bindings new_state } end |