Class: PatternMatch::MatchingState

Inherits:
Object
  • Object
show all
Defined in:
lib/egison/core.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#atomsObject

Returns the value of attribute atoms.



51
52
53
# File 'lib/egison/core.rb', line 51

def atoms
  @atoms
end

#bindingsObject

Returns the value of attribute bindings.



51
52
53
# File 'lib/egison/core.rb', line 51

def bindings
  @bindings
end

Instance Method Details

#processObject



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