From 8d4eab72bfdceb5dc74890431432e425acff902e Mon Sep 17 00:00:00 2001 From: Torsten Ruger Date: Mon, 4 Mar 2019 19:00:47 +0200 Subject: [PATCH] update parser to use 2.6 was choking on &. syntax improved error reporting slightly --- Gemfile.lock | 6 +++--- lib/ruby.rb | 2 +- lib/ruby/ruby_compiler.rb | 13 +++++++++++-- rubyx.gemspec | 2 +- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index e74cc65e..1d85c48c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -8,7 +8,7 @@ PATH remote: . specs: rubyx (0.6.0) - parser (~> 2.4.0) + parser (~> 2.6.0) rx-file (~> 0.3) GEM @@ -60,8 +60,8 @@ GEM notiffany (0.1.1) nenv (~> 0.1) shellany (~> 0.0) - parser (2.4.0.2) - ast (~> 2.3) + parser (2.6.0.0) + ast (~> 2.4.0) pry (0.11.3) coderay (~> 1.1.0) method_source (~> 0.9.0) diff --git a/lib/ruby.rb b/lib/ruby.rb index 737f765d..e9de51ba 100644 --- a/lib/ruby.rb +++ b/lib/ruby.rb @@ -1,4 +1,4 @@ -require "parser/ruby22" +require "parser/current" require "ast" AST::Node.class_eval do diff --git a/lib/ruby/ruby_compiler.rb b/lib/ruby/ruby_compiler.rb index 11f652dd..49f078aa 100644 --- a/lib/ruby/ruby_compiler.rb +++ b/lib/ruby/ruby_compiler.rb @@ -29,8 +29,17 @@ module Ruby include AST::Sexp def self.compile(input) - ast = Parser::Ruby22.parse( input ) - self.new.process(ast) + begin + ast = Parser::CurrentRuby.parse( input ) + rescue => e + puts "Error parsing #{input}" + end + begin + self.new.process(ast) + rescue => e + puts "Error processing #{ast}" + raise e + end end # raise a ProcessError. This means ruby-x doesn't know how to handle it. diff --git a/rubyx.gemspec b/rubyx.gemspec index e8213b13..5f167a1f 100644 --- a/rubyx.gemspec +++ b/rubyx.gemspec @@ -13,6 +13,6 @@ Gem::Specification.new do |s| s.require_paths = ['lib'] s.summary = 'RubyX is a native object vm without any c, one day possibly a ruby vm' - s.add_dependency "parser" , "~> 2.4.0" + s.add_dependency "parser" , "~> 2.6.0" s.add_dependency "rx-file" , "~> 0.3" end