Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
require 'rjb'
Rjb::load(classpath = 'jrubyparser-0.2.jar', jvmargs=[])
module ToSource
SR = Rjb::import('java.io.StringReader')
PC = Rjb::import('org.jrubyparser.parser.ParserConfiguration')
P = Rjb::import('org.jrubyparser.Parser')
RWV = Rjb::import('org.jrubyparser.rewriter.ReWriteVisitor')
SW = Rjb::import('java.io.StringWriter')
end
class String
def to_ast
ToSource::P.new.parse('(string)', ToSource::SR.new(self), ToSource::PC.new)
end
end
class Rjb::Rjb_JavaProxy
def to_s
toString
end
end
''.to_ast.class.class_eval do
def to_source
sw = ToSource::SW.new
rwv = ToSource::RWV.new(sw, '(string)')
accept(rwv)
sw.toString
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.