<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://debianws.lexgopc.com/wiki143/index.php?action=history&amp;feed=atom&amp;title=Preprocessor</id>
	<title>Preprocessor - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://debianws.lexgopc.com/wiki143/index.php?action=history&amp;feed=atom&amp;title=Preprocessor"/>
	<link rel="alternate" type="text/html" href="http://debianws.lexgopc.com/wiki143/index.php?title=Preprocessor&amp;action=history"/>
	<updated>2026-05-04T17:47:11Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.1</generator>
	<entry>
		<id>http://debianws.lexgopc.com/wiki143/index.php?title=Preprocessor&amp;diff=54231&amp;oldid=prev</id>
		<title>imported&gt;Citation bot: Added website. | Use this bot. Report bugs. | Suggested by Dominic3203 | Category:Programming language implementation | #UCB_Category 24/50</title>
		<link rel="alternate" type="text/html" href="http://debianws.lexgopc.com/wiki143/index.php?title=Preprocessor&amp;diff=54231&amp;oldid=prev"/>
		<updated>2024-10-14T17:44:58Z</updated>

		<summary type="html">&lt;p&gt;Added website. | &lt;a href=&quot;/wiki143/index.php?title=En:WP:UCB&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;En:WP:UCB (page does not exist)&quot;&gt;Use this bot&lt;/a&gt;. &lt;a href=&quot;/wiki143/index.php?title=En:WP:DBUG&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;En:WP:DBUG (page does not exist)&quot;&gt;Report bugs&lt;/a&gt;. | Suggested by Dominic3203 | &lt;a href=&quot;/wiki143/index.php?title=Category:Programming_language_implementation&quot; title=&quot;Category:Programming language implementation&quot;&gt;Category:Programming language implementation&lt;/a&gt; | #UCB_Category 24/50&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{short description|Program that processes input for another program}}&lt;br /&gt;
{{more citations needed|date=February 2013}}&lt;br /&gt;
{{Data transformation}}&lt;br /&gt;
&lt;br /&gt;
In [[computer science]], a &amp;#039;&amp;#039;&amp;#039;preprocessor&amp;#039;&amp;#039;&amp;#039; (or &amp;#039;&amp;#039;&amp;#039;precompiler&amp;#039;&amp;#039;&amp;#039;)&amp;lt;ref&amp;gt;{{cite web&lt;br /&gt;
   |url=https://www.ibm.com/docs/zosbasics/com.ibm.zos.zappldev/zappldev_111.htm&lt;br /&gt;
   |title=What is a precompiler?|website=[[IBM]] }}&amp;lt;/ref&amp;gt; is a [[Computer program|program]] that processes its input data to produce output that is used as input in another program. The output is said to be a &amp;#039;&amp;#039;&amp;#039;preprocessed&amp;#039;&amp;#039;&amp;#039; form of the input data, which is often used by some subsequent programs like [[compiler]]s. 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 (computer science)|macro]] expansions, while others have the power of full-fledged [[programming language]]s.&lt;br /&gt;
&lt;br /&gt;
A common example from [[computer programming]] is the processing performed on [[source code]] before the next step of compilation.&lt;br /&gt;
In some [[computer language]]s (e.g., [[C (programming language)|C]] and [[PL/I (programming language)|PL/I]]) there is a phase of [[compiler|translation]] known as &amp;#039;&amp;#039;preprocessing&amp;#039;&amp;#039;. It can also include macro processing, file inclusion and language extensions.&lt;br /&gt;
&lt;br /&gt;
==Lexical preprocessors==&lt;br /&gt;
Lexical preprocessors are the lowest-level of preprocessors as they only require [[lexical analysis]], that is, they operate on the source text, prior to any [[parser|parsing]], by performing simple substitution of [[Lexical analysis|tokenized]] character sequences for other tokenized character sequences, according to user-defined rules. They typically perform [[macro substitution]], [[header file|textual inclusion]] of other files, and conditional compilation or inclusion.&lt;br /&gt;
&lt;br /&gt;
===C preprocessor===&lt;br /&gt;
{{main|C preprocessor}}&lt;br /&gt;
The most common example of this is the [[C preprocessor]], which takes lines beginning with &amp;#039;#&amp;#039; as [[Directive (programming)|directives]].&lt;br /&gt;
The C preprocessor does not expect its input to use the syntax of the C language.&lt;br /&gt;
Some languages take a different approach and use built-in language features to achieve similar things. For example:&lt;br /&gt;
* Instead of macros, some languages use aggressive inlining and templates.&lt;br /&gt;
* Instead of includes, some languages use compile-time imports that rely on type information in the object code.&lt;br /&gt;
* Some languages use &amp;lt;code&amp;gt;if-then-else&amp;lt;/code&amp;gt; and [[dead code elimination]] to achieve [[conditional compilation]].&lt;br /&gt;
&lt;br /&gt;
===Other lexical preprocessors===&lt;br /&gt;
Other lexical preprocessors include the general-purpose [[m4 (language)|m4]], most commonly used in cross-platform build systems such as [[autoconf]], and [[general purpose macro processor|GEMA]], an open source macro processor which operates on patterns of context.&lt;br /&gt;
&lt;br /&gt;
==Syntactic preprocessors==&lt;br /&gt;
Syntactic preprocessors were introduced with the [[Lisp programming language|Lisp]] family of languages. Their role is to transform syntax trees according to a number of user-defined rules. For some programming languages, the rules are written in the same language as the program (compile-time reflection). This is the case with [[Lisp programming language|Lisp]] and [[OCaml]]. Some other languages rely on a fully external language to define the transformations, such as the [[XSLT]] preprocessor for [[XML]], or its statically typed counterpart CDuce.&lt;br /&gt;
&lt;br /&gt;
Syntactic preprocessors are typically used to customize the syntax of a language, extend a language by adding new primitives, or embed a [[domain-specific programming language]] (DSL) inside a general purpose language.&lt;br /&gt;
&lt;br /&gt;
===Customizing syntax===&lt;br /&gt;
A good example of syntax customization is the existence of two different syntaxes in the [[OCaml|Objective Caml]] programming language.&amp;lt;ref&amp;gt;[http://caml.inria.fr/pub/docs/manual-camlp4/manual007.html The Revised syntax] from The Caml language website&amp;lt;/ref&amp;gt; Programs may be written indifferently using the &amp;quot;normal syntax&amp;quot; or the &amp;quot;revised syntax&amp;quot;, and may be pretty-printed with either syntax on demand.&lt;br /&gt;
&lt;br /&gt;
Similarly, a number of programs written in [[OCaml]] customize the syntax of the language by the addition of new operators.&lt;br /&gt;
&lt;br /&gt;
===Extending a language===&lt;br /&gt;
The best examples of language extension through macros are found in the [[Lisp programming language|Lisp]] family of languages. While the languages, by themselves, are simple dynamically typed functional cores, the standard distributions of [[Scheme (programming language)|Scheme]] or [[Common Lisp]] permit imperative or object-oriented programming, as well as static typing. Almost all of these features are implemented by syntactic preprocessing, although it bears noting that the &amp;quot;macro expansion&amp;quot; phase of compilation is handled by the compiler in Lisp. This can still be considered a form of preprocessing, since it takes place before other phases of compilation.&lt;br /&gt;
&lt;br /&gt;
===Specializing a language===&lt;br /&gt;
One of the unusual features of the [[Lisp programming language|Lisp]] family of languages is the possibility of using macros to create an internal DSL. Typically, in a large [[Lisp programming language|Lisp]]-based project, a module may be written in a variety of such [[minilanguage]]s, one perhaps using a [[SQL]]-based dialect of [[Lisp programming language|Lisp]], another written in a dialect specialized for [[Graphical user interface|GUI]]s or pretty-printing, etc. [[Common Lisp]]&amp;#039;s standard library contains an example of this level of syntactic abstraction in the form of the LOOP macro, which implements an Algol-like minilanguage to describe complex iteration, while still enabling the use of standard Lisp operators.&lt;br /&gt;
&lt;br /&gt;
The [[MetaOCaml]] preprocessor/language provides similar features for external DSLs. This preprocessor takes the description of the semantics of a language (i.e. an interpreter) and, by combining compile-time interpretation and code generation, turns that definition into a compiler to the [[OCaml]] programming language—and from that language, either to bytecode or to native code.&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Please provide an authoritative cite defining &amp;quot;general purpose(sic) preprocessor&amp;quot; and&lt;br /&gt;
&amp;quot;general purpose template engine&amp;quot; or else remove this.&lt;br /&gt;
&lt;br /&gt;
==Preprocessors as template engines==&lt;br /&gt;
Any &amp;quot;general purpose preprocessor&amp;quot;, like [[M4 (computer language)|M4]], can be used as a [[template processor|template engine]].&lt;br /&gt;
&lt;br /&gt;
&amp;quot;General purpose preprocessors&amp;quot; and &amp;quot;general purpose template engines&amp;quot; are the same kind of softwares.&lt;br /&gt;
--~~~&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==General purpose preprocessor==&lt;br /&gt;
{{main|General-purpose macro processor}}&lt;br /&gt;
Most preprocessors are specific to a particular data processing task (e.g., [[compilers|compiling]] the C language). A preprocessor may be promoted as being &amp;#039;&amp;#039;general purpose&amp;#039;&amp;#039;, meaning that it is not aimed at a specific usage or programming language, and is intended to be used for a wide variety of text processing tasks.&lt;br /&gt;
&lt;br /&gt;
{{see also|C preprocessor#Other uses}}&lt;br /&gt;
[[M4 (computer language)|M4]] is probably the most well known example of such a general purpose preprocessor, although the C preprocessor is sometimes used in a non-C specific role. Examples:&lt;br /&gt;
* using C preprocessor for [[JavaScript]] preprocessing.&amp;lt;ref&amp;gt;Show how to use [[C preprocessor|C-preprocessor]] on JavaScript files. [https://web.archive.org/web/20080116034428/http://blog.inetoffice.com/?p=12 &amp;quot;JavaScript is Not Industrial Strength&amp;quot;] &amp;#039;&amp;#039;by T. Snyder&amp;#039;&amp;#039;.&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;{{cite web |title=The C Preprocessor in Javascript? |url=http://www.nongnu.org/espresso/js-cpp.html |website=espresso-mode}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
* using C preprocessor for [[devicetree]] processing within the [[Linux kernel]].&amp;lt;ref&amp;gt;{{Cite web|url=https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git/commit/?id=b40b25fff8205dd18124d8fc87b2c9c57f269b5f|title=Kernel/Git/Stable/Linux.git - Linux kernel stable tree}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
* using [[M4 (computer language)|M4]] &amp;lt;small&amp;gt;(see on-article example)&amp;lt;/small&amp;gt; or C preprocessor&amp;lt;ref&amp;gt;Show how to use [[C preprocessor|C-preprocessor]] as [[template processor|template engine]].&lt;br /&gt;
[https://jkorpela.fi/html/cpre.html &amp;quot;Using a C preprocessor as an HTML authoring tool&amp;quot;] &amp;#039;&amp;#039;by J. Korpela&amp;#039;&amp;#039;, 2000.&amp;lt;/ref&amp;gt; as a [[Web template system|template engine]], to [[HTML]] generation.&lt;br /&gt;
* [[imake]], a [[make (software)|make]] interface using the C preprocessor, written for the [[X Window System]] but now deprecated in favour of [[automake]].&lt;br /&gt;
* [[grompp]], a preprocessor for simulation input files for [[GROMACS]] (a fast, free, open-source code for some problems in [[computational chemistry]]) which calls the system C preprocessor (or other preprocessor as determined by the simulation input file) to parse the topology, using mostly the #define and #include mechanisms to determine the effective topology at grompp run time.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
* {{annotated link|Directive (programming)}}&lt;br /&gt;
* {{annotated link|Metaprogramming}}&lt;br /&gt;
* {{annotated link|Macro (computer science)|Macros}}&lt;br /&gt;
* {{annotated link|Source-to-source compiler|aka=Transpiler}}&lt;br /&gt;
* {{annotated link|Sass (stylesheet language)}}&lt;br /&gt;
* {{annotated link|Stylus (stylesheet language)}}&lt;br /&gt;
* {{annotated link|Less (stylesheet language)}}&lt;br /&gt;
* {{annotated link|Snippet (programming)}}&lt;br /&gt;
* {{annotated link|Template processor|Template engine}}&lt;br /&gt;
* The {{annotated link|C preprocessor}}&lt;br /&gt;
* The {{annotated link|camlp4|OCaml preprocessor-pretty-printer}}&lt;br /&gt;
* The {{annotated link|PL/I preprocessor}}&lt;br /&gt;
* The {{annotated link|Windows software trace preprocessor}}&lt;br /&gt;
* {{annotated link|General-purpose macro processor}}&lt;br /&gt;
&amp;lt;!-- open link&lt;br /&gt;
* The [[MetaOCaml]] metaprogramming language&lt;br /&gt;
* The [[Epigram (metaprogramming language)|Epigram]] metaprogramming language&lt;br /&gt;
* [[Oracle Pro*C]]&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
{{reflist}}&lt;br /&gt;
&lt;br /&gt;
==External links==&lt;br /&gt;
{{Wiktionary|preprocessor}}&lt;br /&gt;
* [https://web.archive.org/web/20090214092527/http://lispm.dyndns.org/news?ID=NEWS-2005-07-08-1 DSL Design in Lisp]&lt;br /&gt;
* [http://www.paulgraham.com/progbot.html Programming from the bottom up]&lt;br /&gt;
* The [https://logological.org/gpp Generic PreProcessor]&lt;br /&gt;
* Gema, the [http://gema.sourceforge.net General Purpose Macro Processor]&lt;br /&gt;
* The [[PIKT]] [http://pikt.org/pikt/ref/ref.4.piktc.html piktc] [http://pikt.org/pikt/ref/ref.3.html text, script, and configuration file preprocessor]&lt;br /&gt;
* [https://goetzpf.bitbucket.io/pyexpander pyexpander, a python based general purpose macro processor]&lt;br /&gt;
* [http://freshmeat.net/projects/minimac-macro-processor minimac, a minimalist macro processor]&lt;br /&gt;
* [https://github.com/raydac/java-comment-preprocessor Java Comment Preprocessor]&lt;br /&gt;
&lt;br /&gt;
{{Authority control}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Programming language implementation]]&lt;/div&gt;</summary>
		<author><name>imported&gt;Citation bot</name></author>
	</entry>
</feed>