Home | Sources Directory | News Releases | Calendar | Articles | | Contact |  

Source-to-source compiler

A source-to-source compiler is a type of compiler that takes a high level programming 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's DOALL statements)[1].

Another purpose of source-to-source-compiling is translating legacy code to use the next version of the underlying programming language or an API that breaks backward compatibility. It will perform automatic code refactoring which is useful when the programs to refactor are outside the control of the original implementer (for example, converting programs from Python 2 to Python 3, or converting programs from an old API to the new API) or when the size of the program makes it impractical or time consuming to refactor it by hand.


[edit] Examples

[edit] LLVM

Low Level Virtual Machine (LLVM) can translate from any language supported by gcc 4.2.1 (Ada, C, C++, Fortran, Java, Objective-C, or Objective-C++) to any of: C, C++, or MSIL by way of the "arch" command in llvm-gcc.

% llvm-g++ x.cpp -o program
% llc -march=c program.bc -o program.c
% cc x.c

% llvm-g++ x.cpp -o program
% llc -march=msil program.bc -o program.msil

The "arch" command can also emit assembly language code in these architectures:

[edit] Refactoring tools

The refactoring tools automate transforming source code into another:

[edit] See also

[edit] References

  1. ^ "Types of compilers". compilers.net. 1997-2005. http://www.compilers.net/paedia/compiler/index.htm. Retrieved 28 October 2010. 
  2. ^ Valerie Henson (January 20, 2009). "Semantic patching with Coccinelle". lwn.net. http://lwn.net/Articles/315686/. Retrieved 28 October 2010. 

Related Articles & Resources

Sources Subject Index - Experts, Sources, Spokespersons

Sources Select Resources Articles

This article is based on one or more articles in Wikipedia, with modifications and additional content by SOURCES editors. This article is covered by a Creative Commons Attribution-Sharealike 3.0 License (CC-BY-SA) and the GNU Free Documentation License (GFDL). The remainder of the content of this website, except where otherwise indicated, is copyright SOURCES and may not be reproduced without written permission. (For information use the Contact form.)

SOURCES.COM is an online portal and directory for journalists, news media, researchers and anyone seeking experts, spokespersons, and reliable information resources. Use SOURCES.COM to find experts, media contacts, news releases, background information, scientists, officials, speakers, newsmakers, spokespeople, talk show guests, story ideas, research studies, databases, universities, associations and NGOs, businesses, government spokespeople. Indexing and search applications by Ulli Diemer and Chris DeFreitas.

For information about being included in SOURCES as a expert or spokesperson see the FAQ or use the online membership form. Check here for information about becoming an affiliate. For partnerships, content and applications, and domain name opportunities contact us.

Sources home page