Skip to content
This repository has been archived by the owner on Aug 13, 2021. It is now read-only.
/ C-to-MIPS-compiler Public archive

A C to MIPS compiler based on the ANSI C specification and written in C++.

Notifications You must be signed in to change notification settings

xw2519/C-to-MIPS-compiler

Repository files navigation

C-To-MIPS Compiler

A C to MIPS compiler based on the ANSI C specification and developed in C++.

This project specifications is based on ELEC50010: Instruction Architecture and Compilers [https://github.com/LangProc/langproc-2019-cw.git].

Table of contents

Deliverables

The deliverables consists of the following:

  • compiler.cpp: Compiles a given ANSI C program into MIPS assembly language.
  • test_compiler.sh: A testbench for the compiler that uses the test cases in the compiler_tests folder and compares the generated MIPS assembly language with MIPS-QEMU.

Compiler

The development of the compiler was inspired based on the ANSI C Yacc Grammer published by Jeff Lee [https://www.lysator.liu.se/c/ANSI-C-grammar-y.html].

The compiler is composed of two main file: lexer and parser. The compiler file dependencies is shown below:

compiler.cpp
|-- lexer.flex
|-- parser.y
    |-- ast_context.hpp
    |-- ast_declaration.hpp
    |-- ast_expression.hpp
    |-- ast_primitive.hpp
    |-- ast_statement.hpp

Building

The compiler is compiled through the Makefile by calling the following commands through the Linux terminal:

make clean 
make all

Testbench

There are three types of testbenches written in Linux bash:

  • test_testcase.sh
  • test_folder.sh
  • test_compiler.sh

Building

Each testbench script can be executed through the Linux terminal such as:

./test_testcase.sh

Contributors

About

A C to MIPS compiler based on the ANSI C specification and written in C++.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •