Want to help DMD bugfixing? Write a simple utility.

Nick Sabalausky a at a.a
Fri Mar 25 15:07:51 PDT 2011


"Jonathan M Davis" <jmdavisProg at gmx.com> wrote in message 
news:mailman.2700.1300915109.4748.digitalmars-d-learn at puremagic.com...
>> On 3/23/11, Jonathan M Davis <jmdavisProg at gmx.com> wrote:
>> > That would require a full-blown D lexer and parser.
>> >
>> > - Jonathan M Davis
>>
>> Isn't DDMD written in D? I'm not sure about how finished it is though.
>
> Yes, but the lexer and parser in ddmd are not only GPL (which would be a
> problem for some stuff but not others - for something like Don's utility, 
> it
> wouldn't be a problem), and more importantly, it is tied to the compiler 
> code.
> It's not designed to be used by an arbitrary program. For that, you would 
> need
> a lexer and parser which were designed with an API such that an arbitrary 
> D
> program could use them. For instance, the lexer could produce a range of
> tokens to be processed, and a program which wants to use the lexer can 
> then
> process that range.
>

I don't know about the license issues, but I don't think the API is a big 
deal. I'm in the early stages of a DDMD-based project to compile D code down 
to Haxe, and all I really had to do was comment out the backend-related 
section at the end of main(), inject my AST-walking/processing functions 
into the AST classes (though, admittedly, there is 1.5 metric fuckton of 
these AST classes), and then add a little bit of code at the end of main() 
to launch my AST-traversal. The main() function could easily be converted to 
a non-main one.

The only real difficultly is the fact that the AST isn't really documented, 
except for what little exists on one particular Wiki4D page (sorry, don't 
have the link ATM).

Hmm, although, depending what you're doing with it, you may also want to 
hook DDMD's stdout/stderr output, or at least the error/warning functions.





More information about the Digitalmars-d-learn mailing list