Download presentation
Presentation is loading. Please wait.
Published byEarl Gibbs Modified over 9 years ago
1
COMPILER OVERVIEW
2
Compiler Phases Syntactic Analysis (Lexing, Parsing) c = (a + b) * (a + b);
3
Compiler Phases Syntactic Analysis (Lexing, Parsing, AST) Semantic Analysis (Types, Scopes…)
4
Compiler Phases Syntactic Analysis (Lexing, Parsing, AST) Semantic Analysis (Types, Scopes…) Generate Intermediate Representation(IR) t1 = a + b t2 = a + b t3 = t1 + t2 c = t3
5
Compiler Phases Syntactic Analysis (Lexing, Parsing, AST) Semantic Analysis (Types, Scopes…) Generate Intermediate Representation(IR) Optimization t1 = a + b t2 = a + b t3 = t1 + t2 c = t3 t1 = a + b t3 = t1 + t1 c = t3
6
Compiler Phases Syntactic Analysis (Lexing, Parsing, AST) Semantic Analysis (Types, Scopes…) Generate Intermediate Representation(IR) Optimization Code Generation t1 = a + b t3 = t1 + t1 c = t3 lw $1, a lb $2, b add $3, $1, $2 add $4, $3, $3 st $4, c
7
PHASE 1: SYNTACTIC ANALYSIS
8
Task 1: Lexing #include int main() { printf(“Hello World!\n”); } http://acm.sjtu.edu.cn/wiki/Compiler_2 015:_Tokens int main ( ) { printf ( “Hello World!\n” ) ; }
9
Task 2: Parsering int main ( ) { printf ( “Hello World!\n” ) ; } http://acm.sjtu.edu.cn/wiki/Compiler_2015:_Grammar Use context-free grammar to build Parse Tree(a.k.a. concrete syntax tree) Build Abstract Syntax Tree(a.k.a. syntax tree) by walking on Parse Tree
10
Tools & Grading Following tools are allowed: lex / yacc / Quex / flex / bison re2c / lemon Jflex / CUP ANTLR (v4) Ragel This phase will be manually judged in code review.
11
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_2015:_An_appetizerhttp://acm.sjtu.edu.cn/wiki/Compiler_2015:_An_appetizer Source Code: https://github.com/stfairy/appetizerhttps://github.com/stfairy/appetizer
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.