Migrating dmd to D?

Zach the Mystic reachBUTMINUSTHISzach at gOOGLYmail.com
Fri Mar 1 22:08:50 PST 2013


On Saturday, 2 March 2013 at 04:28:40 UTC, Zach the Mystic wrote:
> Last year I boiled down existing ddmd to:
>
> https://github.com/zachthemystic/ddmd-clean/
>
> I did it because I needed to teach myself programming, and 
> maybe there was a long shot that someone would want to use it. 
> I rather angrily attached the GPL license because I thought I 
> had to. But flexibility in this area comes as a welcome 
> surprise.
>
> I want to make another point. Dmd is perhaps written in a way 
> that might be easier to create an automatic program translating 
> it to D than other C++ programs. I guess that approach is worth 
> at least a small amount of investigation. The question is 
> whether the number of special cases required to automate will 
> take more toll than the grunt work of direct translation.

You would definitely need an identifier translation table:

"Dsymbols *" -> "Dsymbol[]"
"NULL" -> "null"
`//printf("...%d...", s)` -> `writef("...%s...", s)`
"#ifdef XIFDEFVERSION" + nested ifdefs + "#endif"
-> "version(XIFDEFVERSION) {" + nested {}'s + "}"

"#ifdef 0" -> "version(none)"

To assemble a class, you'd need a list of methods to look up, and 
hints where to look up each method.

It would be good to develop a small domain specific language just 
for translating this. The better the language, the easier it 
would be to add all the special cases I'm sure would be necessary.


More information about the Digitalmars-d mailing list