A compiler is a special program that processes statements written in a particular programming language and turns them into machine language or "code" that a computer's processor uses. Typically, a programmer writes language statements in a language such as Pascal or C one line at a time using an editor. The file that is created contains what are called the source statements. The programmer then runs the appropriate language compiler, specifying the name of the file that contains the source statements.
USE of compiler
1)
i)When executing (running), the compiler first parses (or analyzes) all of the language statements syntactically one after the other.
*simple words checks whether code written according to lang convention or not!
ii)Lexical analysis breaks the source code text into small pieces called tokens. Each token is a single atomic unit of the language, for instance a keyword, identifier or symbol name. The token syntax is typically a regular language, so a finite state automaton constructed from a regular expression can be used to recognize it.
2)In one or more successive stages or "passes", builds the output code, making sure that statements that refer to other statements are referred to correctly in the final code.
{ Optimization: the intermediate language representation is transformed into functionally equivalent but faster (or smaller) forms. Popular optimizations are inline expansion, dead code elimination, constant propagation, loop transformation, register allocation or even automatic parallelization.}
3)Traditionally, the output of the compilation has been called object code or sometimes an object module. (Note that the term "object" here is not related to object-oriented programming.) The object code is machine code that the processor can process or "execute" one instruction at a time.
{Code generation: the transformed intermediate language is translated into the output language, usually the native machine language of the system. This involves resource and storage decisions, such as deciding which variables to fit into registers and memory and the selection and scheduling of appropriate machine instructions along with their associated addressing modes}
3)Traditionally, the output of the compilation has been called object code or sometimes an object module. (Note that the term "object" here is not related to object-oriented programming.) The object code is machine code that the processor can process or "execute" one instruction at a time.
4)More recently, the Java programming language, a language used in object-oriented programming, has introduced the possibility of compiling output (called bytecode) that can run on any computer system platform for which a Java virtual machine or bytecode interpreter is provided to convert the bytecode into instructions that can be executed by the actual hardware processor. Using this virtual machine, the bytecode can optionally be recompiled at the execution platform by a just-in-time compiler.
Note:: A compiler works with what are sometimes called 3GL and higher-level languages . An assembler works on programs written using a processor's assembler language.
hope this will help
Cheers:)
2007-08-24 08:50:42
·
answer #1
·
answered by Neeraj Yadav♥ 6
·
2⤊
0⤋
A compiler translates high level languages like C++ to assembly or even machine level instructions (at the lowest level: 0's and 1's). When a processor is given an instruction, it only understands specific instructions given in binary. The compiler allows developers the ability to write complex functionality, and memory management at a higher level of abstraction. The compiler will take this abstraction and determine how the machine instructions should be layed out. Sometimes compilers are very good at this, and sometimes they are bad.
2007-08-24 16:11:35
·
answer #2
·
answered by Duncan P 2
·
1⤊
0⤋
A compiler (say, for C++) translates the C++ source code you have written into separate object code that the computer itself can understand, enabling you to run your application.
Some compilers include GCC, Borland C++ Builder, and Visual Studio.
2007-08-24 16:16:34
·
answer #3
·
answered by Teej 3
·
1⤊
0⤋
The compiler will take the code you have written, let say in java and translate it into a file that your machine can run. Basically it translates your code to a language that your computer can understand.
2007-08-24 15:32:29
·
answer #4
·
answered by ckcool192000 3
·
0⤊
0⤋
To create machine code from source code in a way that also relieves some overhead from otherwise interpreted language.
2007-08-24 16:13:11
·
answer #5
·
answered by Andy T 7
·
0⤊
0⤋
when u write a program (lines of code), the compiler of the programing language compiles it, so that it can be executed. it also points out any errors, if any, in the code
2007-08-24 15:33:31
·
answer #6
·
answered by Anonymous
·
0⤊
0⤋
to compile a piece of code into a language that can be understood by the computer
2007-08-24 15:28:30
·
answer #7
·
answered by abd 5
·
1⤊
0⤋
For compiled languages, like C++, compilers make the code in to a program.
For uncompiled, you can just run the code. (Like python.)
2007-08-24 15:30:55
·
answer #8
·
answered by Juggernaut 2
·
0⤊
1⤋