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.
-
LIVE
IsaiahLCarter
6 hours agoCharlie Kirk, American Martyr (with Mikale Olson) || APOSTATE RADIO 028
350 watching -
16:43
Mrgunsngear
9 hours ago $0.80 earnedKimber 2K11 Pro Review 🇺🇸
2.77K10 -
13:40
Michael Button
1 day ago $0.17 earnedThe Strangest Theory of Human Evolution
4488 -
10:19
Blackstone Griddles
1 day agoMahi-Mahi Fish Tacos on the Blackstone Griddle
8711 -
23:51
Jasmin Laine
1 day ago“Stop Wasting My Time!”—Trump's BRUTAL WARNING To Canada As Poilievre ROASTS CBC LIVE
1.74K17 -
9:54
Millionaire Mentor
1 day agoNBC Host EXPOSES JB Pritzker For Saying This About Trump
2174 -
1:35:39
SB Mowing
2 days agoIt took the WHOLE NEIGHBORHOOD to uncover this yards SHOCKING SECRET
73.3K60 -
12:52
ROSE UNPLUGGED
22 hours agoFrom Vision to Legacy: Charlie Kirk
45.8K19 -
1:14:22
Jeff Ahern
7 hours ago $10.58 earnedThe Sunday Show with Jeff Ahern
70.8K29 -
16:37
Professor Nez
7 hours ago🚨Internet MELTS DOWN over JD Vance & Trump BREAKING the Democrats!
64.8K184