Premium Only Content
Compiler From Scratch: Phase 1 - Tokenizer Generator 011: Dispatching DFAStates in multiple ways
Streamed on 2024-09-27 (https://www.twitch.tv/thediscouragerofhesitancy)
Zero Dependencies Programming!
Last time It mostly implemented dispatching our DFAStates in a switch/case statement. It almost worked, but was blocked by a strange segmentation fault. Over the weekend I debugged off stream, which I don't feel that bad about because it wasn't a problem with my code. It was a problem with the gcc compiler. With no other changes, I changed an std::vector to a simple array and it worked. I changed the simple array to std::list and it worked. Then just for fun I put it back to std::vector and ... it worked! I circled all the way back to where I started with no meaningful change and it works. That is the third time I've run into it where the compiler won't generated correct code unless a very particular line of code is removed or modified, but then it works fine after it is put right back in the same way. Very strange. With that bug "fixed" I was able to generate a sequence of tokens.
Therefore, today we implemented DFAState dispatching using an array of function pointers, and another where we used an array pointer directly. for both cases, I added another #define flag to create the function pointers by lambda and by std::bind. We now have almost 200 permutations of performance flags that we can play with when we get to performance testing. In all, the new dispatch methods went it pretty easy.
After that I updated the "macros" branch of code generation. There are small helper subprocesses that could be either methods or macros, so I generate both. With a few updates I was able to test that the macro helper subprocesses work as well. And all throughout I was making small refactors as I went.
Toward the end of stream, I started adding line tracking to TxtBuf. It more or less went in without a hitch ... except that I couldn't test it because something in the NFA to DFA transformation is broken. So I sidelined the line tracking in TxtBuf to examine the bug. Removing the "GROUP" concept from NFA helped clean up the code a bit, but didn't fix the issue. We'll have to pick up there next week.
-
LIVE
TheSaltyCracker
1 hour agoIt's Over Zelensky ReeEEStream 11-21-25
12,355 watching -
LIVE
SynthTrax & DJ Cheezus Livestreams
12 hours agoFriday Night Synthwave 80s 90s Electronica and more DJ MIX Livestream SYNTHWAVE / ANIME NIGHT
371 watching -
1:03:56
Glenn Greenwald
4 hours agoIs MAGA Divided? Revisiting the Major Controversies on the Right
76.7K27 -
33:09
Exploring With Nug
3 hours ago $1.35 earnedThey Weren’t Ready for Nightfall on Blood Mountain… So I Helped Them Down
4.46K -
LIVE
Sarah Westall
1 hour agoBoardroom and Government Infiltration: The Silent Erosion of American Power w/ Mike Harris
104 watching -
LIVE
Mally_Mouse
21 hours ago🎮 Let's Play!!: Stardew Valley pt. 33
199 watching -
LIVE
VapinGamers
50 minutes agoForlight 84/Fortnite: Rum Bot Testing - Gaming, Coding and Other Things - !rumbot !music
39 watching -
LIVE
OhHiMark1776
3 hours ago🟢 11-21-25 ||||| Two Morrows make a Day-to-Day? ||||| Livestream (2025)
60 watching -
9:57:30
GrimmHollywood
10 hours ago🔴LIVE • GRIMM HOLLYWOOD x SILVER FOX • GOLDEN YEARS • FINAL DAY • FLARE RACE • ARC RAIDERS •
1.4K -
1:11:24
The Daily Signal
4 hours ago $1.33 earned🚨BREAKING: Democrat Steals $5 Million from FEMA, Trump-Mamdani Meeting Gets Bizarre
3.7K1