Greets,

I've been using a version of Charmonizer with KinoSearch for a little while now. No public release, and it's a work in progress, but the basic approach seems to be sound.

I bailed on the idea of implementing Charmonizer as a domain-specific language with a full-on custom parser. Too much hassle, when another idea presented itself...

Dave had suggested that we might consider using C to write C. However, we agreed that embedding C code in C string literals was just too dang gnarly.

The solution: a source filter.

Here's a description taken from the README file:

<readme>

METAQUOTE UTILITY

Charmonizer is a C program which writes C code. Writing C from C is ordinarily quite awkward, because when you try to embed more than a line or two of C source code inside C string literals, things get ugly fast.

To get around this problem, Charmonizer uses a source filter. In the "real" Charmonizer source code, longer code fragments are surrounded by
    METAQUOTE tags instead of literal double quotes.

        char hello_source[] = METAQUOTE
            #include <stdio.h>
            int main() {
                printf("Hello, world.\n");
                return 0;
            }
        METAQUOTE;

    These source files are run through the "metaquote" utility -- which
transforms everything between paired METAQUOTE tags into concatenated
    string literals.  The result is hideous but valid C.

</readme>

Technically, Charmonizer ain't C -- it really is a domain-specific language which compiles to C. But this is a lot more straightforward than the syntax in the original proposal. And unless you're writing custom modules and you want to take advantage of metaquote, you just write your main configurator app in C and #include post-filter Charmonizer files.

http://www.rectangular.com/svn/kinosearch/trunk/charmonizer/
http://www.rectangular.com/svn/kinosearch/trunk/charmonize.c

Sound good?

metaquote is implemented in C, BTW.

Marvin Humphrey
Rectangular Research
http://www.rectangular.com/


Reply via email to