A micro compiler in Ocaml
troydm.github.io
troydm.github.io
The most visited of these pages is 99 problems: http://ocaml.org/learn/tutorials/99problems.html
Oof, talk about cutting corners. Works well enough until you need function calls, I guess.
Anybody who finds this intriguing might look at http://esumii.github.io/min-caml/index-e.html, which is also written in OCaml and goes into a bit more depth.
let is_digit c = let code = Char.code c in code >= Char.code('0') && code <= Char.code('9')
Could have been written: let is_digit = function '0'..'9' -> true | _ -> false
So the purpose probably wasn't to teach OCaml.
Do those not count? What are the tradeoffs to doing it from scratch?
Using tools is often more complicated than just writing code, it isn't that hard to write a recursive descent parser, and you have the flexibility if loading it with all the error recovery you want. What tools give you is potentially better parser performance and more theoretic assurances (useful for tricky grammars).