Apatosaurus

A compiler is a Computer program which translates a language, the source language , in another, called the language targets , by preserving the significance of the source text. This general outline describes a great number of different programs; and what one understands by “significance of the source text” depends on the role of the compiler. When one speaks about compiler, one as in general supposes as the source language is, for the application considered, moreover high level that the target language, i.e. it presents a higher level of abstraction.

In practice, a compiler is generally used to translate a Source code writes in a Computer programming language in another language, usually a Assembly language or a Machine language. The program in machine language produces by a compiler is called Object code.

The first compiler was written by Grace Hopper.

Structure of a compiler

The principal task of a compiler is to produce correct object code. The majority of the compilers make it possible to optimize the code (the optimized object code will be carried out more quickly, or will have a less occupation memory).

A compiler functions by analyze-synthesis, i.e. instead of replacing each construction of the source language by an equivalent succession of constructions of the target language, it starts by analyzing the source text to build of it an intermediate representation which it translates in its turn into target language.

It is thus natural to separate - at least conceptually, but also in practical - the compiler in a part before (or frontal), sometimes called “stock”, which read the source text and produce the intermediate representation, and a back part (or finale), which traverses this representation to produce the target text. In an ideal compiler, the front part is independent of the target language, while the back part is independent of the source language. Certain compilers carry out moreover on the intermediate form of the substantial treatments, which one can gather in a central part, independent at the same time of the source language and target machine. One can thus write compilers for a whole range of languages and architectures by sharing the central part, to which one attaches a front part by language and a back part by architecture.

The stages of compilation include

  • the program division in lexemes (lexical Analyze);
  • the checking of the correction of the Syntax of the program (syntactic Analysis);
  • analysis of the structures of data (semantic Analysis);
  • the transformation of the source code into intermediate code;
  • the application of techniques of optimization on the intermediate code;
  • the Allowance of registers and translation of the intermediate code in object code, with possibly the insertion of data of debugging and analysis of the execution;
  • and finally the edition of the bonds.

These various stages explain why the compilers are always the subject of research, particularly in the field of the optimization of the produced code.

The majority (but not all) of the compilers translate a source file of a program written in a computer programming language into a file object (or achievable, or a file out of assembler, or even in another language).

An implementation (realization concretes) of a computer programming language can be interpreted or compiled. It is this realization which is a compiler or a Interpréteur, and a computer programming language (more or less theoretical and formalized specification its syntax and of its semantics) can have a compiled implementation, and another interpreted.

Particular compilers

Cross-compiler

A cross-compiler (in English cross-country race to compile ) is a program able to translate a source code into Object code having an environment of execution (material architecture, Operating system) different from that where compilation is carried out. These compilers are mainly used in Industrial data processing.

Byte codes or code byte

Certain compilers translate a source language into virtual machine language , i.e. in a code (generally a succession of bytes) carried out by a virtual machine : a program emulating the principal functionalities of a computer. The bearing of a program does not require thus that the bearing of the virtual machine. It is the case of the Java compiler, which translates code Java into Bytecode Java (object code). A virtual machine DotNet can carry out bytecode MSIL produced by the languages of Microsoft C#, Visual BASIC or others.

Other compilers

If the majority of the compilers translate a code of a computer programming language into another, it is not the case of all the compilers. For example, the software LaTeX compiles a code written in the Langage of formatting of text LaTeX, to convert it into another language, for example DVI, HTML, PostScript

Certain compilers translate, in an incremental or interactive way, the source program (typed by the user) in computer code. For example, certain implementations of Common Lisp (as SBCL) translate an end of program into computer code (in memory).

The Just compilers In Time (just in time) translate an intermediate representation (often code byte) into computer code, in a progressive way.

The problem of starting (bootstrap)

The first compilers were written directly in Assembly language, an elementary language symbolic corresponding to the instructions of the target processor and some structures of control slightly more advanced. This language symbolic must be assembled (and not compiled) and bound to obtain an achievable version. Because of its simplicity, a simple program is enough to convert it into instructions machines.

The current compilers are generally written in the language that they must compile; for example a compiler C is written out of C, SmallTalk in SmallTalk, Lisp in Lisp, etc In the realization of a compiler, a decisive stage is crossed when the compiler for language X is sufficiently complete to be compiled itself: it then does not depend any more a another language (this was assembler) to be produced.

The bugs of the compilers are sometimes very complex to detect. If a compiler of language C comprises a bug, the programmers in Langage C will naturally tend to blame their own source code, not the compiler.

Worse, if this buggé compiler (V1 version) compiles a compiler (V2 version) not buggé, the achievable one compiled (by V1) of the V2 compiler will be buggé. However its source code is good. The bootstrap thus obliges the programmers of compilers to circumvent the bugs existing compilers.

Related articles

External bond

  • Example of interpreter and of part-before compiler.
  • List of free and/or free compilers

Simple: To compile

Random links:Pork-butchery | Villegusien-the-lake | Merry | Park of Drakensberg