Sha256: e84caa05955951afa1ce66f06c27292b64f7334fedc3d4a71c9b57800c04b94e

Contents?: true

Size: 609 Bytes

Versions: 1

Compression:

Stored size: 609 Bytes

Contents

module WLang
  class Dialect
    module Evaluation

      def scope
        @scope ||= Scope.root
      end

      def with_scope(x)
        @scope = scope.push(x)
        res    = yield
        @scope = scope.pop
        res
      end

      def evaluate(expr, *default)
        case expr
        when Symbol, String
          catch(:fail) do
            return scope.evaluate(expr, *default)
          end
          raise NameError, "Unable to find `#{expr}`"
        else
          evaluate(render(expr), *default)
        end
      end

    end # module Evaluation
  end # class Dialect
end # module WLang

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
wlang-2.0.0.beta lib/wlang/dialect/evaluation.rb