Minimac is a minimalist, general purpose text macro processor. Its
simplicity should make it particularly well suited as a front end
preprocessor for little language compilers. It is meant to be
simpler
to use than m4. It uses an explicit argument stack, and user
functions
are defined by concatenation (similar to the Forth language). Macro
expansion is delayed to the last possible moment.
Minimac is a BSD licensed open source project written in ANSI C.The
software is currently in alpha release.
Release announcements are posted on the project's Freshmeat page:
http://freshmeat.net/projects/minimac-macro-processor
---
Example #1
Here's a simple interactive usage example (Minimac's output has been
prefixed with '=>'):
define the macro greet to expand to 'Hello friend`:
`greet`Hello friend`
=>
test the macro greet:
greet
=>Hello friend
define the macro friend to expand to 'George':
`friend`George`
=>
test the macro friend:
friend
=>George
the expansion of greet now takes into account that friend is now a
macro:
greet
=>Hello George
redefine the macro friend to expand to 'Ann':
`friend`Ann`
=>
test the redefined macro friend:
friend
=>Ann
the expansion of greet now takes into account that friend has been
redefined:
greet
=>Hello Ann
----
Example #2
Code for 99 bottles of beer song (http://www.99-bottles-of-
beer.net/)
`drink! ( u -- ) `{continue}${#}
this-many-bottles of beer on the wall, this-many-bottles of beer.
Take one down and pass it around, fewer-bottles of beer on the wall.
{repeat}`
`oh-no! ( -- ) `No more bottles of beer on the wall, no more bottles
of beer.`
`please! ( u -- u ) `{#}
Go to the store and buy some more, this-many-bottles of beer on the
wall.`
`this-many-bottles ( u -- u ) `[
{dup} 0& ~no more bottles~& {case} 1& ~1 bottle~& {case} {.} ~
bottles~ ]`
`fewer-bottles ( u -- u-1 ) `{--}$this-many-bottles`
99& drink!
oh-no!
99& please!
---
Regards,
Mark