What is a compiler?

Asked

Viewed 2,656 times

-5

What is a compiler? Could they exemplify? And what is the difference between compiler and grammar?

2 answers

4

A compiler is a program that receives source code, written in a programming language, and returns a program in another language, usually an executable, in machine language, to be executed later.

A grammar is the set of syntax rules used to validate the source code of a given programming language; each language has its grammar.

One of the compiler’s tasks is to verify that the source code passed to it meets the language’s syntax rules. If the source code has syntax errors, the compiler warns with error messages.

For some languages, instead of a compiler, there is an interpreter: it has the same function as a compiler (generating machine code), but generates the machine code and executes it on time, without saving an executable. Javascript, for example, is an interpreted language. Several languages, such as Java, PHP and C#, adopt a hybrid approach, compiling the source code for a simpler intermediate language, and interpreting the program in that language.

More information on Wikipedia (in English):

0

Compiler is software that takes a source file and analyzes the syntax of the source code. If the source code is right, it will turn the source code into a machine language (or an intermediate language that will be interpreted, as in the case of Java). If you have a problem the compiler warns about the problem found in the source code

Browser other questions tagged

You are not signed in. Login or sign up in order to post.