Module: JRubyParser
- Defined in:
- lib/jruby-parser.rb,
lib/jruby-parser/version.rb,
lib/jruby-parser/util/coercer.rb
Defined Under Namespace
Modules: Args, Receiver, Value
Constant Summary collapse
- Compat =
org.jrubyparser.CompatVersion
- VERSION =
"0.5.4"
Class Method Summary collapse
-
.parse(source_string, opts = {}) ⇒ Object
Parse source string and return a Abstract Syntax Tree (AST) of the source.
Class Method Details
.parse(source_string, opts = {}) ⇒ Object
Parse source string and return a Abstract Syntax Tree (AST) of the source. You may also pass in additional options to affect the reported filename and which version of Ruby you want to use:
Parameters
-
source_string source you want to parse
-
opts customize how your source is parsed (:filename, and :version [defaults to 1.9])
Example
JRubyParser.parse(%q“hello world”, :version => JRubyParser::Compat::RUBY1_8)
28 29 30 31 32 33 34 |
# File 'lib/jruby-parser.rb', line 28 def parse(source_string, opts={}) filename = opts[:filename] ? opts[:filename] : '(string)' version = opts[:version] ? opts[:version] : Compat::RUBY1_9 config = org.jrubyparser.parser.ParserConfiguration.new(0, version) reader = java.io.StringReader.new(source_string) org.jrubyparser.Parser.new.parse(filename, reader, config) end |