This isn’t homework, I’m genuinely interested in compilers
I had read the brilliant articles by Russ Cox already, that’s actually how this started! I understood why the regexp engines in modern languages are so complex, since it’s due to the need to support complex features such as back-references.
The “Implementation” section of the article uses C for all code. Since it’s using lots of for loops and if statements,
it’s therefore difficult for me as an OCaml beginner to translate it into idiomatic OCaml code.
I think many of the points made by Russ Cox back in 2007 are still valid 2018. Not all regexp expressions makes use of all the complex features, so maybe there is a market for such a library like RE2, but implemented in pure OCaml.
I think a series of articles based on Russ Cox’s original one, but where OCaml instead of C is used as the language for the reference implementation, would be very interesting to a lot of people, who are looking at OCaml as a candidate language for their parser/compiler projects.