Class: Parslet::Accelerator::Engine Private
- Inherits:
-
Object
- Object
- Parslet::Accelerator::Engine
- 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
- #bindings ⇒ Object readonly private
Instance Method Summary collapse
- #bind(var, val) ⇒ Object private
- #bound?(var) ⇒ Boolean private
-
#initialize ⇒ Engine
constructor
private
A new instance of Engine.
- #lookup(var) ⇒ Object private
- #match(atom, expr) ⇒ Object private
- #try_bind(variable, value) ⇒ Object private
Constructor Details
#initialize ⇒ Engine
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
#bindings ⇒ Object (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.
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 |