~/talk

Make Your Own Regex Engine!

Talkat RubyKaigi 2024 · 2024-05-15..05-17· [compilers-and-language-design]
links:none on file
slides:none on file

An actual regex engine gets built: a hand‑written parser (the longest part), a compiler (~60 lines) that emits a backtracking VM program, and a tiny VM implemented in about 21 lines that implements push/jump/char/match (full Ruby’s engine is ~2,000 lines). It shows capture via a caps array, char‑loop failure like aa?* causing infinite loops and the mitigation using push nil CHECK, and lookahead implemented by savepos/resetpos*. Ruby 3.3 later adds memoization optimizations.

AI-written summary · about

  1. 0:00Introduction
  2. 2:14Why build a regex engine
  3. 4:02Transpiling regex to Ruby
  4. 10:28Backtracking VM basics
  5. 14:14Compiling regex to VM
  6. 17:38Implementing capture groups
  7. 19:51Handling char loops
  8. 24:20Lookahead in regex
  9. 27:33Next steps and optimizations
  10. 29:10Conclusion and Q&A
~/search
type to search 8,222 conferences, 162,397 speakers and 219,688 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
← →
on a talk: 5 seconds back / forward
0–9
on a talk: jump to 0%–90% of the recording
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.