Want to help DMD bugfixing? Write a simple utility.

Nick Sabalausky a at a.a
Fri Mar 25 13:58:20 PDT 2011


"Alexey Prokhin" <alexey.prokhin at yandex.ru> wrote in message 
news:mailman.2713.1300954193.4748.digitalmars-d-learn at puremagic.com...
>> Currently, as far as I know, there are only two lexers and two parsers 
>> for
>> D: the C++ front end which dmd, gdc, and ldc use and the D front end 
>> which
>> ddmd uses and which is based on the C++ front end. Both of those are 
>> under
>> the GPL (which makes them useless for a lot of stuff) and both of them 
>> are
>> tied to compilers. Being able to lex D code and get the list of tokens in
>> a D program and being able to parse D code and get the resultant abstract
>> syntax tree would be very useful for a number of programs.
> There is a third one: http://code.google.com/p/dil/. The main page says 
> that
> the lexer and the parser are fully implemented for both D1 and D2. But the
> license is also the GPL.

The nearly-done v0.4 of my Goldie parsing system (zlib/libpng license) comes 
with a mostly-complete lexing-only grammar for D2.

http://www.dsource.org/projects/goldie/browser/trunk/lang/dlex.grm

The limitations of it right now:

- Doesn't do nested comments. That requires a feature (that's going to be 
introduced in the related tool GOLD Parsing System v4.2) that I haven't had 
a chance to add into Goldie just yet.

- It's possible there might be some edge-case bugs regarding either the ".." 
operator and/or float literals.

- It's ASCII-only. Goldie supports Unicode, but character set optimization 
isn't implemented yet, so unicode grammars are technically possible but 
impractical ATM (this will be the top priority after I get v0.4 released).





More information about the Digitalmars-d-learn mailing list