class Parslet::Accelerator::Engine

@api private

Attributes

bindings[R]

Public Class Methods

new() click to toggle source
# File lib/parslet/accelerator/engine.rb, line 79
def initialize 
  @bindings = {}
end

Public Instance Methods

bind(var, val) click to toggle source
# File lib/parslet/accelerator/engine.rb, line 108
def bind var, val
  @bindings[var] = val
end
bound?(var) click to toggle source
# File lib/parslet/accelerator/engine.rb, line 102
def bound? var
  @bindings.has_key? var
end
lookup(var) click to toggle source
# File lib/parslet/accelerator/engine.rb, line 105
def lookup var
  @bindings[var]
end
match(atom, expr) click to toggle source
# File lib/parslet/accelerator/engine.rb, line 83
def match(atom, expr)
  atom.accept(
    Apply.new(self, expr))
end
try_bind(variable, value) click to toggle source
# 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