D port of dmd: Lexer, Parser, AND CodeGenerator fully operational

Jonathan M Davis jmdavisProg at gmx.com
Wed Mar 7 23:54:33 PST 2012


On Thursday, March 08, 2012 08:45:13 Zach the Mystic wrote:
> On Thursday, 8 March 2012 at 07:21:19 UTC, Zach the Mystic wrote:
> > On Thursday, 8 March 2012 at 04:56:07 UTC, Jonathan M Davis
> > 
> > wrote:
> >> If you took it from ddmd, then it's definitely going to have
> >> to be GPL.
> >> 
> >> Now, there is interest in having a D parser and lexer in
> >> Phobos. I don't know
> >> if your version will fit the bill (e.g. it must have a
> >> range-based API), but we
> >> need one at some point. The original idea was to more or less
> >> directly port
> >> dmd's lexer and parser with some adjustments to the API as
> >> necessary
> >> (primarily to make it range-based). But no one has had the
> >> time to complete
> >> such a project yet (I originally volunteered to do it, but I
> >> just haven't had
> >> the time).
> 
> I have another question. The parser need to parse the tokens into
> some kind of objects, which I presume will be the current dmd
> object structure? Many of the class members are only of value to
> semantic and can be cut. But as much value as a parser is, you
> need just as much work designing the structures of the objects it
> creates, which is mostly done, by the way, it's just I'm not sure
> what exactly you're trying to put into phobos.

Well, the first concern is the lexer. As far as getting stuff into Phobos goes, 
I'd advise concentrating on getting the lexer ready rather than necessarily 
trying to do it all at once - _especially_ since the lexer needs to be usable 
separately from the parser.

As for what the parser should output, it's going to need to be the Abstract 
Syntax Tree. What exactly that looks like in dmd, I don't know. But we're 
pretty much going to want all of that information outputted by the parser. 
Ideally, it would be possible to build a compiler on top of the lexer and 
parser in Phobos. But I can't really give you specifics without studying the 
code in detail.

- Jonathan M Davis


More information about the Digitalmars-d-announce mailing list