a macro preprocessor for ruby with ruby-like template notation
Ruby
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
bin
examples
lib
spec
.travis.yml
Gemfile
LICENSE
README.md
Rakefile
sith.gemspec

README.md

sith

sith is a macro preprocessor for Ruby

Build Status

Still a prototype.

Example:

a macro definitions file:

macro_mapper attr_reader(label)
  def ~{label}
  	@~{label}
  end
end

macro_mapper attr_writer(label)
  def ~{label}=(value)
  	@~{label} = value
  end
end

macro attr_accessor(*labels)
  attr_reader ~{labels}
  attr_writer ~{labels}
end

a ruby file

class A
  attr_accessor a, z
end
sith ruby_file.rb macro_definitions.rb > output.rb`

output.rb

class A
  def a
    @a
  end
  def z
    @z
  end
  def a=(value)
    @a = value
  end
  def z=(value)
    @z = value
  end
end

install

gem install sith

thanks

built on top of parser and unparser gems.

similar to

rubymacros

however, the macros in sith are defined using a ruby-like template notation, not a lisp-like ast notation.

built by

Alexander Ivanov