Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/comradeprogrammer/c0_compiler_buaa
Project of 'Compiler Technology' Course of SCSE,BUAA
https://github.com/comradeprogrammer/c0_compiler_buaa
buaa buaascse
Last synced: 22 days ago
JSON representation
Project of 'Compiler Technology' Course of SCSE,BUAA
- Host: GitHub
- URL: https://github.com/comradeprogrammer/c0_compiler_buaa
- Owner: ComradeProgrammer
- Created: 2019-09-17T03:27:15.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-12-25T16:05:25.000Z (about 5 years ago)
- Last Synced: 2024-10-28T19:50:42.643Z (2 months ago)
- Topics: buaa, buaascse
- Language: C++
- Size: 901 KB
- Stars: 3
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# C0_Compiler
Final Project of ' Design of Compiler Technology' Course of SCSE,BUAA
### Overview
This is the repository for the project of "Design of Compiler Technology".This project contains a simple compiler which can translate a 'C0' language to MIPS assembly language.
### About the 'C0 language'
C0 language is a slightly modified and simplified High-level programming language based on C language. The grammar of this 'C0' language is LL(1) grammar.
The Grammar of this C0 language is shown bellow.
![grammar](https://github.com/ComradeProgrammer/C0_Compiler_BUAA/blob/master/Annotation%202019-09-26%20123820.jpg?raw=true)
### About the simple compiler
This compiler contains a 'frontend' and a 'backend.
In the front end we implemented Lexical analysis,Grammar analysis ( recursive-descend method), and the fault handling. The front end can translate the original C0 language to midcode.
The backend translates midcode to the target assembly language : mips. The following optimization is Implemented:- Active variables analysis
- automatic inline function
- DAG optimization (elimination of shared expression)
- Elimination of dead code
- substitution for assign instruction
- constant proporgation and substitution
- peephole optimization
- Simple calculation in compilation phase
- graph coloring algorithm for distribution of global register
- distribution of temporary register based on active variables analysis
### Development Environment
Editor:VS2019
Complier: clang++ 8.0 msvc g++7.2.0
Debugger: gdb debugger of msvc
### How to use this compiler
In command line:
```
usage: C0compiler.exe sourcefile
[-o outputfile]
[-d debugInformation]
[-rdi recursiveDescendInformationFile]
[-h] help document
[-opt] turn on the optimization
```
if no argument is passed to the complier,the program will be run under HomeWork Acceptance Test Mode. Under such circumstance,the source file must be "testfile.txt" and the output file must be "mips.txt"