sith
sith is a macro preprocessor for Ruby
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
however, the macros in sith
are defined using a ruby-like template notation, not a lisp-like ast notation.