Principles of Programming Languages
h"p://www.di.unipi.it/~andrea/Dida2ca/PLP-16/
- Prof. Andrea Corradini
Department of Computer Science, Pisa
- Structure of compilers
- Overview of a syntax-directed compiler front-
Principles of Programming Languages - - PowerPoint PPT Presentation
Principles of Programming Languages h"p://www.di.unipi.it/~andrea/Dida2ca/PLP-16/ Prof. Andrea Corradini Department of Computer Science, Pisa Lesson 3 Structure of compilers Overview of a syntax-directed compiler front- end
2
3
4
5
Source Program Lexical analyzer 1 Syntax Analyzer 2 Semantic Analyzer 3 Intermediate Code Generator 4 Code Optimizer 5 Code Generator Target Program Symbol-table Manager Error Handler
Analyses
Peephole Optimization 7
1, 2, 3, 4 : Front-End 5, 6, 7 : Back-End
6
Syntheses
6
7
8
Seman,c Analysis Scanner (lexical analysis) Parser (syntax analysis) Machine-Independent Code Improvement Target Code Genera,on Machine-Specific Code Improvement Source program (character stream) Tokens Parse tree Abstract syntax tree, or … Modified intermediate form Assembly or object code Modified assembly or object code
9
Intermediate Code Genera,on Three address code, or… Three address code, or…
10
Lexical analyzer Parser / Syntax-directed translator
Syntax definiBon (BNF grammar)
IR specificaBon
11
12
13
14
15
16
17
18
19
20
21
22
23
24