Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Contributing to the Ruby Parser
Search
S.H.
May 16, 2024
Technology
2
960
Contributing to the Ruby Parser
In RubyKaigi 2024 Lightning Talks Slide
S.H.
May 16, 2024
Tweet
Share
More Decks by S.H.
See All by S.H.
ゆるゆるMastodon 鯖缶生活
gamelinks007
0
400
1週間で作るActivityPubリレーサーバ
gamelinks007
0
59
Rails 8で作るActivityPub リレーサーバ
gamelinks007
0
290
Developing an ActivityPub Relay with Rails 8
gamelinks007
0
23
Mastodon on Ruby master
gamelinks007
0
83
Trying to Make Ruby's Parser Available as a Gem
gamelinks007
1
280
ユーザーから見たLrama
gamelinks007
0
190
Other Decks in Technology
See All in Technology
RSNA2024振り返り
nanachi
0
580
Oracle Cloud Infrastructure:2025年2月度サービス・アップデート
oracle4engineer
PRO
1
210
インフラをつくるとはどういうことなのか、 あるいはPlatform Engineeringについて
nwiizo
5
2.6k
Classmethod AI Talks(CATs) #16 司会進行スライド(2025.02.12) / classmethod-ai-talks-aka-cats_moderator-slides_vol16_2025-02-12
shinyaa31
0
110
エンジニアの育成を支える爆速フィードバック文化
sansantech
PRO
3
1.1k
明日からできる!技術的負債の返済を加速するための実践ガイド~『ホットペッパービューティー』の事例をもとに~
recruitengineers
PRO
3
390
Tech Blogを書きやすい環境づくり
lycorptech_jp
PRO
1
240
抽象化をするということ - 具体と抽象の往復を身につける / Abstraction and concretization
soudai
16
3.6k
組織貢献をするフリーランスエンジニアという生き方
n_takehata
1
1.3k
なぜ私は自分が使わないサービスを作るのか? / Why would I create a service that I would not use?
aiandrox
0
730
オブザーバビリティの観点でみるAWS / AWS from observability perspective
ymotongpoo
8
1.5k
Data-centric AI入門第6章:Data-centric AIの実践例
x_ttyszk
1
400
Featured
See All Featured
Java REST API Framework Comparison - PWX 2021
mraible
28
8.4k
4 Signs Your Business is Dying
shpigford
182
22k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
251
21k
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
Building Flexible Design Systems
yeseniaperezcruz
328
38k
Speed Design
sergeychernyshev
27
790
The Art of Programming - Codeland 2020
erikaheidi
53
13k
Raft: Consensus for Rubyists
vanstee
137
6.8k
Building Better People: How to give real-time feedback that sticks.
wjessup
367
19k
Writing Fast Ruby
sferik
628
61k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
12
960
How GitHub (no longer) Works
holman
314
140k
Transcript
Contributing to the Ruby Parser S.H.
About Me • S.H. • Software engineer at ESM, Inc.
• Hamada.rb Organizer • I’m hosting Ruby Hacking Challenge in Hamada.rb
None
ruby/ruby contributors
ruby/ruby contributors I’m here!
parse.y contributors
parse.y contributors I’m here!
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
In RubyKaigi 2021 Takeout
In RubyKaigi 2021 Takeout • parse.y is difficult to maintain
◦ No one but nobu can maintain parse.y • parse.y seems hard to understand
Is parse.y really that hard to maintain?
I’m worried
I started to reading parse.y
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
What I read to study to parse.y • Ruby Under
the Microscope • Ruby Hacking Guide • ruby trunk changes
I’ve started to understand parse.y a bit
Difficulties I noticed while reading • Ruby Parser and Ripper
are interwind • The overall codebase is large
Difficulties I noticed while reading • Ruby Parser and Ripper
are interwind • The overall codebase is large It’s too hard
Difficulties I noticed while reading • Ruby Parser and Ripper
are interwind • The overall codebase is large May be able to do something here?
Let’s do it!
Action • Reusing BNF • Introducing some macros • Introducing
Ruby C API
Reusing BNF (1)
Reusing BNF (1)
Reusing BNF (2)
Reusing BNF (2)
Reusing BNF (3)
Reusing BNF (3)
Introducing macro (1)
Introducing macro (2)
Introducing Ruby C API
Results • Cut down codebase • Added dependencies by introducing
macros and Ruby C API
In RubyKaigi 2023
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
After RubyKaigi 2023
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
Why? • parse.y needs Ruby C API for generation of
literal objects • Will obtain a simpler AST ◦ e.g. Fixnum, Bignum, and Float…
Let’s do it!
Introducing new NODE (1)
Introducing new NODE (2)
Reducing C API dependencies (1)
Results • Obtained a simpler AST for some literal ◦
e.g. Numeric and __ENCODING__ • Reducing Ruby C API dependencies for Universal Parser
KPT Keep motivation Should more disscuss Share my experience Increase
Parser Contributor Keep Problem Try
parse.y is NOT Hell! We can hack parse.y!