DCT: D compiler as a collection of libraries

Roman D. Boiko rb at d-coding.com
Fri May 11 23:01:17 PDT 2012


On Saturday, 12 May 2012 at 05:41:16 UTC, Jonathan M Davis wrote:
> It's great that you're working on this. We definitely need more 
> of this sort of
> stuff. However, I would point out that I'm not sure that it 
> will be acceptable
> for Phobos (it _may_ be, but it's not quite what we've been 
> looking for).
> There are two types of lexers/parsers that we've been looking 
> to add to
> Phobos.
>
> 1. A direct port of the lexer from dmd's C++ front-end. The API 
> would be D-
> ified to use ranges, but the internals would be almost 
> identical to the C++
> front-end so that porting changes back and forth would be very 
> easy. It also
> would make it easier to replace the C++ front-end with a D one 
> later if the D
> one is very close to the C++ one.
>
> 2. A lexer/parser generator using templates and/or CTFE to 
> generate a
> lexer/parser of whatever language using a BNF or EBNF grammar - 
> probably
> similar to what Philippe Sigaud has done to generate a parser 
> using PEGs. Such
> could be used to generate a lexer/parser for D or any other 
> language.
>
> What you seem to be doing is creating a D-specific parser from 
> scratch, which
> is great, but it's not quite what we've been looking to add to 
> Phobos. That
> doesn't necessarily mean that we can't or won't add it to 
> Phobos once it's
> complete (especially if nothing else gets done first), but it 
> also may not be
> acceptable, because it's not either #1 or #2. That would have 
> to be decided
> once it's done and ready to be reviewed for inclusion in 
> Phobos. I'm not
> trying to discourage you at all. I'm just pointing out that 
> what you're doing
> is quite what we're looking for. Regardless, it _would_ be 
> interesting to be
> able to compare implementations of #1 and #2 against what 
> you're doing and
> seeing which performs better.
>
> - Jonathan M Davis
Yes, my project has different goals from #1 or #2. The primary 
need I'm trying to address is making development of tools for D 
development much easier. Tools are needed for D to become more 
widely used in practise. Secondary (a nice-to-have) would be to 
build a compiler on top of that. I plan to do both, but I don't 
intend to be backwards-compatible with DMD backend. I hope that 
at least part of my code will either influence or be reused in 
the reference D compiler (whatever that will be in the future).

It is important to have a reference frontend implementation which 
can be used in many tools, otherwise a lot of effort would be 
completely wasted and no tool would comply with the D 
specification and compilers.


More information about the Digitalmars-d-announce mailing list