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.
-
4:28:34
SOLTEKGG
4 hours agoLIVE (30+ KILL WORLD RECORD) - Battlefield 6
6.83K1 -
23:30
Lady Decade
20 hours ago $19.90 earnedYakuza Kiwami 3 is Causing Outrage !
34.1K10 -
1:33:48
CCoH
1 day ago $1.43 earnedWes Craven: The Mastermind Who Rewired Horror | Coffee Chat of Horrors
5.95K4 -
10:23
Forrest Galante
9 hours agoAsking an Indian Billionaire Why He Is Saving 1 Million Animals
74.3K19 -
LIVE
Lofi Girl
3 years agolofi hip hop radio 📚 - beats to relax/study to
164 watching -
6:14
PistonPop-TV
2 days ago $38.36 earnedThe VW 07K: The Indestructible Five-Cylinder with Lamborghini DNA
36.6K9 -
11:40
ThinkStory
23 hours agoFRANKENSTEIN Ending Explained!
31.7K7 -
33:05
ArturRehi
2 days ago1,000 Shahed Drones Explode at the same time in a BEHEMOTH FIREBALL in Donetsk
37.3K8 -
15:36
JohnXSantos
1 day ago $3.87 earnedHow To Design A Luxury Clothing Brand With A.I (From 0-$100+)
31.5K -
1:55:13
The Kevin Trudeau Show Limitless
4 days agoHow To Pray To Get Results!
33.5K13