3 ms·
Having never heard of mojo before, I found this article fascinating. It provides a great example of how a toy regex parser works and an excellent explanation of
by spectraldrift 11mo ago
Having never heard of mojo before, I found this article fascinating. It provides a great example of how a toy regex parser works and an excellent explanation of why vanilla regex tends to be slow. It also presents a novel solution: compiling the regex into regular code, which can then be optimized by the compiler.
- convolvatron 11mo agothis is literally how 'lex' works. the one written in 1987 by Vern Paxson.
- jlokier 11mo agoThe original is 'lex', written in 1975 by Mike Lesk and Eric Schmidt. Yes, that Eric Schmidt, CEO of Google. 1987 was the clone, 'flex' :-) It did "compiling the regex into regular code, which can then be optimized by the compiler" before the C programming language as we know it was created. I think 'lex' was compiling regex to C before the C language even had 'struct' types, 'printf' or 'malloc'.
- spectraldrift 11mo agoSo I'm only 40 years behind! It's amazing how early innovations like this seamlessly fade into the background and can be taken for granted by folks like myself.