WHAT IS COMPILER IN PROGRAMMING?


COMPILERS

A compiler is a translating program that translates the instruction of a high level language into machine level language. A compiler is so called because it compiles a set of machine language instruction for every program instruction of a high level language.

A program is written by a programmer in a high level language is called a source program.

After this source program has been converted into machine language by a compiler, it is called as an object program.

Note: The source program and the object program are the same program, but at different stages of development.

A compiler can convert only those source programs which have been written in the language for which the computer is meant. For example, a FORTRAN compiler is only capable of converting or translating source programs which have been written in FORTRAN  and , therefore, each machine requires a separate compiler for each language.

While translating a given source program, the compiler analyses each statement in the source program and generates a sequence of machine instructions which , when executed, will precisely carry out the computation specified in the statement. As the compiler analyses each statement, it uncovers certain types of errors. These are referred to as diagnostic errors.

These are the following kinds of errors in  a source program:

  1. Illegal characters.
  2. Illegal combination of characters.
  3. Improper sequencing of instructions in a program.

A source program containing an error diagnosed by the compiler will not be compiled into an object program. The compiler will print out a suitable message indicating this, with a list of coded error messages which indicate the type of errors committed.

A compiler cannot diagnose logical errors. It can only diagnose grammatical(syntax) errors in the program. For example, if one has wrongly punched -55 as the age of a person, when he actually intended +55, programs containing such errors will be successfully compiled and errors are detected only after the program is executed and the result produced does not tally with the desired result.

Leave a comment