lib/ruby2js.rb in ruby2js-3.0.15 vs lib/ruby2js.rb in ruby2js-3.1.0

- old
+ new

@@ -79,10 +79,22 @@ def es2017 @options[:eslevel] >= 2017 end + def es2018 + @options[:eslevel] >= 2018 + end + + def es2019 + @options[:eslevel] >= 2019 + end + + def es2020 + @options[:eslevel] >= 2020 + end + def process(node) ast, @ast = @ast, node replacement = super if replacement != node and @comments[node] @@ -199,10 +211,12 @@ def self.parse(source, file=nil, line=1) buffer = Parser::Source::Buffer.new(file, line) buffer.source = source.encode('utf-8') parser = Parser::CurrentRuby.new parser.builder.emit_file_line_as_literals=false - parser.parse_with_comments(buffer) + ast, comments = parser.parse_with_comments(buffer) + Parser::CurrentRuby.parse(source.encode('utf-8')) unless ast + [ast, comments] rescue Parser::SyntaxError => e split = source[0..e.diagnostic.location.begin_pos].split("\n") line, col = split.length, split.last.length message = "line #{line}, column #{col}: #{e.diagnostic.message}" message += "\n in file #{file}" if file