top | item 7505819

A micro compiler in Ocaml

63 points| joaobatalha | 12 years ago |troydm.github.io | reply

22 comments

order
[+] gsg|12 years ago|reply
"Our program will preallocate 1000 bytes on stack for variables, since all of our variables are static."

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.

[+] toolslive|12 years ago|reply
I don't know what the purpose is here, but I think it would be a lot smaller if the standard tools for lexing and parsing were used. http://caml.inria.fr/pub/docs/manual-ocaml-400/manual026.htm...
[+] seanmcdirmid|12 years ago|reply
Most real production compilers don't use lexer or parser generators.
[+] kristianp|12 years ago|reply
Informative comment, but surely the purpose of the article is to teach ocaml, not the lexing&parsing tools, which require more ocaml knowledge?
[+] greyfade|12 years ago|reply
I hate this suggestion. What's the point of writing a toy compiler if you skip learning how to write one of its most critical parts?
[+] viciousplant|12 years ago|reply
don't you see the purpose is purely the anime?