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.
-
1:29:02
Game On!
1 day ago $6.26 earnedTHEY'RE BACK! NFL Wise Guys Return For Week 3 BEST BETS!
26.3K2 -
6:16
China Uncensored
1 hour agoHow Trump Plans on Stopping Russia and China—Without Firing a Shot!
3.7K6 -
33:13
Ohio State Football and Recruiting at Buckeye Huddle
13 hours agoOhio State Football: 10 Things We Learned Watching Washington's Win over Colorado State
2.25K -
1:14:04
NAG Entertainment
13 hours agoKickback w/ Leon - Rocket League: Road to GC
8.59K -
30:13
Degenerate Plays
1 hour agoBritish Insults Are Hilarious - Call of Duty: Modern Warfare 2 (2009) : Part 2
3.94K1 -
6:42
NAG Daily
17 hours agoCharlie Kirk: His Words. His Vision. His Movement.
29.6K26 -
21:42
Jasmin Laine
19 hours ago“Kimmel Isn’t a Victim, Charlie Kirk Was”—Gutfeld OBLITERATES Liberal Media Over FAKE Outrage
30.3K29 -
33:59
ComedyDynamics
23 days agoBest of Jim Breuer: Let's Clear the Air
77.2K20 -
2:11:03
Badlands Media
1 day agoDevolution Power Hour Ep. 391: First Principles, Psyops, and Hybrid Warfare
128K156 -
2:45:52
BlackDiamondGunsandGear
15 hours agoAfter Hours Armory / America After Charlie Kirk
90.7K21