Sha256: 42b9cac49d08ae20e3c8668590bdba20e75025515d587641e05090ac01c5b4a8

Contents?: true

Size: 559 Bytes

Versions: 4

Compression:

Stored size: 559 Bytes

Contents

require_relative '../exceptions'

module Dentaku
  module AST
    class Identifier < Node
      attr_reader :identifier

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

      def value(context={})
        v = context[identifier]
        case v
        when Node
          v.value
        when NilClass
          raise UnboundVariableError.new([identifier])
        else
          v
        end
      end

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
dentaku-2.0.3 lib/dentaku/ast/identifier.rb
dentaku-2.0.2 lib/dentaku/ast/identifier.rb
dentaku-2.0.1 lib/dentaku/ast/identifier.rb
dentaku-2.0.0 lib/dentaku/ast/identifier.rb