Abstractly a compiler is a program that takes as input a representation of some sort and transforms this representation into another one as its output.
subgraph input file
A[Representation A] --> C(fa:fa-tools Compiler)
C --> B
subgraph output file
Usually, the input file contains a programming language source (a C source file for example) and the output file contains an executable file for the target machine or
for a virtual machine.
A compiler generally produces different kind of intermediate representations before producing the final representation. The compiler can, depending on the source language,
do some static analysis to detect some errors before the execution of the program. The compiler can transform the source program, without modifying its semantic, into a more
efficient code : this transformation is called optimisation.
- In the MiniJava part, we will study a kind of compiler, a transpiler or source to source compiler, for which the input
representation will be a programming language (the MiniJava language) and the output representation will be another programming
language (the C language). In this way, we will be able to take advantage of the presence of a C compiler and focus
only on the static type checking and the generation in C of the object orienting part of MiniJava.
This first compiler will be an easier step into compilation but still will be a very practical approach to compilation because we will produce quickly a compiler
without the hard part of generating optimized machine code for a given architecture.