Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate YARP (aka Prism) #1213

Merged
merged 52 commits into from
Sep 22, 2023
Merged

Integrate YARP (aka Prism) #1213

merged 52 commits into from
Sep 22, 2023

Conversation

seven1m
Copy link
Member

@seven1m seven1m commented Sep 6, 2023

This will be my branch to integrate YARP instead of NatalieParser.

NatalieParser was born out of my frustration with the state of Ruby parsers and lack of a library that was free of a dependency on Ruby itself. Our humble parser project proved you can build a fast Ruby parser free of the tight coupling to MRI, but we didn't have the resources to make it fully correct. There are just a lot of edge cases with Ruby parsing I didn't have time to suss out.

YARP came along after and did everything I hoped NatalieParser could do, but with the backing of a major corporation and support from the Ruby community.

NatalieParser was quite a labor of love, and we learned a lot. I'd like to think it showed some in the Ruby community what was possible, and I have no regrets in building it.

Now it's time to be a little more practical for Natalie, given that there are so few of us on the project, and we don't want to make building a parser our full-time OSS job. 😄 (I will archive the NatalieParser project once YARP is fully working with Natalie.)

@seven1m seven1m self-assigned this Sep 6, 2023
@herwinw
Copy link
Member

herwinw commented Sep 7, 2023

Using upstream code? What's next, switching to std::string? 😉

@seven1m
Copy link
Member Author

seven1m commented Sep 7, 2023

Ha! Possibly! 😆

This works:

    $ rake

    $ bin/natalie --ast -e "p 1+2"
    s(:block, s(:block, s(:call, nil, :p, s(:call, s(:lit, 1), :+, s(:lit, 2)))))

    $ bin/natalie -e "p 1+2"
    3
I was trying to get test/natalie/method_test.rb parsing (and passing),
but I found a few unexpected results from YARP. I think these are bugs,
which I filed here:

ruby/prism#1435
ruby/prism#1436
I'd love to find a way to avoid these dependencies. These are just for
generating some sources for YARP, and are not used after that. I bet we
can pre-generate YARP sources and commit to our repo...
This returns a simpler node in a very specific case of "#{'str'}" which
gets one spec passing that relied on that.
We have to keep the sexp_type for symbol, regex, etc.
For now... once the test suite is passing, it would be good to come back
and remove this whole compatibility layer and have pass1.rb just consume
the YARP nodes directly. Baby steps. :-)
@seven1m
Copy link
Member Author

seven1m commented Sep 15, 2023

All the tests in test/natalie are parsing and passing on my local machine. Progress! 🎉

@seven1m
Copy link
Member Author

seven1m commented Sep 20, 2023

All existing specs passing!

Now I would like to start removing the translation layer and have pass1 consume the YARP nodes directly... [edit:] I think I've changed my mind, for now. Having the translation from YARP nodes to the Sexps is a nice barrier between our compiler and the ongoing changes that YARP is experiencing on a daily basis. Once things settle down with YARP, then we can start relying on those Nodes not changing too much.

@seven1m seven1m marked this pull request as ready for review September 22, 2023 01:51
@seven1m seven1m merged commit b4fe9dd into master Sep 22, 2023
10 checks passed
@seven1m seven1m deleted the yarp branch September 22, 2023 01:51
@@ -4,6 +4,7 @@ task default: :build

DEFAULT_BUILD_TYPE = 'debug'.freeze
SO_EXT = RUBY_PLATFORM =~ /darwin/ ? 'bundle' : 'so'
SO_EXT2 = RUBY_PLATFORM =~ /darwin/ ? 'dylib' : 'so'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI this is called DLEXT in RbConfig terms

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@seven1m seven1m changed the title Integrate YARP Integrate YARP (aka Prism) Feb 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants