ITWissen.info - Tech know how online

Compiler construction

The principles and techniques of compiler construction are cross-thematic. Compiler construction encompasses programming languages, computer architecture, language theory, algorithms, and software engineering. To this end, a few compiler construction techniques are sufficient to create compilers - translators - for a wide range of languages and machines.

The nature and constraints of the target language and runtime environment must be carefully considered because they have a strong influence on the compiler design and what code generation strategy it might use.

A successful source language is likely to be implemented on multiple target machines. If a language exists, compilers for the language will be needed to generate code for multiple target platforms. Further evolution of the machine hardware is possible, so customizable compilers are beneficial. It follows that design is as important as limiting machine-specific details to a small number of modules that make up the compiler as a whole.

There are several aspects of compiler performance that must be considered in compiler construction: Compiler speed, code quality, error diagnostics, portability, and maintainability. The delineations between these criteria are not so clear, and the compiler specification is likely to leave many of these parameters unspecified.

The evolution of compilers

Since the first compilers appeared in the early 1950s, our knowledge of compiler design and development has evolved greatly. It is difficult to give an exact date for the first compiler, because in the beginning different groups did a lot of independent experimentation and implementation. Much of the early work on compiler construction was concerned with translating arithmetic formulas into machine code.

Throughout the 1950s, compilers were consistently considered difficult programs to write. For example, the effort toimplement the first Fortran compiler- Backus et al,1957 - was 18 man-years. Since then, systematic techniques have been discovered to deal with many tasks that arise during a compilation. Good implementation languages, programming environments, and software tools have also been developed.

Methods of compiler construction

There are several general methods that a compiler builder can take. The simplest is to adapt an existing compiler to a language or target platform. If there is no suitable compiler, the compiler builder could take the design of a known compiler for a similar language and implement the appropriate components, using component generating tools or implementing them by hand. It is relatively rare that a completely new compiler build is required.

Regardless of which method is taken, writing a compiler is an exercise in software engineering. Results from other software works can be applied to increase the reliability and maintainability of the finished product. A design that adapts to changes without difficulty will allow the compiler to evolve with the language. The use of compiler-building tools can be of significant help in this regard.

Some general tools have been created for automated design of specific compiler components. These tools use specific languages to specify and implement a component. Many work with relatively sophisticated algorithms. The most successful tools are those that hide the details of the generation algorithm and produce components that can be easily integrated into the other parts of the compiler. The following compilation lists some helpful tools for compiler construction:

Parser Generators: parser generators produce parsers from input, usually built on a context-free grammar.

Scanner Gener ators: Scanner generators automatically generate scanners. Input is usually a regular expression-based specification.

Syntax-driven translation engines: These generate a collection of routines that traverse a parse tree, generating intermediate code.

Automatic code generators: such a tool receives as input a set of rules that define, for each operation, its translation from the intermediate language to the target platform's machine language.

Data flow machines: Much of the information needed for good code optimization is obtained only through data flow analysis. That is, one gathers information about how values are transferred from one part of a program to another.

Informations:
Englisch: Compiler construction
Updated at: 09.04.2012
#Words: 635
Links: compiler, computer architecture, software engineering (SE), runtime environment (RTE), code
Translations: DE
Sharing:    

All rights reserved DATACOM Buchverlag GmbH © 2024