1 TheorieLangage Compilation
1 TheorieLangage Compilation
Salah Sadou
Introduction to FRAMA-C
1 Introduction of formalism in the C language
2 Course given by Julien Signoles (CEA-List, Paris)
1 Programming Languages
Few Historical References
Translators
Translation stages
Tools for Building Translators
Leading Thread
Today there are thousands of languages and are sometimes very specialized.
Specificities
A maximum of errors detected by the compilation phase.
A translation, followed by several executions.
Specificities
As many translations as executions.
Slow execution.
All errors appear at runtime.
Exemple
Java compilers.
Lexical Analyzer
it produces lexical units (or tokens) by character concatenation.
The lexical unit constitutes the first level of entity having an identifiable
role in the language:
a sequence of digits like ’1’ ’2’ ’4’ is the lexeme ’124’
a sequence of letters like ’e’ ’l’ ’s’ ’e’ is the lexeme ’else’
Code Generator
It produces a sequence of statements executable by a target machine (or
intermediate code statements for a virtual machine).
Optimizer
It improves and simplifies the code produced by the generator following
various transformations (eg: deletion of unreachable parts of the program).
Symbol Table
It has a central role for:
variables, arrays, structures: description of the type, memory space to
be reserved, range, visibility,
procedures, functions, methods: number and type of parameters (call
by value, by address)
Assessment
Presentation of your language’s Grammar
Demonstration of your compiler on a sample of algorithms.