Premium Only Content

Compiler From Scratch: Phase 1 - Tokenizer Generator 014: Regex code gen/testing, starting lazy eval
Streamed on 2024-10-18 (https://www.twitch.tv/thediscouragerofhesitancy)
Zero Dependencies Programming!
Last week we had debugged the NFA/DFA not picking up the "ANY" operator correctly and fixed it up through the DFA. I didn't like the way it printed out in the DFA table or DFA graphviz plot, so I fixed that first thing. That was followed up with a small refactor of function names left over from last week's output improvements. Just a couple of small, easy tasks to get warmed up.
After that it was time to do code generation for the ANY operator, which was easier than expected. It was basically putting "true" inside the if condition. A little debugging around the Regex for strings and it was good to go. After that I generated code for the StartOfLine and EndOfLine anchors. The main effort was two functions added to the ChrRef, then that function was called from the tokenizer. Since the anchor operators don't consume a character there was a bit of fiddling to suppress the "munch" function call in these cases. Just a bit more finagling around detecting the end of input and all was well.
I tested a couple of possible error cases with the new processing in place. One turned out to be fine, the other caused a crash as expected (unterminated string at the end of input). This was noted in the TODO for future attention.
And finally it was time to start building out the lazy tokenizer processing. There were a few opportunities to refactor/cleanup other code as we went through this exercise. The high-level methods for doing the lazy processing are put together well enough to compile, but there are still changes needed to get the whole thing working end-to-end, mostly in the helper functions. We'll pick up there next week.
-
1:05:13
Russell Brand
4 hours agoReporting From Tommy Robinson’s ‘Unite the Kingdom’ March - SF634
115K56 -
LIVE
Rallied
2 hours ago $0.10 earnedWarzone Challenges All Night
80 watching -
55:05
Committee on House Administration
1 day agoSubcommittee on Elections Hearing:“Maintaining Election Operations in the Face of Natural Disasters”
16.1K -
5:56
Buddy Brown
4 hours ago $3.44 earnedThis is Why Everyone's Googling September 23rd! | Buddy Brown
28.5K20 -
58:33
Human Events Daily with Jack Posobiec
2 hours agoBreaking: Utah Prosecutors Announce Charges Against Charlie Kirk Assassin
33.1K1 -
3:21
Michael Heaver
3 hours agoGermany’s Seismic Result Serves WARNING
21.4K4 -
1:02:14
SGT Report
18 hours agoGOD'S ORDER VS. SATAN'S CHAOS -- Dr. Henry Ealy
36.7K38 -
2:03:13
The Charlie Kirk Show
4 hours agoMichael Knowles, Matt Walsh, and Ben Shapiro Remember Charlie Kirk | 9.16.2025
444K453 -
2:11:49
Steven Crowder
7 hours agoThe Lies are Sick: Charlie Kirk's Legacy Separating Fact from Fiction
596K507 -
1:22:10
Sean Unpaved
4 hours agoMNF Mayhem: Bucs' Stunner, Brady's Booth Drama, Shedeur's Draft Doge & the Masters on Prime
38.6K2