Get the latest tech news
Writing Micro Compiler in OCaml (2014)
TL;DR Writing micro compiler in OCaml At one point or another every single software developer in the world comes to a realization in his career when …
Unfortunately OCaml doesn’t have an unread operation like libc’s ungetc so we’ll need to define a simple stream reader which will have a mutable char and we will also count lines of source code read. We’ll define some additional utility functions which will be used during parsing including an Syntax_error exception which will be thrown if invalid token is scanned. Our parsing method will be combined with semantics checking and will output asm code using generator functions which we will define later.
Or read this on Hacker News