|
m4 is a macro processing language designed by Brian Kernighan and Dennis Ritchie. ...
Brian W. Kernighan (pronounced Ker-ni-han; the g is silent; born 1942) is a computer scientist who worked at the Bell Labs and contributed to the design of the pioneering AWK and AMPL programming languages. ...
Ken Thompson (left) with Dennis Ritchie (right) Dennis MacAlistair Ritchie (born September 9, 1941) is a computer scientist notable for his influence on ALTRAN, B, BCPL, C, Multics, and Unix. ...
Use
A macro processor is a text-replacement tool. Its chief use is to re-use text templates, typically in programming applications, but also in text editing, text processing applications. Computer programming (often simply programming) is the craft of implementing one or more interrelated abstract algorithms using a particular programming language to produce a concrete computer program. ...
History Macro processors were prevalent when assembly language programming was the common tool of programmers. In these early days of programming, the programmers noted that much of their program was repeated text. Simple means to re-use this text were invented. Programmers soon discovered it easy to not only reuse entire blocks of text, but, on occasion, substitute different values for similar parameters. This defined the usage range of macro processors. M4 was developed in 1977. It was the original macro engine used to implement Rational Fortran, and is shipped with most Unix variants. One of the most widespread present-day uses is as part of the GNU Project's autoconf. A more historic usage was in the configuration process of the wide-spread MTA sendmail. It has been suggested that Assembler be merged into this article or section. ...
Ratfor (short for RATional FORtran) is a programming language implemented as a preprocessor for Fortran. ...
Unix or UNIX is a computer operating system originally developed in the 1960s and 1970s by a group of AT&T Bell Labs employees including Ken Thompson, Dennis Ritchie, and Douglas McIlroy. ...
GNU (pronounced ) is a free software operating system consisting of a kernel, libraries, system tools, compilers and many end-user applications. ...
Autoconf is a tool for producing shell scripts that automatically configure software source code packages to adapt to many kinds of UNIX-like systems. ...
Features m4 offers these facilities: - text replacement
- parameter substitution
- file inclusion
- string manipulation
- conditional evaluation
- arithmetic expressions
- system interface
- programmer diagnostics
Unlike most earlier macro processors, it is not targeted at any particular computer or human language; historically, however, it was developed for supporting the Ratfor dialect of Fortran. Unlike some other macro processors, m4 is Turing-complete as well as a practical programming language. Ratfor (short for RATional FORtran) is a programming language implemented as a preprocessor for Fortran. ...
Fortran (also FORTRAN) is a general-purpose[1], procedural[2], imperative programming language that is especially suited to numeric computation and scientific computing. ...
In computability theory a programming language or any other logical system is called Turing-complete if it has a computational power equivalent to a universal Turing machine. ...
Example The following fragment is a simple example that could be part of an HTML generation library. It defines a macro to number sections automatically: An excerpt of HTML code with syntax highlighting In computing, HyperText Markup Language (HTML) is a markup language designed for the creation of web pages with hypertext and other information to be displayed in a web browser. ...
define(`H2_COUNT', 0) define(`H2', `define(`H2_COUNT', incr(H2_COUNT))' dnl `<h2>H2_COUNT. $1</h2>') H2(First Section) H2(Second Section) H2(Conclusion) After being processed with m4, the following text will be generated: <h2>1. First Section</h2> <h2>2. Second Section</h2> <h2>3. Conclusion</h2> Free software implementations There is a GNU version of m4. FreeBSD, NetBSD, and OpenBSD also provide independent implementations of the m4 language. GNU m4 is the GNU version of the m4 macro preprocessor. ...
FreeBSD is a Unix-like free operating system descended from AT&T UNIX via the Berkeley Software Distribution (BSD) branch through 386BSD and 4. ...
NetBSD is a freely redistributable, open source version of the Unix-like BSD computer operating system. ...
OpenBSD is a freely available Unix-like computer operating system descended from Berkeley Software Distribution (BSD), a Unix derivative created at the University of California, Berkeley. ...
References - Brian W. Kernighan and Dennis M. Ritchie. The M4 macro processor. Technical report, Bell Laboratories, Murray Hill, New Jersey, USA, 1977. pdf
- Kenneth J. Turner. Exploiting the m4 macro language. Technical Report CSM-126, Department of Computing Science and Mathematics, University of Stirling, Scotland, September 1994. pdf
- René Seindal. GNU M4 Manual. GNU Press. 2004. [1]
External links - http://www.gnu.org/software/m4/m4.html
|