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.
-
43:10
Donald Trump Jr.
4 hours agoThe Days of Destructive DEI are Over, Plus Full News Coverage! | TRIGGERED Ep.301
78.8K54 -
52:07
BonginoReport
3 hours agoThe Internet Picks Bongino’s FBI Replacement - Nightly Scroll w/ Hayley Caronia (Ep.200)
63.6K40 -
55:30
Russell Brand
5 hours agoStay Free LIVE from AmFest — Turning Point USA - SF665
104K11 -
1:11:26
Kim Iversen
6 hours agoTrump Pulls War Fake-Out…Attack on Venezuela Still Coming!?
65.5K85 -
2:04:53
Redacted News
4 hours agoPutin just changed EVERYTHING with this move and NATO can't do anything | Redacted w Clayton Morris
139K116 -
25:22
DeVory Darkins
4 hours agoTrump scores MAJOR WIN after Inflation Report as his speech sparks EPIC MELTDOWN
46K49 -
1:01:23
Nick Freitas
6 hours agoLIVE at America Fest!
62.9K3 -
1:11:19
vivafrei
6 hours agoCandace Owens' Backtracks? Brown University Cover-Up? Bongino Leaves! Pfizer Makes LEGAL ADMISSIONS?
143K76 -
56:22
The Nunn Report - w/ Dan Nunn
6 hours ago[Ep 813] LIVE from Rumble Set at AmFest 2025 | Guests Vem, Midnight, & Kevin Smith
51.8K4 -
29:58
Stephen Gardner
7 hours ago🔥IT'S BAD! NEW report just DROPPED!
56.4K39