examples/sexp_grep.rb in sexp_path-0.4.0 vs examples/sexp_grep.rb in sexp_path-0.5.0

- old
+ new

@@ -1,8 +1,8 @@ require 'rubygems' require File.dirname(__FILE__) + '/../lib/sexp_path' -require 'parse_tree' +require 'ruby_parser' # Example program, this will scan a file for anything # matching the Sexp passed in. @@ -12,11 +12,11 @@ if paths.empty? || !pattern puts "Prints classes and methods in a file" puts "usage:" puts " ruby sexp_grep.rb <pattern> <path>" puts "example:" - puts " ruby sexp_grep.rb t(:defn) *.rb" + puts " ruby sexp_grep.rb 't(:defn)' *.rb" exit end begin # Generate the pattern, we use a little instance_eval trickery here. @@ -29,11 +29,11 @@ exit 1 end # For each path the user defined, search for the SexpPath pattern paths.each do |path| - # Parse it with ParseTree, and append line numbers - sexp = sexp = LineNumberingProcessor.process_file(path) + # Parse it with RubyParser, and append line numbers + sexp = RubyParser.new.parse(File.read(path), path) found = false # Search it with the given pattern, printing any results sexp.search_each(pattern) do |match| if !found \ No newline at end of file