Sha256: 8d3e1159fb45b085ba71129d6e08b2a05ffa10a4de148fb0f090c8755f49b686
Contents?: true
Size: 1002 Bytes
Versions: 13
Compression:
Stored size: 1002 Bytes
Contents
# frozen_string_literal: true require 'parser' require 'parser/current' module Leftovers module Parser class << self # mostly copied from https://github.com/whitequark/parser/blob/master/lib/parser/base.rb # but with our parser def parse_with_comments(string, file = '(string)', line = 1) PARSER.reset source_buffer = ::Parser::CurrentRuby.send( :setup_source_buffer, file, line, string, PARSER.default_encoding ) PARSER.parse_with_comments(source_buffer) end private # mostly copied from https://github.com/whitequark/parser/blob/master/lib/parser/base.rb # but with our builder def parser p = ::Parser::CurrentRuby.new(Leftovers::AST::Builder.new) p.diagnostics.all_errors_are_fatal = true p.diagnostics.ignore_warnings = true p.diagnostics.consumer = lambda do |diagnostic| diagnostic end p end end PARSER = parser end end
Version data entries
13 entries across 13 versions & 1 rubygems