project: acm compiler 2014 shanghai jiao tong university class acm 2011 dong xie
Post on 01-Jan-2016
217 Views
Preview:
TRANSCRIPT
Introduction Task: Write a compiler of simplified C in full-featured Java to
MIPS.
Main Reference Book: Compilers Principles Techniques and Tools
You may also need more materials: Modern Compiler Implementation in Java/C/ML
MIPS-SPIM document
All kinds of papers
…
Introduction You are allowed to use a language other than Java
Whoever bootstrapping C will get a full score
NO bonus needed for other language
BUT you may not have a good support from your TAs.
Apply it explicitly to TAs if you want to do this.
TA List 贺天行 cloudygooseg [at] gmail.com
解东 xiedong1993 [at] gmail.com
吴航 wuzhongminghang [at] gmail.com
金天行 121665841 [at] qq.com
Google Groups: tiger-acm-sjtu [at] googlegroups.com
IMPORTANT Be sure you have join this group.
Schedule & Principles Lecture: every Friday 7 PM at SEIEE Building 3-404
Project Checkpoint Due: on some Friday 6 PM
There will be TWO code reviews during the project
NO CHEATING
NO LATE SUBMISSION
All test cases will be publicly available.
Versioning & Submission Version your compiler codes using BitBucket.
You are NOT allowed to publish your code on the Internet
Create a private repo named compiler2014
Add username acmcompiler to your repository with read permission
Submit your code for each phase by creating a tag.
Grading Data Correctness (60 points)
Performance (20 points)
Code review (5 points)
Attendance (5 points)
Bonus Report
Mail list Summary
Helper
Book Reader
Performance Winners
Possible Bonus List Use C language to implement the compiler.
Implement typedef
Implement higher order functions. (lambda expression, etc.)
Static analyzer (abstract interpreter)
Garbage collection (If you pass our testcases, you can get this bonus.)
Optimization (loop-unrolling, constants propagation, inline functions, dead code elimination, etc.)
Concurrency and scheduling
Reconstruct the AST
...
Compiler Phases Syntactic Analysis (Lexing, Parsing) Semantic Analysis (Types, Scopes, …) Intermediate Representation (IR) Optimization (CPU, Registers, Memory, …) Code Generation
Difference between compilers and interpreters?
Example int a = 1; print(a); int b = “hello” print(b)
When will a compiler and a interpreter raise the error.
An Appetizer A toy compiler as a tutorial written by Xiao Jia
Notice: you may not find IR phase in it.
You will find it VERY IMPORTANT if you have no idea to start.
Description: http://acm.sjtu.edu.cn/wiki/Compiler_2014:_An_appetizer
Source Code: https://github.com/stfairy/appetizer
Task 1: Tokenlize
int
<id, main>
(
int <id, argc>
)
{
<id, printf>
(
<string, “Hello World!\n”>
)
;
return
<number, 0>
;
}
Task 2: Parsering
(func int main[(arg int argc)])
(stmtlist
(expr (call printf[“Hello World!\n”]))
(stmtlist
(return (number 0))))
Note: you need to print out a AST NOT a Parser Tree.
Syntactic Specification
Tokens:
http://acm.sjtu.edu.cn/wiki/Compiler_2014:_Tokens
Grammar:
http://acm.sjtu.edu.cn/wiki/Compiler_2014:_Grammar
Tools & Grading Following tools are allowed:
lex / yacc / Quex / flex / bison
re2c / lemon
Jflex / CUP
ANTLR (v3 or v4)
Ragel
This phase will be manually judged in code review.
Feel free to design your own output formats!
top related