Method: Parser::Base.parse
- Defined in:
- lib/parser/base.rb
.parse(string, file = '(string)', line = 1) ⇒ Parser::AST::Node
Parses a string of Ruby code and returns the AST. If the source
cannot be parsed, SyntaxError is raised and a diagnostic is
printed to stderr.
33 34 35 36 37 |
# File 'lib/parser/base.rb', line 33 def self.parse(string, file='(string)', line=1) parser = default_parser source_buffer = setup_source_buffer(file, line, string, parser.default_encoding) parser.parse(source_buffer) end |