I think it would have been better to use the term source-to-source translator instead of "preprocessors" which makes it ambiguous in meaning , but it ain't any wrong to use it either.
Basically , A compiler is a computer program translates source code from a high-level programming language to a lower level language (e.g., assembly language or machine code).But the document in the question says :
Historically, compilers for many languages, including C++ and Fortran, have been implemented as “preprocessors” which emit another high level language such as C.
As per this description , it can be said that earlier , the compilers were implemented as source-to-source translator . A translator is also a form of preprocessor but its different from the preprocessor used in a program.
A translator is a computer program that translates a program written in a given programming language into a functionally equivalent program in a different language.
Now, coming to preprocessor used in a program , lets take an example :
#include <stdio.h>// a PREPROCESSOR directive
A preprocessor is a program that processes a source file before the main compilation takes place,( similar to a translator ) but the difference lies in the fact that HERE it handles directives whose names begin with #.
Here #include
is a directive. This directive causes the preprocessor to add the contents of the stdio.h
file to your
program.This is a typical preprocessor action: adding or replacing text in the source code
before it’s compiled.