Premium Only Content
Compiler From Scratch: Phase 1 - Tokenizer Generator 022: Resolving DFA state ambiguity
Streamed on 2024-12-13 (https://www.twitch.tv/thediscouragerofhesitancy)
Zero Dependencies Programming!
Last week we got stuck by the fact that DFAs can have overlapping transitions. In these cases the first test always wins and there is no way to jump off an invalid track onto another valid track once it starts down a track. So we fixed that today.
The trick is to think of each transition as a set of characters; a set in the mathematical sense. When processing the transitions we look for overlapping sets. If they overlap we compute:
1) Which characters are only in the first set
2) Which characters are only in the second set
3) Which characters are in both sets, and treat that as a new transition that follows the lowest rule number (rule order precedence).
Then add each of these three onto the unprocessed list for further checking. Once a transition makes it all the way through the unprocessed list without overlapping any other sets, this transition if put on the processed list. This process also has the added benefit of making the order we check the transitions in not matter at all. We can shuffle the transitions into any order, and since they don't overlap any more, they will all be checked eventually and not get cut off by an overlapping rule. Now the DFA looks much messier, but it is finally correct.
With that change done the testing of VVProject tokenizer proceeded. It didn't take much fiddling to get it the way we want. We had already done most of the plumbing into VVProject last week and with a bit of tweaking it was working just fine there as well.
I started down the road of making a tokenizer for the VVTokenizerDefinition, but got sidetracked thinking about multiple-encodings support in that tokenizer. I started down a dark road trying to make that work, but where VVProject calls VVTokenizerDefinition was where I found the problem: for the "Multi" encoding to work it would have to know the encoding when we generate the tokenizer itself. We can't switch that encoding behavior at tokenizer runtime with this system, only at tokenizer generation time. And the biggest problems is the REGEX tokenizing rule. That will have to support anything at tokenization time. I have a plan, but ran out of time by the time I had thought it through. We'll have to remove some of the work we did today, but that will have to wait for next week.
-
1:48:48
MattMorseTV
4 hours ago $28.34 earned🔴Sedition Charges INBOUND.🔴WH Press Conference.🔴
36.9K107 -
9:06
Jamesons Travels
19 hours ago $1.89 earnedMilitary Veterans in Congress Tell Troops to Refuse Trump's Orders
6.67K28 -
LIVE
The Bold Lib
1 hour agoBOLDCHAT: Unemployment | AI | Birth Rates w/ANGELA BELCAMINO
56 watching -
20:34
ArynneWexler
6 hours agoNew Poll: Women Are Done With America | NN8
3.75K15 -
59:30
The White House
4 hours agoPress Secretary Karoline Leavitt Briefs Members of the Media, Nov. 20, 2025
38.2K27 -
2:06:37
Steven Crowder
6 hours agoJasmine Crockett's Epstein Idiocy & the Absolute State of the Democrat Party
513K342 -
33:37
The Boomer Effect
17 hours agoBeyond Convenience: The Tyranny Behind Digital IDs
8.22K1 -
1:15:39
Sean Unpaved
4 hours agoAre Josh Allen & Bills On UPSET ALERT vs. Texans? | UNPAVED
30.3K -
2:06:44
Side Scrollers Podcast
5 hours agoRoblox Kids TRANS Game + Pokimane ROASTED AGAIN + More | Side Scrollers
38.5K9 -
2:05:47
The Charlie Kirk Show
4 hours agoTP Action Update + Mogadishu Minnesota + Replacing ObamaCare | Bowyer, Thorpe, Cremieux | 11.20.2025
67.5K19