Professional Documents
Culture Documents
Construction
Robert van Engelen
http://www.cs.fsu.edu/~engelen/courses/COP5621
http://www.cs.fsu.edu/~engelen/courses/COP5621
Input
Source
Target
Compiler
Program
Program
Source
Program
Interpreter
Output
Input
Preprocessor
Source Program
Try for example:
Compiler
gcc -v myprog.c
Target Assembly Program
Assembler
Relocatable Object Code
Linker
Libraries and
Relocatable Object Files
COP5621 Fall 2009
9
Absolute Machine Code
The Phases of a Compiler
Phase
Output
Sample
Programmer (source code producer)
Source string
A=B+C;
Scanner (performs lexical analysis)
Token string
‘A’, ‘=’, ‘B’, ‘+’, ‘C’, ‘;’
And symbol table with names
Parser (performs syntax analysis Parse tree or abstract syntax tree
;
|
based on the grammar of the =
programming language)
/ \
A +
/ \
B C