What is Translator? Explain the type of translator.

 What is Translator?

A program written in a high-level language is called source code. Translators are needed to convert the source code (HLL) into machine code.

A translator takes a program written in the source language as input and converts it into a program in the target language (machine language) as output. It also detects and reports the error during translation.

The roles of the translator are:

• Translating the high-level language program input into an equivalent machine language program.

• Providing diagnostic messages wherever the programmer violates the specification of the high-level language program.

The different types of translators are as follows:

Compiler

The compiler is a translator that is used to convert programs in a high-level language to a low-level language. It translates the entire program and also reports the errors in the source program encountered during the translation.

Compiler


Interpreter

An interpreter is a translator that is used to convert programs in high-level language(source code)  to low-level language (machine language). An interpreter translates line by line and reports the error once it is encountered during the translation process.

It directly executes the operations specified in the source program when the input is given by the user. It gives better error diagnostics than a compiler.

 Interpreter

 



Assembler

An assembler is a translator which is used to translate the assembly language code into machine language code.

Assembler

            


 

 Differences between compiler and interpreter

 



No comments

Powered by Blogger.