Language Translator/Language Processor
A translator is a computer program that
translates a program written in a given programming language into a
functionally equivalent program in a different language. Depending on the
translator, this may involve changing or simplifying the program flow, without
losing the essence of the program, thereby producing a functionally equivalent
program.
A program is a set of instructions for
performing a particular task. These instructions are just like English words.
The computer interprets the instructions as 1's and 0's. A program can be
written in assembly language as well as in high-level language. This written
program is called the source program. The source program is to be converted to
the machine language, which is called an object program. A translator is
required for such a translation.
Program translator translates source code of
programming language into machine language-instruction code. Generally,
computer programs are written in languages like COBOL, C, BASIC and ASSEMBLY
LANGUAGE, which should be translated into machine language before execution.
Programming language translators are classified as follows. A list of
translators is given in fig. below:
Translators are as follows.
- Assembler
- Compiler
- Interpreter
Assembler:
An assembler translates the
symbolic codes of programs of an assembly language into machine language
instructions (Figure). The symbolic language is translated to the machine
code in the ratio of one is to one symbolic instructions to one machine code
instructions. Such types of languages are called low-level languages. The
assembler programs translate the low-level language to the machine code. The
translation job is performed either manually or with a program called
assembler.
In hand assembly, the programmer uses the set of instructions
supplied by the manufacturer. In this case, the hexadecimal code for the
mnemonic instruction is searched from the code sheet. This procedure is tedious
and time-consuming. Alternate solution to this is the use of assemblers. The
program called assembler provides the codes of the mnemonics. This process is
fast and facilitates the user in developing the program speedily.
Compiler:
Compilers are the translators,
which translate all the instructions of the program into machine codes, which
can be used again and again (see Figure). The program, which is to be
translated, is called the source program and after translation the object code
is generated. The source program is input to the compiler. The object code is
output for the secondary storage device.
The entire program will be read by the
compiler first and generates the object code. However, in interpreter each line
is executed and object code is provided. M-BASIC is an example of an
interpreter. High-level languages such as C, C++ and Java compilers are
employed. The compiler displays the list of errors and warnings for the
statements violating the syntax rules of the language. Compilers also have the ability
of linking subroutines of the program.
Interpreter:
Interpreters also come in the
group of translators. It helps the user to execute the source program with a
few differences as compared to compilers. The source program is just like
English statements in both interpreters and compilers. The interpreter
generates object codes for the source program. Interpreter reads the program
line by line, whereas in compiler the entire program is read by the compiler,
which then generates the object codes.
Interpreter directly executes the
program from its source code. Due to this, every time the source code should be
inputted to the interpreter. In other words, each line is converted into the
object codes. It takes very less time for execution because no intermediate
object code is generated.
0 comments:
Post a Comment