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:24
Tundra Tactical
2 hours agoWhats New With HRT Tactical Gear at SHOT Show 2025
1.86K -
LIVE
LFA TV
1 day agoMankind Refuses the Way of Peace | TRUMPET DAILY 1.27.25 7pm
656 watching -
LIVE
2 MIKES LIVE
5 hours ago2 MIKES LIVE #171 Deep Dive Monday!
233 watching -
LIVE
The Big Mig™
2 hours agoOperation Gideon, The Truth w/ Ret. Green Beret Jordan Goudreau
3,264 watching -
24:23
The Based Mother
3 hours agoGIRL, PLEASE! Selena Gomez gets destroyed for her sloppy crying fit over illegal aliens.
2.52K5 -
43:30
Stephen Gardner
4 hours ago🔥"MILLIONS WILL BE HURT" BECAUSE OF THIS | Gerald Celente
20.6K47 -
47:54
Kimberly Guilfoyle
4 hours agoTrump Doctrine in Full Force, Live with Bo French and Tony Kinnett | Ep.191
36K13 -
1:53:03
Redacted News
4 hours agoNATO Warmongers Trying to SCREW Trump's Peace Plans in Ukraine by Sending 100K Troops Front Lines?
110K226 -
1:19:42
Candace Show Podcast
4 hours agoSelena Gomez Cries & More Ryan Reynolds' Lies | Candace Ep 139
94K148 -
1:54:23
Revenge of the Cis
5 hours agoEpisode 1435: Mexican Sad Dance
41K11