{"id":13879148,"url":"https://github.com/seattlerb/ruby_parser","last_synced_at":"2025-04-10T02:13:33.488Z","repository":{"id":504197,"uuid":"131523","full_name":"seattlerb/ruby_parser","owner":"seattlerb","description":"ruby_parser is a ruby parser written in pure ruby. It outputs s-expressions which can be manipulated and converted back to ruby via the ruby2ruby gem.","archived":false,"fork":false,"pushed_at":"2024-12-29T10:31:53.000Z","size":2662,"stargazers_count":476,"open_issues_count":4,"forks_count":100,"subscribers_count":19,"default_branch":"master","last_synced_at":"2025-02-05T18:07:57.350Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://www.zenspider.com/projects/ruby_parser.html","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/seattlerb.png","metadata":{"files":{"readme":"README.rdoc","changelog":"History.rdoc","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2009-02-18T07:43:03.000Z","updated_at":"2025-01-27T18:07:05.000Z","dependencies_parsed_at":"2024-01-13T00:57:21.136Z","dependency_job_id":"fc23d090-3735-4d91-9dd9-dd20d968e02c","html_url":"https://github.com/seattlerb/ruby_parser","commit_stats":{"total_commits":857,"total_committers":2,"mean_commits":428.5,"dds":0.002333722287047868,"last_synced_commit":"718e13e172e089c4cc9dcde2bfe41a446cd8cedc"},"previous_names":[],"tags_count":76,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seattlerb%2Fruby_parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seattlerb%2Fruby_parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seattlerb%2Fruby_parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/seattlerb%2Fruby_parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/seattlerb","download_url":"https://codeload.github.com/seattlerb/ruby_parser/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237424351,"owners_count":19307876,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-06T08:02:11.279Z","updated_at":"2025-02-12T04:09:09.399Z","avatar_url":"https://github.com/seattlerb.png","language":"Ruby","funding_links":[],"categories":["Ruby","Ruby Parser / Unparser","Ruby ##"],"sub_categories":[],"readme":"= ruby_parser\n\nhome :: https://github.com/seattlerb/ruby_parser\nbugs :: https://github.com/seattlerb/ruby_parser/issues\nrdoc :: http://docs.seattlerb.org/ruby_parser\n\n== DESCRIPTION:\n\nruby_parser (RP) is a ruby parser written in pure ruby (utilizing\nracc--which does by default use a C extension). It outputs\ns-expressions which can be manipulated and converted back to ruby via\nthe ruby2ruby gem.\n\nAs an example:\n\n    def conditional1 arg1\n      return 1 if arg1 == 0\n      return 0\n    end\n\nbecomes:\n\n    s(:defn, :conditional1, s(:args, :arg1),\n      s(:if,\n        s(:call, s(:lvar, :arg1), :==, s(:lit, 0)),\n        s(:return, s(:lit, 1)),\n        nil),\n      s(:return, s(:lit, 0)))\n\nTested against 801,039 files from the latest of all rubygems (as of 2013-05):\n\n* 1.8 parser is at 99.9739% accuracy, 3.651 sigma\n* 1.9 parser is at 99.9940% accuracy, 4.013 sigma\n* 2.0 parser is at 99.9939% accuracy, 4.008 sigma\n* 2.6 parser is at 99.9972% accuracy, 4.191 sigma\n* 3.0 parser has a 100% parse rate.\n  * Tested against 2,672,412 unique ruby files across 167k gems.\n  * As do all the others now, basically.\n\n== FEATURES/PROBLEMS:\n\n* Pure ruby, no compiles.\n* Includes preceding comment data for defn/defs/class/module nodes!\n* Incredibly simple interface.\n* Output is 100% equivalent to ParseTree.\n  * Can utilize PT's SexpProcessor and UnifiedRuby for language processing.\n* Known Issue: Speed is now pretty good, but can always improve:\n  * RP parses a corpus of 3702 files in 125s (avg 108 Kb/s)\n  * MRI+PT parsed the same in 67.38s (avg 200.89 Kb/s)\n* Known Issue: Code is much better, but still has a long way to go.\n* Known Issue: Totally awesome.\n* Known Issue: line number values can be slightly off. Parsing LR sucks.\n\n== SYNOPSIS:\n\n  RubyParser.new.parse \"1+1\"\n  # =\u003e s(:call, s(:lit, 1), :+, s(:lit, 1))\n\nYou can also use Ruby19Parser, Ruby18Parser, or RubyParser.for_current_ruby:\n\n  RubyParser.for_current_ruby.parse \"1+1\"\n  # =\u003e s(:call, s(:lit, 1), :+, s(:lit, 1))\n\n== DEVELOPER NOTES:\n\nTo add a new version:\n\n* New parser should be generated from lib/ruby_parser[23].yy.\n* Extend lib/ruby_parser[23].yy with new class name.\n* Add new version number to V2/V3 in Rakefile for rule creation.\n* Add new `ruby_parse \"x.y.z\"` line to Rakefile for rake compare (line ~300).\n* Require generated parser in lib/ruby_parser.rb.\n* Add new V## = ::Ruby##Parser; end to ruby_parser.rb (bottom of file).\n* Add empty TestRubyParserShared##Plus module and TestRubyParserV## to test/test_ruby_parser.rb.\n* Extend Manifest.txt with generated file names.\n* Add new version number to sexp_processor's pt_testcase.rb in all_versions.\n\nUntil all of these are done, you won't have a clean test run.\n\n== REQUIREMENTS:\n\n* ruby. woot.\n* sexp_processor for Sexp and SexpProcessor classes, and testing.\n* racc full package for parser development (compiling .y to .rb).\n\n== INSTALL:\n\n* sudo gem install ruby_parser\n\n== LICENSE:\n\n(The MIT License)\n\nCopyright (c) Ryan Davis, seattle.rb\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseattlerb%2Fruby_parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fseattlerb%2Fruby_parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fseattlerb%2Fruby_parser/lists"}