08-02-2013, 12:04 PM
Concepts of Compiler Design
Concepts of Compiler.ppt (Size: 916 KB / Downloads: 36)
How are Languages Implemented?
A compiler is a program takes a program written in a source language and translates it into an equivalent program in a target language.
An Interpreter Run programs “as is” without preliminary translation:
Successive phases of translation (to machine/intermediate code) and execution.
Assembler
• The Assembler is responsible for translating the target code–usually assembly code–into an executable machine code.
• The assembly code is a mnemonic version of machine code in which:
Names are used instead of binary codes for operations (Code Table).
2. Names are used for operands instead of memory locations (Symbol Tables).
Loader and Linker
• The machine code generated by the Assembler can be executed only if allocated in Main Memory starting from the address “0”.
• The starting free address, L, in Main Memory to allocate the program is called the Relocation Factor. The Loader must add to each re-locatable address the relocation factor L;
• The Linker links together the different files/modules of a single program and, possibly, adds library files.
Phases of A Compiler
Each phase transforms the source program
from one representation into another
representation.
They communicate with error handlers.
They communicate with the symbol table.
Semantic Analysis
The Semantic Analysis phase checks the program for semantic errors (Type Checking) and gathers type information for the successive phases.
Type Checking: Check types of operands (possibly imposing type coercions); No real number as index for array; etc.