Sha256: efc5cf5ab23c8f2fd3da92ffce4e30f11100bc5d777bd6a6a8cb8926cae20226
Contents?: true
Size: 846 Bytes
Versions: 7
Compression:
Stored size: 846 Bytes
Contents
require 'astrolabe/builder' require 'parser/current' module SlimLint # Parser for the Ruby language. # # This provides a convenient wrapper around the `parser` gem and the # `astrolabe` integration to go with it. It is intended to be used for linter # checks that require deep inspection of Ruby code. class RubyParser # Creates a reusable parser. def initialize @builder = ::Astrolabe::Builder.new @parser = ::Parser::CurrentRuby.new(@builder) end # Parse the given Ruby source into an abstract syntax tree. # # @param source [String] Ruby source code # @return [Array] syntax tree in the form returned by Parser gem def parse(source) buffer = ::Parser::Source::Buffer.new('(string)') buffer.source = source @parser.reset @parser.parse(buffer) end end end
Version data entries
7 entries across 7 versions & 1 rubygems