Sha256: 2a833b53e7134c42ce85df4118ac0602e3b35cdbf1c277da58d78233c651a492
Contents?: true
Size: 937 Bytes
Versions: 2
Compression:
Stored size: 937 Bytes
Contents
# frozen_string_literal: true # @api public # @since 0.1.0 module LIT # @api public # @since 0.1.0 module Parser require_relative "parser/version" require_relative "parser/errors" require_relative "parser/ast" require_relative "parser/ast_builder" require_relative "../../ext/lit/parser/lit_parser" require "json" class << self def parse_file(path) source_code = File.read(path) result = JSON.parse(__parse_internal(source_code)) if result.fetch("type") == "parse_error" error_data = result.fetch("data") error_message = format_error(path, JSON.dump(error_data)) raise ParseError.new(data: error_data, message: error_message) else ASTBuilder.new(result.fetch("data")).build end end def format_error(file_path, error) __format_error_internal(file_path.to_s, error) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
litl-parser-0.1.1 | lib/lit/parser.rb |
litl-parser-0.1.0 | lib/lit/parser.rb |