ruby / racc

Racc is an LALR(1) parser generator. It is written in Ruby itself, and generates ruby programs.
Other
535 stars 88 forks source link

Documentation: How to use the pure Ruby version of racc #272

Open mohamedhafez opened 1 month ago

mohamedhafez commented 1 month ago

It says in https://railsatscale.com/2023-08-29-ruby-outperforms-c/

An interesting feature of Racc is that it actually ships with a pure Ruby implementation of the parser runtime.

But I don't see documentation about how to choose to use the pure ruby variant of racc instead of the c-extension version, could that be added somewhere?

headius commented 1 month ago

It looks like this currently falls back to the pure-Ruby version only if the extension (JRuby or CRuby) does not load:

https://github.com/ruby/racc/blob/2c5a142f03ecde2044767d8d51eb05547777881f/lib/racc/parser.rb#L189-L214

I think we would need some additional code to allow users to opt into the pure-Ruby version or opt out of loading the extensions.