Premium Only Content

Compiler From Scratch: Phase 1 - Tokenizer Generator 004: Regex Pattern to NFA
Streamed on 2024-08-09 (https://www.twitch.tv/thediscouragerofhesitancy)
Zero Dependencies Programming!
With some stolen code out of the way to store all of our state I can start the Pattern to NFA processing. This process involves stepping through a regex pattern one character at a time. Depending on the character we either add a "fragment" to our list of fragments, or we update some state, like "Are we inside square brackets?" or "Are we escaping the next character?".
Then we run through the list multiple times, once for each precedence of operator. If an operator at the current precedence level is found, we reduce the list by moving any neighboring elements to the proper relationship under the current operator. If everything parses correctly, we end up with one fragment at the end which contains the root state of our NFA. A decent amount of code was stolen from my old sandbox as there is a lot of detailed bookkeeping involved in these processes.
I then added the ability to log the NFA as a formatted table, as well as a tree. I think the table is easier to read and trace.
Then I started adding new features to my Regex to NFA converter, starting with non-greedy modifiers. The cardinality operators (+, *, and ?) can be made non-greedy by putting "?" after them. Strangely, this is a very simple change that just involves swapping the left and right out pointers for the given state. However, during this change I found a bug in my "+" implementation which I had to fix, and due to the time elapsed since I had last played in the sandbox, it took me longer than it should have. But in the end, I got it all working.
-
LIVE
GritsGG
2 hours agoWe Are Winning Every Game!!!! Most Wins 3040+! 🔥
92 watching -
1:57:28
Gary Cardone
2 days ago $1.22 earnedLIVE With Gary Cardone
10.6K3 -
8:01
MattMorseTV
20 hours ago $12.35 earnedTrump just DROPPED a BOMBSHELL.
85.1K86 -
LIVE
FyrBorne
12 hours ago🔴Warzone M&K Sniping: Is The Overlook OP or Bait?
306 watching -
2:00:53
MG Show
23 hours agoTrump Stops the Epstein Nonsense & Exposes FAKE MAGA; Victory Lap
106K98 -
39:21
MattGaetz
1 day agoThe Anchormen Show with Matt Gaetz | Feeding the Dragon
44.1K28 -
6:01
Michael Button
3 days ago $4.33 earnedMy History Degree Lied About Lost Civilizations
55.2K17 -
9:36
MattMorseTV
1 day ago $6.71 earnedThe EU just FOUND OUT.
40.6K52 -
22:39
Forrest Galante
1 day agoPrivate Tour of Australia's Craziest Zoo
175K15 -
6:57:31
ABNERDAGREAT
11 hours ago🔴DISCORD VC/MUSIC ZELDA BREATH OF THE WILD SWITCH 2 EDITION🔴
23.3K2