Module: Mulang::Ruby::SexpParser

Defined in:
lib/mulang/ruby/sexp_parser.rb

Class Method Summary collapse

Class Method Details

.parser(ruby_code, parser_class) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/mulang/ruby/sexp_parser.rb', line 6

def self.parser(ruby_code, parser_class)
  parser = parser_class.new
  parser.diagnostics.consumer = lambda {|it|}
  parser.diagnostics.all_errors_are_fatal = true
  buffer = Parser::Source::Buffer.new('(string)')
  buffer.source = ruby_code
  parser.parse(buffer).tap do |result|
    raise "Syntax error" if result.eql? false
  end
end