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.
-
LIVE
Lofi Girl
3 years agolofi hip hop radio 📚 - beats to relax/study to
234 watching -
21:37
Forrest Galante
1 day ago6 Deadly Sea Monsters That Actually Exist
145K10 -
23:24
Stephen Gardner
12 hours agoYou WON'T Believe What Happened To Lindsey Graham
68.5K49 -
8:05:17
SpartakusLIVE
10 hours agoSolos on ARC: UNBANNED
253K10 -
30:29
Robbi On The Record
10 hours ago $10.76 earnedWhales Are Selling. Banks Are Nervous. Bitcoin analysis ft Simply Bitcoin Tv
20.9K9 -
2:28:12
vivafrei
18 hours agoEp. 291: More Epstein Documents! Stacey Plaskett SCANDAL! Butler Cover-Up, Tucker Smea & MORE!
215K266 -
6:06:22
xLuigi34x
10 hours ago100 Follower Special! Going to 100% The DKC Trilogy on stream!
53.7K8 -
50:27
Sarah Westall
8 hours agoMusk Helps Expose the Most Consequential Political Blackmail Operation in Modern British History
38.4K22 -
4:52:47
Due Dissidence
16 hours agoTrump GOES NUCLEAR on MTG, Tucker Exposes Butler COVERUP, Shmuley SUED For HILARIOUS Reason
53.7K29 -
20:13
RealReaper
11 hours ago $5.69 earnedPredator Badlands: If You Like This Movie Then I Hate You
37.5K20