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 (or a set of programs) that transforms the source code written into a programming language (the source language) into another computer language (the target language), the latter having a binary form known as code object. The most common reason for converting source code is to create an executable program.
The name "compiler" is used primarily for programs that translate source code from a high-level programming language into a lower-level language (eg assembler language or machine code). 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 known as a cross-compiler. More generally, compilers are a specific type of translator.
Although all programs that take a set of programming specifications and translate them, that is, they create a means to execute those specifications, they are technically "compilers", the term usually means a program that produces an independent compiler executable (which may require A runtime library or subsystem to operate), a compiler that simply executes the original specifications is generally known as an "interpreter", although due to the different methods of analyzing what the compilation represents and what renders the interpretation, there is certain Overlap between the two terms.
A program that translates from a low level language to a higher level is a decompiler. A program that translates between high-level languages is often referred to as 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; Therefore, the compiler implementers invest a significant effort to ensure compiler correction.