Gema:
gema is a general purpose text processing utility based on the concept of pattern matching. In general, it reads an input file and copies it to an output file, while performing certain transformations to the data as specified by a set of patterns defined by the user. It can be used to do the sorts of things that are done by Unix utilities such as cpp, grep, sed, awk, or strings. It can be used as a macro processor, but it is much more general than cpp or m4 because it does not impose any particular syntax for what a macro call looks like. Unlike utilities like sed or awk, gema can deal with patterns that span multiple lines and with nested constructs. It is also distinguished by being able to use multiple sets of rules to be used in different contexts.
Another neat feature is that it has bindings to Lua that let you run arbitrary Lua code to operate on the result of a match.
I came across Gema years ago, but while I've never had the opportunity to use it for anything, I kept it in the back of my mind as an interesting project. I've been wondering how similar what it does is to Perl 6 grammars, so I've been meaning to check out Gema again, although I couldn't remember the name until just now.
Feel free to post a comment below. Please see my comment policy.
Formatting Rules (No HTML):