diff options
-rw-r--r-- | lib/prism/translation/parser.rb | 108 |
1 files changed, 100 insertions, 8 deletions
@@ -9,11 +9,14 @@ module Prism # the parser gem, and overrides the parse* methods to parse with prism and # then translate. class Parser < ::Parser::Base # The parser gem has a list of diagnostics with a hard-coded set of error # messages. We create our own diagnostic class in order to set our own # error messages. - class Diagnostic < ::Parser::Diagnostic - # The message generated by prism. attr_reader :message # Initialize a new diagnostic with the given message and location. @@ -112,20 +115,109 @@ module Prism true end # If there was a error generated during the parse, then raise an # appropriate syntax error. Otherwise return the result. def unwrap(result, offset_cache) result.errors.each do |error| next unless valid_error?(error) - - location = build_range(error.location, offset_cache) - diagnostics.process(Diagnostic.new(error.message, :error, :prism_error, location)) end result.warnings.each do |warning| next unless valid_warning?(warning) - - location = build_range(warning.location, offset_cache) - diagnostics.process(Diagnostic.new(warning.message, :warning, :prism_warning, location)) end result |