Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/natelindev/modular-mini-c-compiler
A Mini C Compiler
https://github.com/natelindev/modular-mini-c-compiler
c compiler mips mips-assembly xml
Last synced: 11 days ago
JSON representation
A Mini C Compiler
- Host: GitHub
- URL: https://github.com/natelindev/modular-mini-c-compiler
- Owner: natelindev
- Created: 2017-08-12T12:04:53.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-12-12T07:48:55.000Z (about 7 years ago)
- Last Synced: 2024-11-17T13:23:51.593Z (2 months ago)
- Topics: c, compiler, mips, mips-assembly, xml
- Language: C++
- Size: 27.3 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Modular-Mini-C-Compiler
## Introduction
This is a modular mini C compiler.
It can translate a subset of C language into MIPS assembly language.
Currently it's unfinished ,there are still a lot of work to do. Help is welcomed.
Basic Module Functions are as follows.
**PreProcessor**: delete comments.
**Scanner**: Tokenize the input stream.
**Parser**: Generate Parse tree.
**SemanticAnalyser**: Reduce the size and length of parse tree, make it into AST.
**IR_Generator**: Translate the AST into IR (Intermediate Representation). In this case, we use linear three address IR.
**Optimizer**: Not yet implemented. Will function as IR optimizer in order to reduce Time/Space Complexity in the future.
**Code_Generator**: Generate RISC assembly code from IR.
**XML_suit**: Parse the XML input and Generate the XML output. Note that XML format can be found at `XML_examples` directory.
*[Warning] There are still a lot of work to be done, currently the XML input and output of each module is handled by the their own version of XML suit, this will be fixed in the future.*
## Usage
Suppose you have a file named test.c
Put the module binary in the root directory, and then (eg. `Scanner.exe`)
#### Windows
```powershell
run.bat test
```#### Unix(Including macOS & Linux)
```shell
$./run.sh test
```If it prompts that the permission is denied.
Please execute this command first:
```Shell
$chmod 755 run.sh
```## Thanks
Inspired by [bit-minic-compiler](https://github.com/jiweixing/bit-minic-compiler)
## Disclaimer
- No code from bit-mini-compiler is taken to this project
- This project is for educational purpose only, I'm not responsible for the consequences of error assembly code it generated.