Tópicos sobre Construção de Compiladores

From Wiki**3

Revision as of 18:57, 15 November 2008 by Root (talk | contribs)

A compiler is a program that takes as input a program written in the source language and translates it into another the target language, typically (although not necessarily) one understandable by a machine.

Various types: translator (between two high-level languages), compiler (from high- to low-level language), decompiler (from low- to high-level language), rewriter (within the same language).

Modern compilers usually take source code and produce object code, in a form usable by other programs, such as a linker or a virtual machine. Examples:

  • C/C++ are typically compiled into object code for later linking (.o files);
  • Java is typically compiled (Sun compiler) into binary class files (.class), used by the virtual machine. The GCC Java compiler can, besides the class files, also produce object files (like for C/C++).

Compiler or interpreter: although both types of language analysis tools share some properties, they differ in how they handle the analyzed code. Compilers will simply produce an equivalent version of the original language in a target language; interpreters will, like compilers, translate the input language, not into a target version, but rather directly into the execution of the actions described in the source language.

The following sections cover the overall development process and contain both theoretical and practical aspects.