Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 94 lines (68 sloc) 3.093 kb
512f595 @zenspider Fixed and improved the readme
zenspider authored
1 = ruby_parser
2
3e11dcd @zenspider Updated url section, switched to github for repo/home url, and cleaned u...
zenspider authored
3 home :: https://github.com/seattlerb/ruby_parser
9b345da @zenspider prepped for release
zenspider authored
4 bugs :: https://github.com/seattlerb/ruby_parser/issues
e1d634d @zenspider fixed url
zenspider authored
5 rdoc :: http://docs.seattlerb.org/ruby_parser
afc6228 @zenspider MOSTLY DONE... importing now so I can track.
zenspider authored
6
7 == DESCRIPTION:
2749468 @zenspider Removed ruby_parser.rb from manifest and worked into package rule instea...
zenspider authored
8
9 ruby_parser (RP) is a ruby parser written in pure ruby (utilizing
10 racc--which does by default use a C extension). RP's output is
11 the same as ParseTree's output: s-expressions using ruby's arrays and
12 base types.
afc6228 @zenspider MOSTLY DONE... importing now so I can track.
zenspider authored
13
512f595 @zenspider Fixed and improved the readme
zenspider authored
14 As an example:
15
a286817 @zenspider formatting and added accuracy stats
zenspider authored
16 def conditional1 arg1
17 return 1 if arg1 == 0
18 return 0
19 end
512f595 @zenspider Fixed and improved the readme
zenspider authored
20
21 becomes:
22
a286817 @zenspider formatting and added accuracy stats
zenspider authored
23 s(:defn, :conditional1, s(:args, :arg1),
24 s(:if,
25 s(:call, s(:lvar, :arg1), :==, s(:lit, 0)),
26 s(:return, s(:lit, 1)),
27 nil),
28 s(:return, s(:lit, 0)))
29
30 Tested against 801,039 files from the latest of all rubygems (as of 2013-05):
31
32 * 1.8 parser is at 99.9739% accuracy, 3.651 sigma
33 * 1.9 parser is at 99.9940% accuracy, 4.013 sigma
34 * 2.0 parser is at 99.9939% accuracy, 4.008 sigma
512f595 @zenspider Fixed and improved the readme
zenspider authored
35
afc6228 @zenspider MOSTLY DONE... importing now so I can track.
zenspider authored
36 == FEATURES/PROBLEMS:
2749468 @zenspider Removed ruby_parser.rb from manifest and worked into package rule instea...
zenspider authored
37
38 * Pure ruby, no compiles.
af96092 @zenspider Refactored several smallish areas.
zenspider authored
39 * Includes preceding comment data for defn/defs/class/module nodes!
2749468 @zenspider Removed ruby_parser.rb from manifest and worked into package rule instea...
zenspider authored
40 * Incredibly simple interface.
41 * Output is 100% equivalent to ParseTree.
42 * Can utilize PT's SexpProcessor and UnifiedRuby for language processing.
512f595 @zenspider Fixed and improved the readme
zenspider authored
43 * Known Issue: Speed is now pretty good, but can always improve:
44 * RP parses a corpus of 3702 files in 125s (avg 108 Kb/s)
45 * MRI+PT parsed the same in 67.38s (avg 200.89 Kb/s)
46 * Known Issue: Code is much better, but still has a long way to go.
2749468 @zenspider Removed ruby_parser.rb from manifest and worked into package rule instea...
zenspider authored
47 * Known Issue: Totally awesome.
512f595 @zenspider Fixed and improved the readme
zenspider authored
48 * Known Issue: line number values can be slightly off. Parsing LR sucks.
afc6228 @zenspider MOSTLY DONE... importing now so I can track.
zenspider authored
49
50 == SYNOPSIS:
51
90abb39 @zenspider - Updated Synopsis to reflect new options for running RP. (louismullie)
zenspider authored
52 RubyParser.new.parse "1+1"
53 # => s(:call, s(:lit, 1), :+, s(:lit, 1))
54
55 You can also use Ruby19Parser, Ruby18Parser, or RubyParser.for_current_ruby:
56
57 RubyParser.for_current_ruby.parse "1+1"
9b345da @zenspider prepped for release
zenspider authored
58 # => s(:call, s(:lit, 1), :+, s(:lit, 1))
afc6228 @zenspider MOSTLY DONE... importing now so I can track.
zenspider authored
59
60 == REQUIREMENTS:
61
2749468 @zenspider Removed ruby_parser.rb from manifest and worked into package rule instea...
zenspider authored
62 * ruby. woot.
9b345da @zenspider prepped for release
zenspider authored
63 * sexp_processor for Sexp and SexpProcessor classes, and testing.
512f595 @zenspider Fixed and improved the readme
zenspider authored
64 * racc full package for parser development (compiling .y to .rb).
afc6228 @zenspider MOSTLY DONE... importing now so I can track.
zenspider authored
65
66 == INSTALL:
67
2749468 @zenspider Removed ruby_parser.rb from manifest and worked into package rule instea...
zenspider authored
68 * sudo gem install ruby_parser
afc6228 @zenspider MOSTLY DONE... importing now so I can track.
zenspider authored
69
70 == LICENSE:
71
72 (The MIT License)
73
cf2703f @zenspider + Refactored and added new_resbody to ruby_parser_extras.
zenspider authored
74 Copyright (c) Ryan Davis, seattle.rb
afc6228 @zenspider MOSTLY DONE... importing now so I can track.
zenspider authored
75
76 Permission is hereby granted, free of charge, to any person obtaining
77 a copy of this software and associated documentation files (the
78 'Software'), to deal in the Software without restriction, including
79 without limitation the rights to use, copy, modify, merge, publish,
80 distribute, sublicense, and/or sell copies of the Software, and to
81 permit persons to whom the Software is furnished to do so, subject to
82 the following conditions:
83
84 The above copyright notice and this permission notice shall be
85 included in all copies or substantial portions of the Software.
86
87 THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
88 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
89 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
90 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
91 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
92 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
93 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Something went wrong with that request. Please try again.