Add an option to use Prism parser#2642
Conversation
|
There's a small issue for opalopal as of now which regards loading of WASM modules - they can be only loaded async (at least in Chromium). I have a plan to support such workflow, but it will take some time. Other than that, before we flip the default, we will also have to check regressions in source maps. |
Thanks to recent improvement of Prism, we no longer need workaround code
|
So what's the current status of using Prism parser in Opal? |
|
@davispuh This PR is mostly about experimenting with Prism to work under MRI. And it mostly works. We have a long term goal to migrate from whitequark/parser to prism, but there are multiple issues as of now:
|
|
My bad, I didn't know it had gotten so big. I've lowered its size now ruby/prism#3824 and it could probably get quite a bit smaller if I'm honest. How big is the built whitequark/parser? I can aim to be smaller than that. |
|
@davispuh Is https://github.com/kateinoigakukun/irb.wasm what you're looking for? That's kind of orthogonal to this PR, which is more about supporting eval. |
|
@kddnewton I think you managed it :). I have tried to isolate Opal-compiled parser (with no other parts of Opal, ie. compiler): The second number is what we should compare against, since most of the time we want to ship Opal-generated code minified. |
|
Oh yeah nice, we're now < half that size. |
|
Is that including the support code for serialization? |
|
Yes! I just added the flags for ignoring the other optional features like JSON support/pack support/etc. |
Ruby 3.3 introduced Prism parser, and it is also released as a gem.
The latest version of Prism includes
Prism::Tarnslaion::Parser, a wrapper class to make Prism compatible with parser gem (whitequark/parser).This PR tries to replace the current parser (
Parser::Ruby32) withPrism::Tranlation::Parser.Since this is just an experiment, the default parser remains to be that of parser gem. Instead I added
--prismCLI option to switch the parser.Here are some advantages with Prism:
Todo:
cc: @kddnewton