A compiler for the compiler course. The source language is a mixture of C and Java. The target is x86 assembly.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.idea Maple: Beautified Code Jun 14, 2017
Maple Add README Oct 18, 2018
M_language_manual.pdf Add README Oct 18, 2018
Presentation.pdf update from bitbucket Sep 19, 2017
README.md update README Oct 18, 2018
asm.png Add README Oct 18, 2018
ast.png Add README Oct 18, 2018
ir.png Add README Oct 18, 2018

README.md

Maple: A Compiler Translate Mx* Language into X86 Assembly

Project of MS208 Compiler

A PDF to introduce my compiler (written in Chinese): Presentation.pdf

Please refer to this course wiki for details: https://acm.sjtu.edu.cn/wiki/Compiler_2017

Mx* Language

Mx* is a hybriding language of C and Java. Documents of Mx* Language: M_language_manual.pdf

Structure

Abstract Syntax Tree

Intermediate language

ASM Generation

Usage

cd Maple
bash codegen.bash
[Enter your code]
[End with control + d]

Example

cd Maple
bash codegen.bash

class TA{
	string state;
	int anger;
}
int init_anger = 100;
int work_anger = 10;
void work(string st, TA ta)
{
	if (ta.anger <= 100) println(st + ", " + ta.state + " enjoys this work. XD");
	else println(st + ", " + ta.state + " wants to give up!!!!!");
	ta.anger = ta.anger + work_anger;
}
int main()
{
	TA mr;
	TA mars;
	mr = new TA;
	mr.state = "the leading TA";
	mr.anger = 0;
	mars = new TA;
	mars.state = "the striking TA";
	mars.anger = init_anger;
	work("MR", mr);
	work("Mars", mars);
	work("Mars", mars);
}

[End with control + d]