Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Contributing to the Ruby Parser

S.H.
May 16, 2024

Contributing to the Ruby Parser

In RubyKaigi 2024 Lightning Talks Slide

S.H.

May 16, 2024
Tweet

More Decks by S.H.

Other Decks in Technology

Transcript

  1. About Me • S.H. • Software engineer at ESM, Inc.

    • Hamada.rb Organizer • I’m hosting Ruby Hacking Challenge in Hamada.rb
  2. Today Topic is… • Why I got interested in the

    Ruby Parser • How I started contributing to the Ruby Parser • How I started contributing to the Universal Parser
  3. In RubyKaigi 2021 Takeout • parse.y is difficult to maintain

    ◦ No one but nobu can maintain parse.y • parse.y seems hard to understand
  4. My first impression of parse.y • The codebase is large

    • It’s hard to figure out what to begin reading • I have a no clue about BNF
  5. What I read to study to parse.y • Ruby Under

    the Microscope • Ruby Hacking Guide • ruby trunk changes
  6. Difficulties I noticed while reading • Ruby Parser and Ripper

    are interwind • The overall codebase is large
  7. Difficulties I noticed while reading • Ruby Parser and Ripper

    are interwind • The overall codebase is large It’s too hard
  8. Difficulties I noticed while reading • Ruby Parser and Ripper

    are interwind • The overall codebase is large May be able to do something here?
  9. In RubyKaigi 2023 • I feel the future of the

    Ruby Parser in “The Future of the Ruby Parser” at spikeolaf • I realized that added macros and Ruby C API are make dependencies for Universal Parser
  10. After RubyKaigi 2023 • I read “Started parse.y Refactoring Challenge”

    ◦ https://yui-knk.hatenablog.com/entry/202 3/06/18/162100 • It was written want to remove the generation of literal objects in parse.y
  11. Why? • parse.y needs Ruby C API for generation of

    literal objects • Will obtain a simpler AST ◦ e.g. Fixnum, Bignum, and Float…
  12. Results • Obtained a simpler AST for some literal ◦

    e.g. Numeric and __ENCODING__ • Reducing Ruby C API dependencies for Universal Parser