One-pass compiler

One-pass compiler

In computer programming, a one-pass compiler is a compiler that passes through the source code of each compilation unit only once. In other words, a one-pass compiler does not "look back" at code it previously processed. Another term sometimes used is narrow compiler, which emphasizes the limited scope a one-pass compiler is obliged to use. This is in contrast to a multi-pass compiler which traverses the source code and/or the abstract syntax tree several times, building one or more intermediate representations that can be arbitrarily refined.

While one-pass compilers may be faster than multi-pass compilers, they are unable to generate as efficient programs, due to the limited scope available. (Many optimizations require multiple passes over a program, subroutine, or basic block.) In addition, some programming languages simply cannot be compiled in a single pass, as a result of their design.

In contrast, some programming languages have been designed specifically to be compiled with one-pass compilers, and include special constructs to allow one-pass compilation. An example of such a construct is the forward declaration in Pascal. Normally Pascal requires that procedures be fully defined before use. This helps a one-pass compiler with its type checking: calling a procedure that hasn't been defined is a clear error. However, this requirement makes mutually recursive procedures impossible to implement:

function odd(n : integer) : boolean;
begin
   if n = 0 then
       odd := false
   else if n < 0 then
       odd := even(n + 1) { Compiler error: 'even' is not defined }
   else 
       odd := even(n - 1)
end;
   
function even(n : integer) : boolean;
begin
   if n = 0 then
       even := true
   else if n < 0 then
       even := odd(n + 1)
   else 
       even := odd(n - 1)
end;

By adding a forward declaration for the function even before the function odd, the one-pass compiler is told that there will be a definition of even later on in the program.

function even(n : integer) : boolean; forward;

function odd(n : integer) : boolean;
{ Et cetera }


Wikimedia Foundation. 2010.

Игры ⚽ Поможем написать курсовую

Look at other dictionaries:

  • One-Pass Compiler —   [engl.], Einschritt Compiler …   Universal-Lexikon

  • Multi-pass compiler — A multi pass compiler is a type of compiler that processes the source code or abstract syntax tree of a program several times. This is in contrast to a one pass compiler, which traverses the program only once. Each pass takes the result of the… …   Wikipedia

  • Compiler — This article is about the computing term. For the anime, see Compiler (anime). A diagram of the operation of a typical multi language, multi target compiler A compiler is a computer program (or set of programs) that transforms source code written …   Wikipedia

  • Compiler optimization — is the process of tuning the output of a compiler to minimize or maximize some attributes of an executable computer program. The most common requirement is to minimize the time taken to execute a program; a less common one is to minimize the… …   Wikipedia

  • Einschritt-Compiler —   [engl. one pass compiler], ein Compiler, der den zu übersetzenden Quellcode nur einmal durchgeht und dabei übersetzt. Die Syntax einiger Programmiersprachen verlangt aber oft mehrere Durchgänge bis zur vollständigen Übersetzung des Codes …   Universal-Lexikon

  • Cross compiler — A cross compiler is a compiler capable of creating executable code for a platform other than the one on which the compiler is run. Cross compiler tools are used to generate executables for embedded system or multiple platforms. It is used to… …   Wikipedia

  • Code generation (compiler) — In computer science, code generation is the process by which a compiler s code generator converts some intermediate representation of source code into a form (e.g., machine code) that can be readily executed by a machine (often a computer).… …   Wikipedia

  • Burroughs large systems — The Burroughs large systems were the largest of three series of Burroughs Corporation mainframe computers. Founded in the 1880s, Burroughs was the oldest continuously operating entity in computing, but by the late 1950s its computing equipment… …   Wikipedia

  • PASCAL — Paradigmen: imperativ, strukturiert Erscheinungsjahr: 1972 Entwickler: Niklaus Wirth Dialekte: UCSD Pascal …   Deutsch Wikipedia

  • Programmiersprache Pascal — Pascal Paradigmen: imperativ, strukturiert Erscheinungsjahr: 1972 Entwickler: Niklaus Wirth Dialekte: UCSD Pascal …   Deutsch Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”