Class: Evilution::AST::Parser Private
- Inherits:
-
Object
- Object
- Evilution::AST::Parser
- Defined in:
- lib/evilution/ast/parser.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Method Summary collapse
- #call(file_path) ⇒ Object private
Instance Method Details
#call(file_path) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/evilution/ast/parser.rb', line 7 def call(file_path) raise Evilution::ParseError.new("file not found: #{file_path}", file: file_path) unless File.exist?(file_path) begin source = File.read(file_path) rescue SystemCallError => e raise Evilution::ParseError.new("cannot read #{file_path}: #{e.}", file: file_path) end result = Prism.parse(source) if result.failure? raise Evilution::ParseError.new("failed to parse #{file_path}: #{result.errors.map(&:message).join(", ")}", file: file_path) end extract_subjects(result.value, source, file_path) end |