related topics
{math, number, function}
{system, computer, user}
{language, word, form}

In computer science, a preprocessor is a program that processes its input data to produce output that is used as input to another program. The output is said to be a preprocessed form of the input data, which is often used by some subsequent programs like compilers. The amount and kind of processing done depends on the nature of the preprocessor; some preprocessors are only capable of performing relatively simple textual substitutions and macro expansions, while others have the power of fully-fledged programming languages.

A common example from computer programming is the processing performed on source code before the next step of compilation. In some computer languages (e.g., C and PL/I ) there is a phase of translation known as preprocessing.


Lexical preprocessors

Lexical preprocessors are the lowest-level of preprocessors, insofar as they only require lexical analysis, that is, they operate on the source text, prior to any parsing, by performing simple substitution of tokenized character sequences for other tokenized character sequences, according to user-defined rules. They typically perform macro substitution, textual inclusion of other files, and conditional compilation or inclusion.

C preprocessor

The most common example of this is the C preprocessor, which takes lines beginning with '#' as directives. Because it knows nothing about the underlying language, its use has been criticized and many of its features built directly into other languages. For example, macros replaced with aggressive inlining and templates, includes with compile-time imports (this requires the preservation of type information in the object code, making this feature impossible to retrofit into a language); conditional compilation is effectively accomplished with if-then-else and dead code elimination in some languages.

Full article ▸

related documents
Abstraction (computer science)
Chaitin's constant
Breadth-first search
Natural number
Goldbach's conjecture
Homology (mathematics)
Probability density function
Euclidean space
Insertion sort
Cyclic redundancy check
Linear independence
Analysis of algorithms
Type theory
L'Hôpital's rule
Glossary of topology
Euclidean algorithm
Heine–Borel theorem
Wiener process
Axiom schema of replacement
Pushdown automaton
Complete metric space
Presentation of a group
Standard ML
Binary relation
Context-free grammar