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.
-
30:29
DeVory Darkins
1 day ago $4.42 earnedtroubling FBI report details the shooter left chilling note as more Democrats suffer humiliation
8.33K100 -
LIVE
FyrBorne
15 minutes ago🔴Fyr Takes On Borderlands 4 (First Impressions) #2KPartner #VaultNetwork
364 watching -
1:11:26
Coin Stories with Natalie Brunell
20 hours agoBRICS Nations Hold the Leverage (and Gold) and Why Bitcoin Price Isn’t Higher with Luke Gromen
29.4K2 -
1:50:29
Tucker Carlson
7 hours agoTucker Carlson LIVE: America After Charlie Kirk
352K312 -
2:12:05
FreshandFit
7 hours agoIf She Can Do Better She Will Leave You
38.9K12 -
2:14:00
Inverted World Live
9 hours agoLegion of Zoom | Ep. 109
207K12 -
2:42:57
TimcastIRL
10 hours agoDOJ Releases Charlie Kirk Assassin Messages, Trans Left Aligned Confirmed | Timcast IRL
356K220 -
1:09:13
Man in America
13 hours agoSICK: Xi & Putin Caught Plotting Organ Transplants for “Eternal Life”
92.9K34 -
6:04:35
Drew Hernandez
14 hours agoMASS CONFUSION AROUND CHARLIE'S MURDER
68K54 -
1:01:40
HotZone
6 days ago $14.06 earned"Prepare for WAR" - Confronting the URGENT Threat to America
91.1K29