# \[ruby-talk:444403\] \[ANN\] ruby\_parser 3.21.0 Released

**URL:** <https://rubytalk.org/t/ruby-talk-444403-ann-ruby-parser-3-21-0-released/76326>\
**Category:** ruby-talk\
**Created:** [16 January 2024 00:15 UTC](https://rubytalk.org/t/ruby-talk-444403-ann-ruby-parser-3-21-0-released/76326 "2024-01-16T00:15:20Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ryan\_Davis1](https://yyz1.discourse-cdn.com/flex029/user_avatar/rubytalk.org/ryan_davis1/32/1848_2.png) [@Ryan\_Davis1](https://rubytalk.org/u/Ryan_Davis1)\
**Post date:** [16 January 2024 00:15 UTC](https://rubytalk.org/t/ruby-talk-444403-ann-ruby-parser-3-21-0-released/76326/1 "2024-01-16T00:15:20Z")

</div>

ruby\_parser version 3.21.0 has been released!

\* home: \<[https://github.com/seattlerb/ruby\_parser&gt](https://github.com/seattlerb/ruby_parser&gt);  
\* bugs: \<[https://github.com/seattlerb/ruby\_parser/issues&gt](https://github.com/seattlerb/ruby_parser/issues&gt);  
\* rdoc: \<[http://docs.seattlerb.org/ruby\_parser&gt](http://docs.seattlerb.org/ruby_parser&gt);

ruby\_parser (RP) is a ruby parser written in pure ruby (utilizing  
racc--which does by default use a C extension). It outputs  
s-expressions which can be manipulated and converted back to ruby via  
the ruby2ruby gem.

As an example:

&nbsp;&nbsp;&nbsp;&nbsp;def conditional1 arg1  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return 1 if arg1 == 0  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return 0  
&nbsp;&nbsp;&nbsp;&nbsp;end

becomes:

&nbsp;&nbsp;&nbsp;&nbsp;s(:defn, :conditional1, s(:args, :arg1),  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;s(:if,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;s(:call, s(:lvar, :arg1), :==, s(:lit, 0)),  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;s(:return, s(:lit, 1)),  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nil),  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;s(:return, s(:lit, 0)))

Tested against 801,039 files from the latest of all rubygems (as of 2013-05):

\* 1.8 parser is at 99.9739% accuracy, 3.651 sigma  
\* 1.9 parser is at 99.9940% accuracy, 4.013 sigma  
\* 2.0 parser is at 99.9939% accuracy, 4.008 sigma  
\* 2.6 parser is at 99.9972% accuracy, 4.191 sigma  
\* 3.0 parser has a 100% parse rate.  
&nbsp;&nbsp;\* Tested against 2,672,412 unique ruby files across 167k gems.  
&nbsp;&nbsp;\* As do all the others now, basically.

Changes:

### 3.21.0 / 2024-01-15

\* 18 minor enhancements:

&nbsp;&nbsp;\* (internal) Added simple RubyLexer#comment.  
&nbsp;&nbsp;\* (internal) Removed RubyLexer#comments and #ignore\_body\_comments.  
&nbsp;&nbsp;\* (internal) Removed RubyParser#comments.  
&nbsp;&nbsp;\* (internal) Renamed files from lib/ruby##\_parser.\* to lib/ruby\_parser##.\*  
&nbsp;&nbsp;\* (internal) Renamed lib/ruby3\_parser.yy to lib/ruby\_parser3.yy  
&nbsp;&nbsp;\* (internal) Renamed lib/ruby\_parser.yy to lib/ruby\_parser2.yy  
&nbsp;&nbsp;\* Added tentative 3.2 support. (torrocus)  
&nbsp;&nbsp;\* Made `rake compare` a multitask (28s -\> 10s!!).  
&nbsp;&nbsp;\* Made `rake compare` depend on `generate` (from clean: 28s -\> 18s).  
&nbsp;&nbsp;\* No longer package versioned .y files.  
&nbsp;&nbsp;\* Overhaul of parser/lexer comment processing.  
&nbsp;&nbsp;\* Parser productions for k\_class/k\_module/k\_def carry their comment with them.  
&nbsp;&nbsp;\* Restructured build tasks to utilize Hoe's .yy support! 8.5s -\> 1.2s!!!  
&nbsp;&nbsp;\* RubyParser new\_(class|module|defn|defs) handle comment processing via sexp.  
&nbsp;&nbsp;\* RubyParser new\_(class|module|defn|defs) handle normalizing production sexps.  
&nbsp;&nbsp;\* RubyParser#next\_token clears out lexer's comment when applicable.  
&nbsp;&nbsp;\* Simplified parser productions for defn\_head, defs\_head. No more normalizing.  
&nbsp;&nbsp;\* Updated `rake compare` steps for lrama in ruby 3.3+.

\* 6 bug fixes:

&nbsp;&nbsp;\* Cleaned out cruft from `rake compare` code.  
&nbsp;&nbsp;\* Fixed compare/normalize.rb for lrama differences.  
&nbsp;&nbsp;\* Made `parser` task depend on `isolate` task to pick up racc generator.  
&nbsp;&nbsp;\* Made racc a runtime dependency (was dev only) now that ruby 3.3 doesn't ship with the racc runtime. (wildmaples)  
&nbsp;&nbsp;\* Updated README.rdoc updating instructions to match current filenames.  
&nbsp;&nbsp;\* Updated compare versions and added 3.3.

> **···**
>
> \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_  
> ruby-talk mailing list -- ruby-talk@ml.ruby-lang.org  
> To unsubscribe send an email to ruby-talk-leave@ml.ruby-lang.org  
> ruby-talk info -- [Info | ruby-talk@ml.ruby-lang.org - ml.ruby-lang.org](https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-talk.ml.ruby-lang.org/)
