What is a compiler? Could they exemplify? And what is the difference between compiler and grammar?
What is a compiler? Could they exemplify? And what is the difference between compiler and grammar?
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 run afterwards.
A grammar is the set of syntax rules used to validate the source code of a particular programming language; each language has its grammar.
One of the compiler's tasks is to check if the source code passed to it complies with language syntax rules. If the source code has syntax errors, the compiler warns you with error messages.
For some languages, instead of a compiler, there is an interpreter: it has the same function as a compiler (generate machine code), but generates the machine code and executes it on time, without writing an executable. JavaScript, for example, is an interpreted language. Several languages, such as Java, PHP and C #, take a hybrid approach, compiling the source code for a simpler intermediate language, and interpreting the program in that language.
More information on Wikipedia:
Compiler is software that takes a source file and parses the source code synthase. If the source code is right, it will transform the source code into machine language (or an intermediate language that will be interpreted, as in the case of Java). If you have any problems the compiler warns you about the problem found in the source code