15-07-2017, 01:50 PM
A compiler translates code written in one language into another language without changing the meaning of the program. It is also expected that a compiler will make the target code efficient and optimized in terms of time and space. The compiler design principles provide a deep insight into the translation and optimization process. The compiler design covers the basic translation mechanism and error detection and recovery. It includes lexical, syntactic and semantic analysis as a front end and generation and optimization of code as back-end.
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. 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. It is likely that a compiler will do many or all of the following operations: lexical analysis, preprocessing, parsing, semantic analysis, code generation, and code optimization. Program crashes caused by incorrect compiler behavior can be very difficult to locate and work with; Therefore, the compiler implementers invest a significant effort to ensure compiler correction. Compilers as they are strictly defined are only translators. However, interpreters are systems that apply a translation and then actually perform the indicated operations; And many compilers in practice use or rely on interpreters.