|
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. Computer science, or computing science, is the study of the theoretical foundations of information and computation and their implementation and application in computer systems. ...
A computer program is a collection of instructions that describe a task, or set of tasks, to be carried out by a computer. ...
This article is about the computing term. ...
A macro in computer science is an abstraction, that defines how a certain input pattern is replaced by an output pattern according to a defined set of rules. ...
A programming language is an artificial language that can be used to control the behavior of a machine, particularly a computer. ...
A common example from computer programming is the processing performed on source code before the next step of compilation. In some computer languages (eg, C) there is a phase of translation known as preprocessing. notice:If doing a reaserch project on this you might want to change the subject! Why? From here you go to steps, from steps you go to how to do each one, then you go farther and farther until you get to computers and then to Internet causing a lot...
Source code (commonly just source or code) is any series of statements written in some human-readable computer programming language. ...
The term computer language is a more expansive and alternate term for the more commonly-used term programming language. ...
C is a general-purpose, procedural, imperative computer programming language developed in 1972 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system. ...
This article is about the computing term. ...
Lexical pre-processors
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. Lexical analysis is the processing of an input sequence of characters (such as the source code of a computer program) to produce, as output, a sequence of symbols called lexical tokens, or just tokens. For example, lexers for many programming languages convert the character sequence 123 abc into two tokens...
A parser is a computer program or a component of a program that analyses the grammatical structure of an input, with respect to a given formal grammar, a process known as parsing. ...
Lexical analysis is the process of taking an input string of characters (such as the source code of a computer program) and producing a sequence of symbols called lexical tokens, or just tokens, which may be handled more easily by a parser. ...
A macro in computer science is an abstraction, whereby a certain textual pattern is replaced according to a defined set of rules. ...
Pre-processing in C/C++ The most widely used lexical preprocessor is CPP, the C preprocessor, used pervasively in C and its descendant, C++. This preprocessor is used to provide the usual set of preprocessing services The C preprocessor (cpp) is the preprocessor for the C programming language. ...
C is a general-purpose, procedural, imperative computer programming language developed in 1972 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system. ...
C++ (pronounced see plus plus, IPA: ) is a general-purpose, high-level programming language with low-level facilities. ...
Inclusion The most common use of the C preprocessor is the #include "..." or #include <...> directive, which copies the full content of a file into the current file, at the point at which the directive occurs. These files usually (almost always) contain interface definitions for various library functions and data types, which must be included before they can be used; thus, the #include directive usually appears at the head of the file. The files so included are called "header files" for this reason. Some examples include <math.h> and <stdio.h> from the standard C library, providing mathematical and input/output functions, respectively. While this use of a preprocessor for code reuse is simple, it is also slow, rather inefficient and requires the additional use of conditional compilation to avoid multiple inclusions of a given header file. Since the 1970s, faster, safer and more efficient alternatives to reuse by file inclusion have been known and used by the programming language community, and implemented in most programming languages: Java and Common Lisp have packages, Pascal has units, Modula, OCaml, Haskell or Python have modules, and D, designed as a replacement of C and C++, has imports. Java is an object-oriented programming language developed by Sun Microsystems in the early 1990s. ...
Common Lisp, commonly abbreviated CL, is a dialect of the Lisp programming language, standardised by ANSI X3. ...
Pascal is an imperative computer programming language, developed in 1970 by Niklaus Wirth as a language particularly suitable for structured programming. ...
In the mid-1970s, after designing the Pascal programming language, Niklaus Wirth began experimenting with program concurrency and modularization, which led to the design of the Modula programming language. ...
Objective Caml (OCaml) is a general-purpose programming language descended from the ML family, created by Xavier Leroy, Jérôme Vouillon, Damien Doligez, Didier Rémy and others in 1996. ...
Haskell is a standardized pure functional programming language with non-strict semantics, named after the logician Haskell Curry. ...
Python is a programming language created by Guido van Rossum in 1990. ...
D is an object-oriented, imperative system programming language designed by Walter Bright of Digital Mars as a re-engineering of C/C++. He has done this by re-designing many C++ features, and borrowing ideas from other programming languages. ...
Macros Macros are commonly used in C to define small snippets of code. During the preprocessing phase, each macro call is replaced, in-line, by the corresponding macro definition. If the macro has parameters, they are substituted into the macro body during expansion; thus, a C macro can mimic a C function. The usual reason for doing this is to avoid the overhead of a function call in simple cases, where the code is lightweight enough that function call overhead has a significant impact on performance. It has been suggested that this article or section be merged with Snippet management. ...
For instance, #define max(a,b) a>b?a:b defines the macro max, taking two arguments a and b. This macro may be called like any C function, using identical syntax. Therefore, after preprocessing, z = max(x,y); becomes z = x>y?x:y; While this use of macros is very important for C, for instance to define type-safe generic data-types or debugging tools, it is also slow, rather inefficient, and may lead to a number of pitfalls. For instance, if f and g are two functions, calling z = max(f(), g()); will not evaluate f()once and g() once, and place the highest value in z as one may believe. Rather, one of the functions will be evaluated twice. If that function has side effects, this is usually not the expected behavior. C macros are capable of mimicking functions, creating new syntax within some limitations, as well as expanding into arbitrary text (although the C compiler will require that text to be valid C source code, or else comments), but they have some limitations as a programming construct. Macros which mimic functions, for instance, can be called like real functions, but a macro cannot be passed to another function using a function pointer, since the macro itself has no address. More modern languages typically do not use this form of metaprogramming through macro expansion of character strings, rather relying on either automatic or manual inlining of functions and methods, and other abstraction techniques such as templates, generic functions, or parametric polymorphism. In particular, inline functions overcome one of the major disadvantages of macros in modern C and C++ implementations, since an inline function provides the macro's advantage of avoiding the overhead of a function call, while its address can still be stored in a function pointer for indirect calls or use in parameters. Also, the problem of multiple evaluation, seen above in the max macro, would not occur in an inlined function. Metaprogramming is the writing of programs that write or manipulate other programs (or themselves) as their data or that do part of the work that is otherwise done at runtime during compile time. ...
In computer programming, templates are a feature of the C++ programming language that allow code to be written without consideration of the data type with which it will eventually be used. ...
In certain systems for object-oriented programming such as the Common Lisp Object System and Dylan, a generic function is an entity made up of all methods having the same name. ...
Polymorphism refers to features of various programming languages which allow a single piece of source code to operate on a variable whose type is not fixed. ...
In computer science, an inline function is a programming language construct used to suggest to a compiler that a particular function be subjected to in-line expansion; that is, it suggests that the compiler insert the complete body of the function in every context where that function is used. ...
Conditional compilation -
The C preprocessor also offers conditional compilation. This permits having different versions of a same code in the same source file. Typically, this is used to customize the program with respect to the compilation platform, the status (debugging code can be "defined out" in production code), as well as to ensure that header files are only included once. In the C programming language, an #include guard is a particular construct used to avoid the problem of double inclusion when dealing with the #include directive, as demonstrated in the following sample C code: // Double inclusion File grandfather. ...
In this common case, the programmer will use a construct like this: #ifndef FOO_H #define FOO_H ...(header file code)... #endif This "macro guard" protects the header file from duplicate inclusion by testing for the existence of a macro which, by convention, has the same name as the header file itself. The definition of the FOO_H macro takes place when the header file is first processed by CPP. Thereafter, if that header file is included again, FOO_H will already be defined, causing the preprocessor to skip the entirety of the header file's text. Preprocessor conditionals can be used in more complex ways, as below: #ifdef x ... #else ... #endif or #if x ... #else ... #endif This technique is often used in system header files to test for various features whose definition can change depending on the platform; for example, the GNU C Library uses "feature-test" macros to ensure that operating system and hardware differences are properly handled, while maintaining the same portable interface. Glibc is the GNU projects C standard library. ...
Once again, most modern programming languages discard this feature, rather relying on traditional if...then...else... flow control operators, leaving to the compiler the task of removing useless code from the executable.
Other lexical pre-processors Other lexical preprocessors include the general-purpose m4, most commonly used in cross-platform build systems such as autoconf, and GEMA, an open source macro processor which operates on patterns of context. The title given to this article is incorrect due to technical limitations. ...
processing Autoconf is a tool for producing shell scripts that automatically configure software source code packages to adapt to many kinds of UNIX-like systems. ...
Syntactic pre-processors Syntactic preprocessors were introduced with the 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 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. Lisp is a family of computer programming languages with a long history and a distinctive fully-parenthesized syntax. ...
Lisp is a family of computer programming languages with a long history and a distinctive fully-parenthesized syntax. ...
Objective Caml (OCaml) is a general-purpose programming language descended from the ML family, created by Xavier Leroy, Jérôme Vouillon, Damien Doligez, Didier Rémy and others in 1996. ...
...
The Extensible Markup Language (XML) is a W3C-recommended general-purpose markup language that supports a wide variety of applications. ...
CDuce is an XML-oriented functional language, which extends XDuce in a few directions. ...
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 inside a general purpose language. A domain-specific programming language (domain-specific language, DSL) is a programming language designed to be useful for a specific set of tasks. ...
Customizing syntax A good example of syntax customization is the existence of two different syntaxes in the Objective Caml programming language. Programs may be written indifferently using the "normal syntax" or the "revised syntax", and may be pretty-printed with either syntax on demand. Objective Caml (OCaml) is a general-purpose programming language descended from the ML family, created by Xavier Leroy, Jérôme Vouillon, Damien Doligez, Didier Rémy and others in 1996. ...
Similarly, a number of programs written in OCaml customize the syntax of the language by the addition of new operators. Objective Caml (OCaml) is a general-purpose programming language descended from the ML family, created by Xavier Leroy, Jérôme Vouillon, Damien Doligez, Didier Rémy and others in 1996. ...
Extending a language The best examples of language extension through macros are found in the Lisp family of languages. While the languages, by themselves, are simple dynamically-typed functional cores, the standard distributions of 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 "macro expansion" 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. Lisp is a family of computer programming languages with a long history and a distinctive fully-parenthesized syntax. ...
The Scheme programming language is a functional programming language and a dialect of Lisp. ...
Common Lisp, commonly abbreviated CL, is a dialect of the Lisp programming language, standardised by ANSI X3. ...
Similarly, statically-checked, type-safe regular expressions or code generation may be added to the syntax and semantics of OCaml through macros, as well as micro-threads (also known as coroutines or fibers), monads or transparent XML manipulation. A regular expression (abbreviated as regexp, regex or regxp) is a string that describes or matches a set of strings, according to certain syntax rules. ...
This article or section does not cite its references or sources. ...
Objective Caml (OCaml) is a general-purpose programming language descended from the ML family, created by Xavier Leroy, Jérôme Vouillon, Damien Doligez, Didier Rémy and others in 1996. ...
Coroutines are program components like subroutines. ...
A fiber in computer science is a term for a particularly lightweight thread of execution. ...
Some functional programming languages make use of monads[1] [2] to structure programs which include operations that must be executed in a specific order. ...
Specializing a language One of the unusual features of the Lisp family of languages is the possibility of using macros to create an internal Domain-Specific Programming Language. Typically, in a large Lisp-based project, a module may be written in a variety of such minilanguages, one perhaps using a SQL-based dialect of Lisp, another written in a dialect specialized for GUIs or pretty-printing, etc. Common Lisp'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. Lisp is a family of computer programming languages with a long history and a distinctive fully-parenthesized syntax. ...
A domain-specific programming language (domain-specific language, DSL) is a programming language designed to be useful for a specific set of tasks. ...
Lisp is a family of computer programming languages with a long history and a distinctive fully-parenthesized syntax. ...
SQL (commonly expanded to Structured Query Language â see History for the terms derivation) is the most popular computer language used to create, retrieve, update and delete (see also: CRUD) data from relational database management systems. ...
Lisp is a family of computer programming languages with a long history and a distinctive fully-parenthesized syntax. ...
Common Lisp, commonly abbreviated CL, is a dialect of the Lisp programming language, standardised by ANSI X3. ...
The MetaOCaml preprocessor/language provides similar features for external Domain-Specific Programming Languages. 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 A domain-specific programming language (domain-specific language, DSL) is a programming language designed to be useful for a specific set of tasks. ...
Objective Caml (OCaml) is a general-purpose programming language descended from the ML family, created by Xavier Leroy, Jérôme Vouillon, Damien Doligez, Didier Rémy and others in 1996. ...
General purpose preprocessor Most preprocessors are specific to a particular data processing task (e.g., compiling the C language). A preprocessor may be promoted as being general purpose, 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. A compiler is a computer program that translates a computer program written in one computer language (called the source language) into an equivalent program written in another computer language (called the output or the target language). ...
The C Programming Language, Brian Kernighan and Dennis Ritchie, the original edition that served for many years as an informal specification of the language The C programming language is a low_level standardized programming language developed in the early 1970s by Ken Thompson and Dennis Ritchie for use on the UNIX...
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: m4 is a macro processing language designed by Brian Kernighan and Dennis Ritchie. ...
The C Programming Language, Brian Kernighan and Dennis Ritchie, the original edition that served for many years as an informal specification of the language The C programming language is a low_level standardized programming language developed in the early 1970s by Ken Thompson and Dennis Ritchie for use on the UNIX...
The C preprocessor (cpp) is the preprocessor for the C programming language. ...
JavaScript is the name of Netscape Communications Corporations and now the Mozilla Foundations implementation of the ECMAScript standard, a scripting language based on the concept of prototype-based programming. ...
m4 is a macro processing language designed by Brian Kernighan and Dennis Ritchie. ...
The C preprocessor (cpp) is the preprocessor for the C programming language. ...
The process: putting information from database, and presentation specifications from web template, into the template engine, to produce web pages. ...
HTML, short for HyperText Markup Language, is the predominant markup language for the creation of web pages. ...
imake is a C preprocessor interface to the make utility for Unix Systems. ...
The correct title of this article is . ...
The C preprocessor (cpp) is the preprocessor for the C programming language. ...
KDE 3. ...
Automake is a programming tool that produces portable makefiles for use by the make program, used in compiling software. ...
See also Wikipedia does not have an article with this exact name. ...
It has been suggested that French Wiktionary be merged into this article or section. ...
A directive is an instruction to a programming language compiler about how to compile a program. ...
Metaprogramming is the writing of programs that write or manipulate other programs (or themselves) as their data or that do part of the work that is otherwise done at runtime during compile time. ...
A macro in computer science is an abstraction, that defines how a certain input pattern is replaced by an output pattern according to a defined set of rules. ...
Snippet management is a feature of some text editors, program source code editors, IDEs and related software. ...
The process: putting information from database, and presentation specifications from web template, into the template engine, to produce web pages. ...
The C preprocessor (cpp) is the preprocessor for the C programming language. ...
Camlp4 is a software system for writing extensible parsers for programming languages. ...
The Windows software trace preprocessor (abbreviated WPP; the preprocessor and related support tools are known as WPP Software Tracing) is a preprocessor that simplifies the use of WMI event tracing to implement efficient software tracing in drivers and applications that target Windows 2000 and later operating systems. ...
External links References - ^ Show how to use C-preprocessor on JavaScript files. "JavaScript is Not Industrial Strength" by T. Snyder.
- ^ Show how to use C-preprocessor as template engine. "Using a C preprocessor as an HTML authoring tool" by J. Korpela, 2000.
|