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.
-
18:23
Producer Michael
20 hours agoWHAT REALLY HAPPENED IN DUBAI!
38.6K5 -
6:32
Blackstone Griddles
14 hours agoCajun Smashburgers with Bruce Mitchell | Blackstone Griddles
9.9K9 -
43:16
The Finance Hub
17 hours ago $2.83 earnedBREAKING: DONALD TRUMP JUST SHOCKED THE WORLD!
13.6K11 -
2:00:57
BEK TV
1 day agoTrent Loos in the Morning - 9/03/2025
9.44K -
LIVE
The Bubba Army
23 hours agoNick Hogan Sues Bubba to BLOCK the DOC - Bubba the Love Sponge® Show | 9/03/25
1,847 watching -
8:01
MattMorseTV
14 hours ago $11.87 earnedHe's ACTUALLY doing it...
82.5K81 -
33:25
Uncommon Sense In Current Times
17 hours ago $3.66 earnedHollywood’s Woke Agenda Exposed | Kevin Sorbo on Cancel Culture, Faith & the Common Sense Revolution
32.5K3 -
8:23
The Art of Improvement
22 hours ago $1.76 earned7 Smart Habits to Boost Mental Clarity
16.3K4 -
12:09
China Uncensored
13 hours agoI Have NEVER Been More Furious
16.9K21 -
2:12
WildCreatures
4 days ago $1.44 earnedThe beauty and mystery of the Pantanal, Brazil's best secret
15.7K3