Class: Parslet::Accelerator::Engine Private

Inherits:
Object
  • Object
show all
Defined in:
lib/parslet/accelerator/engine.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeEngine

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Engine.



79
80
81
# File 'lib/parslet/accelerator/engine.rb', line 79

def initialize 
  @bindings = {}
end

Instance Attribute Details

#bindingsObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



77
78
79
# File 'lib/parslet/accelerator/engine.rb', line 77

def bindings
  @bindings
end

Instance Method Details

#bind(var, val) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



108
109
110
# File 'lib/parslet/accelerator/engine.rb', line 108

def bind var, val
  @bindings[var] = val
end

#bound?(var) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


102
103
104
# File 'lib/parslet/accelerator/engine.rb', line 102

def bound? var
  @bindings.has_key? var
end

#lookup(var) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



105
106
107
# File 'lib/parslet/accelerator/engine.rb', line 105

def lookup var
  @bindings[var]
end

#match(atom, expr) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



83
84
85
86
# File 'lib/parslet/accelerator/engine.rb', line 83

def match(atom, expr)
  atom.accept(
    Apply.new(self, expr))
end

#try_bind(variable, value) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/parslet/accelerator/engine.rb', line 88

def try_bind(variable, value)
  if bound? variable
    return value == lookup(variable)
  else
    case variable
      when Symbol
        bind(variable, value)
    else
      # This does not look like a variable - let's try matching it against
      # the value: 
      variable === value
    end    
  end
end