[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Template file processor

From: Neil Jerram
Subject: Re: Template file processor
Date: Tue, 06 Dec 2005 19:57:14 +0000
User-agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux)

Bruce Korb <address@hidden> writes:

> That is useful and handy and a convenient representation for generating
> a text file that has computed fragments.  To be clear, though, that is not
> exactly the prime motivation behind my program.  :)  It is rather the
> separation of a template that describes the output file from the data
> used to drive the instantiation.  e.g. in my "trivial example", these
> data:  [...example snipped...]

But this is quite straightforward to do with my template processor

The template for list.h would be this:

typedef enum {
$(for-each (lambda (item-data)    $
     IDX_$~a (string-upcase (symbol->string (car item-data)))$,
$         ) list-data)            $
} list_enum;

extern const char* az_name_list[ $~a (length list-data)$ ];

and the template for list.c this:

#include "list.h"
const char* az_name_list[] = {
$(for-each (lambda (item-data)    $
     $~s (cdr item-data)$,
$         ) list-data)            $

and then the code to define the data and generate the output would be

(define list-data
  '((alpha . "some alpha stuff")
    (beta . "more beta stuff")
    (omega . "final omega stuff")))

(use-modules (ossau template))

(with-output-to-file "list.h"
  (lambda ()
    (process-template "list.h.template"

(with-output-to-file "list.c"
  (lambda ()
    (process-template "list.c.template"

So what's my point?  Well nothing very much, except to say that from
my point of view (as someone who prefers to code in Scheme) you are
making life hard for yourself with AutoGen by writing so much of it in
C.  On the other hand I appreciate that AutoGen is a far more mature
system than the above and that you have constraints on what you can do
with it because of your existing users.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]