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

stupid macro question



While macros seem to be the topic of the week,  I thought I'd try to get my
silly macro question answered by the experts.

So here goes:

I've been pondering how easy/fun it might be to port a unit testing
"template" generator we use at work from whatever it was written in
(probably C.  It doesn't matter) to Dylan.  It would be fun to write a Dylan
macro which would create an instance of some "testing class" which I would
define.   Then it would be possible to define methods with the class as a
parameter to write out the template to a text file.  The text file is
something we (the programmers/testers) write by hand now.  It has a very
simple syntax, but a pretty ugly one at that.  I thought a Dylan macro would
have a much cleaner look.  So imagine some sort of macro where you'd write
something like this:

define test-Cpp-environment
   test-function = [ myTestFunction ];

   inputs = [ BlinkHdlr , type = cBlinkHdlr ,
                  test-values = cBlinkTemp, cBlinkTemp2;
                 test-var , type = myStruct,
                 test-values = { 12, 0, 0x1f } ];

   outputs  = [   similar to the above ];

   test-code = [  compareBlinkHdlr_ptr  = new cBlinkHdlr;
                        do_Test();
                    ];

end test-Cpp-environment;


My question is: Can you insert totally non-Dylan stuff as text inside a
macro?  In other words,  the text within the brackets after the test-code =
...  would be actual C++ code.  I don't think that Dylan allows you to match
on totally non-Dylan text, but I thought I'd ask.  If Dylan could match on
this, I would then like to put quotes around it (i.e., make it a string) and
store it into some slot in the hypothetical test class.  With all the other
talk about the ?:* pattern, it seemed at least worth asking.

Otherwise,  it looks like the only other way to do this would be to actually
write my own parser.  The d2c parsergen looks totally undocumented.





Follow-Ups: