Citizendia
Your Ad Here

In computer programming, a one-pass compiler is a compiler that passes through the source code of each compilation unit only once. A compiler is a Computer program (or set of programs that translates text written in a computer language (the source language) into another In Computer science, source code (commonly just source or code) is any sequence of statements or declarations written in some Human-readable See C programming language for translation unit in the context of Computer programming. 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. A multi-pass compiler is a type of Compiler that processes the Source code or Abstract syntax tree of a program several times In Computer science, an abstract syntax tree (AST or just syntax tree, is a tree representation of the Syntax of some Source code In Computer science, an intermediate language is the language of an Abstract machine designed to aid in the analysis of Computer programs The term comes

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. Compiler optimization is the process of tuning the output of a Compiler to minimize or maximize some attribute of an Executable computer program In Computing, a basic block is code that has one entry point (i ) In addition, some programming languages simply cannot be compiled in a single pass, as a result of their design. A programming language is an Artificial language that can be used to write programs which control the behavior of a machine particularly a Computer.

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. Pascal is an influential imperative and procedural Programming language, designed in 1968/9 and published in 1970 by Niklaus Wirth as a small 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. In Computer science, a type system defines how a Programming language classifies values and expressions into '''types''', how it can 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. Mutual recursion is a form of Recursion where two mathematical or computational functions are defined in terms of each other In Computer programming, a forward declaration is a declaration of a variable or function which the programmer has not yet given a complete Definition.

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

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


© 2009 citizendia.org; parts available under the terms of GNU Free Documentation License, from http://en.wikipedia.org
Dapyx Software network: MP3 Explorer | Ebook Manager | Zenithic