Looking for champion - std.lang.d.lex

Jonathan M Davis jmdavisProg at gmx.com
Fri Oct 22 00:12:32 PDT 2010


On Thursday 21 October 2010 23:55:42 Walter Bright wrote:
> Jonathan M Davis wrote:
> > On Thursday 21 October 2010 15:01:21 Walter Bright wrote:
> >> 5. generally follow along with the C++ one so that they can be
> >> maintained in tandem
> > 
> > Does this mean that you want a pseudo-port of the C++ front end's lexer
> > to D for this? Or are you looking for just certain pieces of it to be
> > similar?
> 
> Yes, but not a straight port. The C++ version has things in it that are
> unnecessary for the D version, like the external string table (should use
> an associative array instead), the support for lookahead can be put in the
> parser, doesn't tokenize comments, etc.
> 
> Essentially I'd like the D lexer to be self-contained in one file.
> 
> > I haven't looked at the front end code yet, so I don't know how it works
> > there, but I wouldn't expect it to uses ranges, for instance, so I would
> > expect that the basic design would naturally stray a bit from whatever
> > was done in C++ simply by doing things in fairly idiomatic D. And if I
> > do look at the front end to see how that's done, there's the issue of
> > the license. As I understand it, the front end is LGPL, and Phobos is
> > generally Boost, which would mean that I would be looking at
> > LGPL-licensed code when designing Boost-licensed, even though it
> > wouldn't really be copying the code per se since it's a change of
> > language (though if you did the whole front end, obviously the license
> > issue can be waved quite easily).
> 
> Since the license is mine, I can change the D version to the Boost license,
> no problem.
> 
> > License issues aside, however, I do think that it would make sense for
> > std.lang.d.lex to do things similiarly to the C++ front end, even if
> > there are a number of basic differences.
> 
> Yup. The idea is the D version lexes exactly the same grammar as the dmd
> one. The easiest way to ensure that is to do equivalent logic.

Okay. Good to know. I'll start looking at the C++ front end some time in the 
next few days, but like I said, I really don't know how much time I'm going to 
be able to spend on it, so it won't necessarily be quick. However, porting logic 
should be much faster than doing it from scratch.

- Jonathan M Davis


More information about the Digitalmars-d mailing list