A compiler for MICRO language
A compiler for MICRO language designed using C++, Flex and Bison.
This compiler compiles correctly for code including Statements, Expressions and Function calls. Conditionals and loops are not implemented. To see sample code files see sample_input
To build the compiler first install flex and bison. You can use the following commands for Ubuntu:
sudo apt-get install flex
sudo apt-get install bison
Then clone this repository and run the following command from inside the directory
make compiler
The above command will generate file named micro
and this is our compiler.
To compile your MICRO code use following command
./micro path/to/input_file
You can test using the sample input files provided.
The compiler will generate assembly level code. To interpret the assembly level code we will use Tiny (a very simple assembly code interpreter). You can check it's the documentation of here.
Build the interpreter using
make interpreter
and then run
./tiny input file
The input file in this step is the output generated from above step.
Main parts of this compiler are:
This project was done as part of CS406 Compilers course at IIT Dharwad in Spring 2020 Semester. The interpreter is not written by me and was provided.