The Objective CAML compiler goes through the following stages: lexical analysis, parsing, semantic analysis, generation of intermediate code, optimization of intermediate code and generation of pseudo code. Code generated and represented internally by OCAML is referred to as intermediate language.
Lexical analysis converts characters in a sequence to a lexical element sequence. During parsing, a syntax tree is constructed that verifies the lexical element sequence to ensure it is correct in reference to the grammar used with the language. Semantic analysis checks type inference for program correctness. The next two phases create and optimize the code, and the last step generates the program binary.