John,
>> The definitions I always used were that an interpreter converted raw source
>> or tokenized code at run-time into machine instructions. A compiler linked
>> in library modules and converted source into machine code so that very
>> little or no intepreting was done at run-time.
Consider the statement x = 10 * a - 1
In a compiler, we want the target CPU to execute the assignment at execution time. However, the code generator doesn't do any of the maths, it only generates the object code that will allow the CPU to do it when the code is executed.
An interpreter on the other hand would not produce object code for the CPU, it may produce p-code but this will not get executed by the CPU. The maths is computed immediately, as the parsing is going on. The p-code side of things is merely to take out some of the hard work that goes on like lexical analysis - speed is the keyword in interpreting statements, so p-code helps us do things like token reduction (remember in GWBasic you could use ? instead of print).
The confusion comes from the fact that a compiler is still a compiler even though it may not generate native re-locatable object code! If it generates native code ie. machine code and data that a CPU can understand (direct equivalents for the code and data bytes that the CPU uses) then its not an interpreter.
Précédent
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement