Directories | Web | Images | Groups | News | Shopping | Local

Enter your search keyword(s):

 



(formerly Encyclopedic directory)
Compilers
Home / Top / Computers / Programming / Compilers See also:
Related articles

Edit | Discuss Article

Compiler

A compiler is a computer program that translates a computer program written in one computer language (called the source language) into a program written in another computer language (called the output or the target language).

Most compilers translate source code written in a high level language to object code or machine language that may be directly executed by a computer or a virtual machine. However, translation from a low level language to a high level one is also possible; this is normally known as a decompiler if it is reconstructing a high level language which (could have) generated the low level language. Compilers also exist which translate from one high level language to another, or sometimes to an intermediate language that still needs further processing; these are sometimes known as cascaders.

Typical compilers output so-called objectss that basically contain machine code augmented by information about the name and location of entry points and external calls (to functions not contained in the object). A set of object files, which need not have all come from a single compiler provided that the compilers used share a common output format, may then be linked together to create the final executable which can be run directly by a user.

Table of contents
1 Types of compilers
2 Compiler design
3 Compiler front end
4 Compiler back end
5 Compiled vs. Interpreted languages
6 History
7 Further reading
8 See also
9 External links

Types of compilers

A compiler may produce code intended to run on the same type of computer and operating system ("platform") as the compiler itself runs on. This is sometimes called a native-code compiler. Alternatively, it might produce code designed to run on a different platform. This is known as a cross compiler. Cross compilers are very useful when bringing up a new hardware platform for the first time (see bootstrapping). A "source to source compiler" is a type of compiler that takes a high level language as its input and outputs a high level language. For example, an automatic parallelizing compiler will frequently take in a high level language program as an input and then transform the code and annotate it with parallel code annotations (e.g. OpenMP) or language constructs (e.g. FORTRAN DOALL statements).

Compiler design

In the past, compilers were divided into many passes to save space. When each pass is finished, the compiler can free the space needed during that pass.

Many modern compilers share a common 'two stage' design. The front end translates the source language into an intermediate representation. The second stage is the back end, which works with the internal representation to produce code in the output language. The front end and back end may operate as separate passes, or the front end may call the back end as a subroutine, passing it the intermediate representation.

This approach mitigates complexity separating the concerns of the front end, which typically revolve around language semantics, error checking, and the like, from the concerns of the back end, which concentrates on producing output that is both efficient and correct. It also has the advantage of allowing the use of a single back end for multiple source languages, and similarly allows the use of different back ends for different targets.

Certain languages, due to the design of the language and certain rules placed on the declaration of variables and other objects used, and the predeclaration of executable procedures prior to reference or use, are capable of being compiled in a single pass. The Pascal programming language is well known for this capability, and in fact many Pascal compilers are themselves written in the Pascal language because of the rigid specification of the language and the capability to use a single pass to compile Pascal language programs.

Compiler front end

The compiler front end consists of multiple phases itself, each informed by formal language theory:

  1. Lexical analysis - breaking the source code text into small pieces ('tokens' or 'terminals'), each representing a single atomic unit of the language, for instance a keyword, identifier or symbol names. The token language is typically a regular language, so a finite state automaton constructed from a regular expression can be used to recognize it. This phase is also called lexing or scanning.
  2. Syntax analysis - Identifying syntactic structures of source code. It only focuses on the structure. In other words, it identifies the order of tokens and understand hierarchical structures in code. This phase is also called parsing.
  3. Semantic analysis is to recognize the meaning of program code and start to prepare for output. In that phase, type checking is done and most of compiler errors show up.
  4. Intermediate language generation - an equivalent to the original program is created in an intermediate language.

Compiler back end

While there are applications where only the compiler front end is necessary, such as static language verification tools, a real compiler hands the intermediate representation generated by the front end to the back end, which produces a functional equivalent program in the output language. This is done in multiple steps:

  1. Optimization - the intermediate language representation is transformed into functionally equivalent but faster (or smaller) forms.
  2. Code generation - the transformed intermediate language is translated into the output language, usually the native machine language of the system. This involves resource and storage decisions, such as deciding which variables to fit into registers and memory and the selection and scheduling of appropriate machine instructions.

Compiled vs. Interpreted languages

Many people divide higher level programming languages into two categories: compiled languages and interpreted languages. However, in fact most of these languages can be implemented either through compilation or interpretation, the categorisation merely reflecting which method is most commonly used to implement that language. (Some interpreted languages, however, cannot easily be implemented through compilation, especially those which allow
self-modifying code.)

History

Several experimental compilers were developed in the 1950s, but the Fortran team led by John Backus at IBM is generally credited as having introduced the first complete compiler, in 1957. The idea quickly caught on, and most of the principles of compiler design were developed during the 1960s.

During the 1990s a large number of free compilers and compiler development tools have been developed for all kinds of languages, both as part of the GNU project and other open-source initiatives. Some of them are considered to be of high quality and their free source code makes a nice read for anyone interested in modern compiler concepts.

Further reading

  • by Alfred V. Aho, Ravi Sethi, and Jeffrey D. Ullman (ISBN 0201100886) is considered to be the standard authority on compiler basics, and makes a good primer for the techniques mentioned above. (It is often called the Dragon Book because of the picture on its cover showing a Knight of Programming fighting the Dragon of Compiler Design.) External link to publisher's catalog entry

  • (ISBN 0333217322) by Richard Bornat is an unusually helpful book, being one of the few that adequately explains the recursive generation of machine instructions from a parse-tree. Having learnt his subject in the early days of mainframes and minicomputers, the author has many useful insights that more recent books often fail to convey.

See also

External links


Source | Copyright


Webmasters: Add your website here:

Readers: Edit | Discuss Listings

Tools for compiling
LL(1) parser generator, implentations of Euler, and Backus' FP, all written in Icon.
http://www.iit.edu/~tc/toolsfor.htm

The comp.compilers Newsgroup
Home page of newsgroup. Archives begining from 1986, search, file archive.
http://compilers.iecc.com/index.html

Turbo Pascal 3.0 compiler and code generation internals
Internals of one-pass compiler by example Pascal compiler.
http://www.pcengines.ch/tp3.htm

Catalog of Free Compilers, Interpreters, and Other Language Tools
Searchable listing of programming language tools that come with source code.
http://www.idiom.com/free-compilers/

Nullstone Corp.
Makes NULLSTONE automated compiler performance analysis tool, uses QA approach of coverage and isolation to measure effectiveness of compiler optimizer to perform wide range of optimizations.
http://www.nullstone.com/

Softpanorama Bookshelf / Compiler Construction
Reviews of compiler books, with links to Amazon just in case you want to buy one
http://www.softpanorama.org/Bookshelf/compilers.shtml

Let's Build a Compiler
A multi-part tutorial on compiler construction by Jack Crenshaw.
http://compilers.iecc.com/crenshaw/

Compiler Jobs
Compiler job openings at companies and universities.
http://www.compilerjobs.com/

The Compiler Connection
A comprehensive listing of compiler companies, compiler research projects, benchmarks, and compiler job listings.
http://www.compilerconnection.com/

Architectures and Compilers to Support Reconfigurable Computing
Reconfigurable computing: why and how? Article published in Crossroads, the ACM student magazine.
http://www.acm.org/crossroads/xrds5-3/rcconcept.html

Compilers.net
Directory, search engine of compiler-related sites. People, books, papers, publishers, decompiling, generators (scanner, parser, backend), translators, compiler compilers, courses, tutorials, library, FAQ, free, companies, tools, mail list, survey/poll.
http://www.compilers.net/

Links and Selected Readings for Compiler Writers
GCC extending specific literature, processor chips documentation, collected papers/sites on language standards, compilers, optimization.
http://gcc.gnu.org/readings.html

Free Compilers and Interpreters
List of free compilers and interpreters for programming languages with descriptions.
http://www.thefreecountry.com/compilers/

Program-Transformation.org
Goal: collect, organize, disseminate information on all aspects of program transformation to share results across communities. TWiki collaborative Web development system with descriptions, news, surveys, papers, and links.
http://www.program-transformation.org/twiki/bin/view/Transform

Bloodshed Software: Compilers Resources
Links to free compilers, with sources, compiler construction toolkits, tutorials, articles, other compiler-related sites.
http://www.bloodshed.net/compilers/

Tasking
Supplier of software development tools for embedded microcontroller and digital signal processors applications across industry standard computing platforms.
http://www.tasking.com/

Context
Simple programming language and compiler, with sources on its own input language; DOS, Win32 versions. Some information on compiler design. By Andrei V. Khokhlov.
http://www.avhohlov.narod.ru/engl010.htm

Programming Language and Compiler Research Groups
Multi-site working groups and projects listing.
http://www-2.cs.cmu.edu/afs/cs.cmu.edu/user/mleone/web/language/projects.html

Architectural Neutral Distribution Format (ANDF)
A software porting technology, intended to help develop shrink-wrapped software for open systems, independent of any particular processor architecture.
http://www.info.uni-karlsruhe.de/~andf/

Free Programming Compilers and Interpreters
Links to free programming compilers and interpreters categorized by language.
http://www.freeprogrammingresources.com/frcomplr.html

The Decompilation Page
Resources, history and timeline, discussion of approaches, and ethics.
http://www.itee.uq.edu.au/~csmweb/decompilation/home.html

Dmitry Smaghin's site
A collection of educational compilers, assemblers, disassemblers, interpreters with sources (C, Pascal). Links to freeware compilers.
http://www.exmortis.narod.ru/index_eng.html

Compiler Construction with Minijava
Provide a resource on the process of creating a modern compiler. This site will provide useful resources on lexical anaysis, parsing, abstract syntax tree generation, and typing checking for the Minijava grammer.
http://www.hydrinos.net



Help build the largest human-edited directory on the web.
 Submit a Site - Open Directory Project (modified) - Become an Editor

Modified contents copyright 2008. All rights reserved.