From: John Joyce Date: 2007-05-03T17:17:10+09:00 Subject: Re: C DSL anyone? On May 3, 2007, at 4:18 PM, SonOfLilit wrote: > Am I the only one that thinks OP is looking for a library to assist in > generating ascii C code, like Markaby does for HTML, and not for > executing C code that you wrote as a string? > > Brad, I don't think you'll find one, and in fact, I don't think you'll > need one. Why? C has so much syntax that you're better off generating > it with string manipulation than with a DSL. > > HTML is so simple that there was more gain (succintness, > automatability) than loss (new language to learn) in Markaby and it's > neighbours. With C, I don't see such gains overcoming the loss. > > Aur > Indeed, the OP is trying to generate C rather than write C. Very understandable. Certainly doable. It just means a lot less of the flexibility that C usually has (for good and bad). But actually it is very possible to generate corresponding looping structures, structs, functions and more. Need to generate declarations of many variables. To get started, find a C file that follows the conventions you want to have generated. Rome was not built in a day and no generator will be either. In theory all languages end up the same in ASM anyway. The main problem is that it must be a DSL because some Ruby mechanisms wouldn't translate so smoothly to C. They'd be more like Objective-C. That said, there's a lot of typing that could be saved. Perhaps the most painful things would be dealing with pointers and memory management.