Currently taking a compilers module and am an absolute beginner to compilation. Can anybody help clear this question up for me?
-
Try asking this in the community cs.stackexchange.com That is probably a better place. – Einar Sundgren Mar 25 '15 at 22:20
-
Thanks, will bear that in mind! – Rafi Shakouri Mar 25 '15 at 23:15
2 Answers
It doesn't have to be.
Of course, the use of the word "preprocessor" is implying that it is a step previous to processing proper, and that's certainly true for the C preprocessor, which was originally a separate program (and still is in some implementations).
However, the actions performed by the preprocessor -- textually including other files; macro expansion; conditional compilation -- could theoretically be performed during compilation, and some languages are defined that way. (And many languages simply don't implement these features at all, leaving them to be done by external utilities.)

- 234,347
- 28
- 237
- 341
-
Cobol is a good example of a language with built-in 'pre'-processing, with the COPY, REPLACE, and COPY REPLACING verbs. The processing is typically located between the scanner and the compiler. – user207421 Mar 26 '15 at 00:09
The preprocessing involves transformation of source code that is not directly linked to the language to compile. The product of the preprocessor is again source code.
source --->[ preprocessor ]--> modified source -->[ compiler ]--> object -->[ linker ]--> executable
Generally it works by providing some subsitution rules on the text of the source code.

- 68,716
- 7
- 72
- 138