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.
-
22:20
World2Briggs
18 hours ago $10.90 earnedEveryone Is Leaving These 15 States. Truth Behind the Trend.
22.1K13 -
4:24
Gamazda
19 hours ago $4.84 earnedDeep Purple – Smoke On the Water (Live Piano Cover in a Church)
12.9K13 -
12:54
Brad Owen Poker
13 hours ago $1.79 earnedI Make Final Table! I’m Going To $10,400 WPT World Championship!!
10.8K1 -
10:00
TheMightyMcClures
22 days ago $1.31 earnedWe Fed 500 Families!
12.3K4 -
6:23
The Shannon Joy Show
14 hours agoWas Covid a MILITARY OPERATION?
11.9K6 -
LIVE
The Bubba Army
22 hours agoTRUMP SIGNS EPSTEIN BILL! - Bubba the Love Sponge® Show | 11/20/25
1,713 watching -
27:24
DeVory Darkins
22 hours agoTrump secures RECORD BREAKING INVESTMENT as Charlotte Schools issue SHOCKING Update
38.5K48 -
34:15
ZeeeMedia
17 hours agoPolice Demand Government Critic Hands Over His BLOOD | Daily Pulse Ep 147
68.8K36 -
1:47:50
Side Scrollers Podcast
16 hours agoSide Scrollers Presents: OVERCOCKED
38.4K12 -
3:33:22
HLL8LLY
5 hours ago $1.47 earnedBattlefield 6 Live Gameplay
11.8K