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:10:46
Ellie_roe
5 hours agoEllie and Errys Halloween Spooktacular || Random Horror Games
16.2K -
50:27
Sarah Westall
7 hours agoBig Banks Caught Rigging Market, IMF tells World to “Buckle Up” w/ Andy Schectman
32.2K10 -
13:54
Degenerate Jay
14 hours ago $1.15 earned5 Best Superhero Movies To Watch On Halloween
15.6K4 -
59:03
NAG Podcast
7 hours agoSarah Fields: BOLDTALK W/Angela Belcamino
25.5K7 -
1:21:41
Glenn Greenwald
9 hours agoGlenn Takes Your Questions: On the Argentina Bailout, Money in Politics, and More; Plus: Journalist Jasper Nathaniel on Brutality and Settler Attacks in the West Bank | SYSTEM UPDATE #541
82.8K41 -
3:10:08
Barry Cunningham
7 hours agoPRESIDENT TRUMP TO USE NUCLEAR OPTION? FOOD STAMPS END! | SHUTDOWN DAY 31
49.4K34 -
1:06:56
BonginoReport
14 hours agoThe Battle Between Good & Evil w/ Demonologist Rick Hansen - Hayley Caronia (Ep.168)
100K38 -
1:12:57
Kim Iversen
9 hours agoBill Gates Suddenly Says “Don’t Worry About Climate Change”?
90.5K62 -
1:05:12
Michael Franzese
9 hours agoI Waited 50 Years to Tell You What Happened on Halloween 1975
45.4K17 -
1:07:15
Candace Show Podcast
9 hours agoINFILTRATION: Charlie Kirk Was Being Tracked For Years. | Candace Ep 256
93.6K372