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.
-
6:44:51
Dr Disrespect
8 hours ago🔴LIVE - DR DISRESPECT - IMPOSSIBLE 5 CHICKEN DINNER CHALLENGE - FEAT. VISS
91.2K15 -
LIVE
GloryJean
56 minutes agoDominating The Sniper Role 🖱️ 6.7 K/D | Duos w/ Spartakus
26 watching -
LIVE
BigTallRedneck
55 minutes agoBRRRAP PACK VS ANYBODY!!
77 watching -
1:09:21
TheCrucible
3 hours agoThe Extravaganza! Ep. 24 (8/20/25)
56K8 -
1:18:42
Kim Iversen
3 hours agoUFO Base Area 51 Catches Fire… Is It a Massive Cover-Up?!
29.5K49 -
1:51:18
Redacted News
4 hours ago"There will be consequences!!!" Trump issues big threat to Putin ahead of peace summit | Redacted
97.8K83 -
53:14
Candace Show Podcast
4 hours agoThe MOST MORAL Blackmail In The World | Candace EP 231
51.4K134 -
1:11:28
vivafrei
5 hours agoMatt Taibbi Getting "Westfalled"? Kathy Hochul Fighting for Illegals! Mamdani Minority Report & MORE
98.2K57 -
2:03:39
Pop Culture Crisis
5 hours agoWTF Happened to Miley Cyrus? HARRY POTTER Set Images, Sydney Sweeney Hater EXPOSED | Ep. 901
42.5K21 -
10:17
MattMorseTV
6 hours ago $6.96 earnedTrump's DOJ just DROPPED a NUKE.
47.9K44