News for hackers. Stuff that matters.
Re:Building a Regex Engine in Fewer Than 40 Lines of Code by ridiculous_fish on Tuesday December 05, 2017 @04:02AM (#15850663)
I've written a JS regexp parser and engine. It did not fit in 40 lines.

The most obnoxious part is backreferences. The atom \3 is a backreference if the whole regexp contains at least 3 capture groups; otherwise it is an octal (!) escape for char code 3. But you don't know how many capture groups there are until you're done parsing. This is why JS regexp parsers sometimes must make two passes!

Re:Building a Regex Engine in Fewer Than 40 Lines of Code by masklinn on Tuesday December 05, 2017 @04:34AM (#15850783)
FWIW back references mean you're way outside of "regular languages" so e.g. DFA usually don't support them.