25-07-2017, 12:10 PM
A compiler is a computer program that transforms a computer code written in a programming language (the source language) into another computer language (the target language). Compilers are a type of translator that supports digital devices, mainly computers. A common reason for compilation is to convert source code into a binary form known as object code to create an executable program. The name compiler is primarily used for programs that translate source code from a high-level programming language into a lower-level language (eg assembler language or machine code).
There are many different compiler types. If the compiled program can run on a computer whose CPU or operating system is different from the one in which the compiler runs, the compiler is 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 often referred to as a source-to-source compiler or transpiler. A language rewriter is usually a program that translates the form of expressions without a change of language. The term compiler-compiler is sometimes used to refer to an analyzer generator, a tool often used to help create the lexer and parser.
A compiler is likely to perform many or all of the following operations: preprocessing, lexical analysis, parsing, semantic analysis (syntax-directed translation), intermediate representation, code optimization, and code generation. Compilers implement these operations in phases that promote efficient design and correct transformations from the input source to the target output. Program crashes caused by improper compiler behavior can be very difficult to track and avoid; Therefore, the compiler implementers invest a significant effort to ensure compiler correction.
Compilers are not the only translators used to transform source programs. The interpreter is a computer program that transforms and then executes the indicated operations. The translation process influences the design of computer languages, leading to a preference for compilation or interpretation. In practice, you can implement an interpreter for compiled languages and you can implement compilers for interpreted languages.