Tuesday, January 21, 2014

1, What is computer compiler



A compiler is a computer program (or set of programs) that transforms source code written in a programming language (the source language) into another computer language (the target language, often having a binary form known as object code. The most common reason for wanting to transform source code is to create an executable program.

HISTORY
The name "compiler" is primarily used for programs that translate source code from a high-level programming language to a lower level language (e.g., asse or machine code). If the compiled program can run on a computer whose CPU or operating system is different from the one on which the compiler runs, the compiler is known as a cross-compiler. A program that translates from a low level language to a higher level one is a decompiler. A program that translates between high-level languages is usually called a language translator, source to source translator, or language converter. A language rewriter is usually a program that translates the form of expressions without a change of language.
A compiler is likely to perform many or all of the following operations: lexical analysis, preprocessing, parsing, semantic analysis (Syntax-directed translation), code generation, and code optimization.
Program faults caused by incorrect compiler behavior can be very difficult to track down and work around; therefore, compiler implementors invest significant effort to ensure compiler correctness.
The term compiler-compiler is sometimes used to refer to a parser generator, a tool often used to help create the lexer and parser.
 http://en.wikipedia.org/wiki/Compiler




 2, what are the types of computer compiler
  
TYPES OF COMPILER


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's DOALL statements).

  • One-pass compiler, like early compilers for Pascal
    • The compilation is done in one pass, hence it is very fast.
  • Threaded code compiler (or interpreter), like most implementations of FORTH
    • This kind of compiler can be thought of as a database lookup program. It just replaces given strings in the source with given binary code. The level of this binary code can vary; in fact, some FORTH compilers can compile programs that don't even need an operating system.
  • Incremental compiler, like many Lisp systems
    • Individual functions can be compiled in a run-time environment that also includes interpreted functions. Incremental compilation dates back to 1962 and the first Lisp compiler, and is still used in Common Lisp systems.
  • Stage compiler that compiles to assembly language of a theoretical machine, like some Prolog implementations
    • This Prolog machine is also known as the Warren abstract machine (or WAM). Byte-code compilers for Java, Python (and many more) are also a subtype of this.
  • Just-in-time compiler, used by Smalltalk and Java systems
    • Applications are delivered in bytecode, which is compiled to native machine code just prior to execution
  • A retargetable compiler is a compiler that can relatively easily be modified to generate code for different CPU architectures. The object code produced by these is frequently of lesser quality than that produced by a compiler developed specifically for a processor. Retargetable compilers are often also cross compilers. GCC is an example of a retargetable compiler.
  • A parallelizing compiler converts a serial input program into a form suitable for efficient execution on a parallel computer architecture. 
http://www.compilers.net/paedia/compiler/

                                           Login Activity Diagram


                                            Data Entity Diagram