github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

adamsanderson / sexp_path

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 39
    • 1
  • Source
  • Commits
  • Network (1)
  • Issues (1)
  • Downloads (0)
  • Wiki (1)
  • Graphs
  • Tree: b7ee04f

click here to add a description

click here to add a homepage

  • Branches (2)
    • master
    • ruby_specific
  • Tags (0)
Sending Request…
Enable Donations

Pledgie Donations

Once activated, we'll place the following badge in your repository's detail box:
Pledgie_example
This service is courtesy of Pledgie.

Structural pattern matching for S-Expressions — Read more

  cancel

http://endofline.wordpress.com

  cancel
  • Private
  • Read-Only
  • HTTP Read-Only

This URL has Read+Write access

Commenting a bit on sexp_grep example. 
adamsanderson (author)
Mon Jun 22 18:59:52 -0700 2009
commit  b7ee04fb74dc25652bf691c224fa6dc1aa3c9f4f
tree    d04fbbff8bfc94170c37b3bbe2ab35e56921d364
parent  480291e50495752b9e65cd63c5fa75829d116fdb
sexp_path / examples / print_methods.rb examples/print_methods.rb
100644 28 lines (22 sloc) 0.67 kb
edit raw blame history
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
require 'rubygems'
require File.dirname(__FILE__) + '/../lib/sexp_path'
require 'parse_tree'
 
path = ARGV.shift
if !path
  puts "Prints classes and methods in a file"
  puts "usage:"
  puts " ruby print_methods.rb <path>"
  exit
end
 
code = File.read(path)
sexp = Sexp.from_array(ParseTree.new.parse_tree_for_string(code, path))
 
class_query = Q?{ s(:class, atom % 'class_name', _, _) }
method_query = Q?{ s(:defn, atom % 'method_name', _ ) }
 
results = sexp / class_query / method_query
 
puts path
puts "-" * 80
 
results.each do |sexp_result|
  class_name = sexp_result['class_name']
  method_name = sexp_result['method_name']
  puts "#{class_name}##{method_name}"
end
Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
© 2010 GitHub Inc. All rights reserved. | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server