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.
-
3:38:49
Badlands Media
1 day agoThe Narrative Ep. 38: The Sovereign World
113K60 -
2:57:44
The Charlie Kirk Show
13 hours agoWASHINGTON D.C. PRAYER VIGIL FOR CHARLIE KIRK
251K452 -
14:11
Robbi On The Record
14 hours agoThe Trap of Identity Politics: How Division is Killing America
26.5K53 -
1:29:23
Nerdrotic
14 hours ago $20.86 earnedThe Turning Point | New UFO Video with Michael Collins | Forbidden Frontier #117
87.5K29 -
1:08:26
Sarah Westall
11 hours agoSuicide Pacts forming in Youth Social Media Groups - Discord, Reddit, TikTok w/ John Anthony
83.3K29 -
2:25:31
vivafrei
22 hours agoEp. 281: Charlie Kirk; Routh Trial; Charlotte Train; Bolsanaro Defense; SCOTUS & MORE!
163K245 -
2:55:38
Turning Point USA
13 hours agoWASHINGTON D.C. PRAYER VIGIL FOR CHARLIE KIRK
110K44 -
35:54
The Mel K Show
13 hours agoMel K & Tim James | Healing is an Inside Job | 9-14-25
81.1K4 -
3:06:33
IsaiahLCarter
16 hours ago $17.51 earnedCharlie Kirk, American Martyr (with Mikale Olson) || APOSTATE RADIO 028
90.5K30 -
16:43
Mrgunsngear
19 hours ago $13.96 earnedKimber 2K11 Pro Review 🇺🇸
65.3K15