Sha256: 3c2a027850502c59da1bb2e4871aee27de8386153638b6efb03702a312b2455c

Contents?: true

Size: 733 Bytes

Versions: 5

Compression:

Stored size: 733 Bytes

Contents

module Alf
  module Algebra
    class Rewriter
      include Visitor

    # public interface

      def call(expr, search = nil)
        apply(expr)
      end

    # copy all default implementation

      def apply(expr, *args, &bl)
        send to_method_name(expr, "on_"), expr, *args, &bl
      end

      def on_leaf_operand(expr, *args, &bl)
        expr
      end

      def on_shortcut(expr, *args, &bl)
        apply(expr.expand, *args, &bl)
      end

      def on_missing(expr, *args, &bl)
        copy_and_apply(expr, *args, &bl)
      end

      def not_supported(expr, *args, &bl)
        raise NotSupportedError, "Unexpected operand `#{expr}`"
      end

    end # class Rewriter
  end # module Algebra
end # module Alf

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
alf-core-0.16.3 lib/alf/algebra/support/rewriter.rb
alf-core-0.16.2 lib/alf/algebra/support/rewriter.rb
alf-core-0.16.1 lib/alf/algebra/support/rewriter.rb
alf-core-0.16.0 lib/alf/algebra/support/rewriter.rb
alf-core-0.15.0 lib/alf/algebra/support/rewriter.rb