Class: Dentaku::AST::Identifier

Inherits:
Node
  • Object
show all
Defined in:
lib/dentaku/ast/identifier.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Node

arity, precedence

Constructor Details

#initialize(token) ⇒ Identifier

Returns a new instance of Identifier.



8
9
10
# File 'lib/dentaku/ast/identifier.rb', line 8

def initialize(token)
  @identifier = token.value.downcase
end

Instance Attribute Details

#identifierObject (readonly)

Returns the value of attribute identifier.



6
7
8
# File 'lib/dentaku/ast/identifier.rb', line 6

def identifier
  @identifier
end

Instance Method Details

#dependencies(context = {}) ⇒ Object



25
26
27
# File 'lib/dentaku/ast/identifier.rb', line 25

def dependencies(context={})
  context.has_key?(identifier) ? dependencies_of(context[identifier]) : [identifier]
end

#value(context = {}) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/dentaku/ast/identifier.rb', line 12

def value(context={})
  v = context.fetch(identifier) do
    raise UnboundVariableError.new([identifier])
  end

  case v
  when Node
    v.value(context)
  else
    v
  end
end