A compiler is a program that acts as a translator which translates human readable code into machine code which is exectubale by the computer. Syntax plays a big role in the function of a compilersince the compiler does not know the mistake that you have made syntactically and therefore reports an error message. The human understandable code must follow the rules that govern syntax and then the compiler can compile your source code for you. A compiler is just a program and is not a program which can fix your mistakes.
The first process that the compiler goes through is lexical analysis, where the compiler reads a stream of characters (from a source code) and generates some lexical tokens. The next process is syntactical analysis where the output from the lexical analyzer comes to the syntactical analyzer and starts to check the information and see if it agrees with the rules that govern syntax. From here onwards, if the information is not valid, a message will be sent to the user to fix the issue. However, if the information is valid, it goes to the next process which is generating machine code. Some programming languages such as Pascal get away with reading the source code once and generate machine code, but two reads of the code are required in most languages. The last process is the toughest for the compiler since there are CPUs which speed up the processing with caches. Finally, the code is executed and the output is screened to the user. Compilers usually generate code into object files, which are then linked by a Linker program.
The different phases that a compiler goes through to compile the source code.
An interpretor is basically a program where it gets the instructions from the program source and converts it to machine code and then it grabs the next instruction from the source to repeat the process. The disadvantage is that interpreted programs run much slower than compiled programs about 5 to 10 times slower as every line of the code thas to be read more than once and processed more than once. Interpreting generally means someone who interprets information to another person for example a person who interprets another language into their native language and tells another person what someone said in their native language. An interpretor works almost exactly the same, for example translating the source code line by line into machine code and then outputing a result.
The phases that an interpretor takes to successfully output the information.