Class: MapRewriter

Inherits:
SexpProcessor
  • Object
show all
Defined in:
lib/bud/rewrite.rb

Overview

We want to rewrite “map” calls on BudCollections to “pro” calls. It is hard to do this precisely (issue #225), so we just replace map calls liberally and define Enumerable#pro as an alias for “map”.

Instance Method Summary collapse

Constructor Details

#initializeMapRewriter

Returns a new instance of MapRewriter.



296
297
298
299
300
# File 'lib/bud/rewrite.rb', line 296

def initialize
  super
  self.require_empty = false
  self.expected = Sexp
end

Instance Method Details

#process_call(exp) ⇒ Object



302
303
304
305
306
307
308
309
310
# File 'lib/bud/rewrite.rb', line 302

def process_call(exp)
  tag, recv, op, *args = exp

  if op == :map and args.empty?
    op = :pro
  end

  s(tag, process(recv), op, *(args.map{|a| process(a)}))
end