Академический Документы
Профессиональный Документы
Культура Документы
main()
{
int i,k,r[L];
for(i=0;i<L;i++) {
k = 3*i+2;
r[i] = k*k;
}
}
Error
Messages
Compiler
0010011000110001
1000111011001010
1101010010101001
1010101010101111
1010100111111111
0101010101010101
2
Marco Maggini
The compiler
Language Processing
Technologies
3
Marco Maggini
Language Processing
Technologies
4
Marco Maggini
=
X = A+B*C
+
*
A
B
Language Processing
Technologies
5
Marco Maggini
Language Processing
Technologies
preprocessor
source program
assembly code
assembler
object code
libreries
linker/loader
executable code
6
Marco Maggini
Language Processing
Technologies
Compiler structure
lexical analysis
syntactic analysis
semantical analysis
symbol table
intermediate code
generation
optimization
object code
generation
error handling
7
Marco Maggini
Language Processing
Technologies
8
Marco Maggini
Language Processing
Technologies
assignment
statement
identifier
expression
expression
identifier
expression
+
expression
identifier
expression
number
60
9
Marco Maggini
Language Processing
Technologies
Syntatic rules
base rules
recursive rules
10
Marco Maggini
Language Processing
Technologies
Sematical analysis
Yields the sematics associated to the syntatic structure
It verifies that the usage rules of the language are satisfied
identifier declarations (e.g. duplicate definitions,...)
type check (compatibility of types in expressions, automatic
type conversion, type check for vector indexes, ecc..)
*
int D;
float C;
C
D
11
Marco Maggini
Language Processing
Technologies
Symbol table
It memorizes the identifiers and their associated attributes
memory allocation
type
visibility scope
number and type of function/procedure arguments
memory allocation
12
Marco Maggini
Language Processing
Technologies
internal intermediate
representation
id1
+
id2
*
id3
int-to-float
60
intermediate code
generation
code optimization
object code
generation
t1 = int-to-float(60)
t2 = id3 * t1
t3 = id2 + t2
id1 = t3
t1 = id3 * 60.0
id1 = id2 + t1
MOVF id3, R2
MULF #60.0, R2
.............