require 'ruby2ruby'
require 'parsetree'
code = "puts(var)"
sexp = SexpProcessor.new.process(ParseTree.translate(code))
# => s(:fcall, :puts, s(:array, s(:vcall, :var)))
code = Ruby2Ruby.new.process(sexp)
# => UnknownNodeError: Bug! Unknown node-type :fcall to Ruby2Ruby
Is there some way to translate Sexps from ParseTree back to ruby code?
I started writing some code that would do this translation but I want to know if that already exists. Another problem is the Ruby2Ruby puts a lot of unneeded parentheses in arithmetic operations (like 4+3-2+-2**4
to (((4 + 3) - 2) + -(2 ** 4))
, both working equivalently). Is there some way to remove them?