D Compiler as a Library

deadalnix deadalnix at gmail.com
Sat Apr 14 06:51:54 PDT 2012


Le 14/04/2012 12:35, Manu a écrit :
> On 13 April 2012 18:25, Jakob Ovrum <jakobovrum at gmail.com
> <mailto:jakobovrum at gmail.com>> wrote:
>
>     On Friday, 13 April 2012 at 13:08:51 UTC, deadalnix wrote:
>
>         SDC have a lot of theses, and I proposed a similar stuff for its
>         evolution. I think it is easier for SDC than it is for dmd
>         considering the codebase of both.
>
>
>     I think we've got the lexer and parser completely separate from
>     most of the rest of the codebase (like the codegen), due to
>     repeated requests from people who wanted to use these parts for
>     IDEs and other tools.
>
>     I've yet to see anyone actually go through with using it though,
>     possibly because there is no documentation for a lot of it.
>     Documenting these parts fully into something of a public API and
>     then putting it online is definitely on the todo list. Perhaps
>     there would be more motivation to do this rather than work on
>     something else if someone actually tried using SDC in their
>     project instead of just talking about it, so it's kind of a
>     catch-22.
>
>     That said, the parser is currently evolving alongside the
>     codegen. When we want to start implementing new parts of the
>     language, we iteratively add it to the parser, hence it's not
>     complete. It's very easy to work with though and it's mostly a
>     menial task (although it's kind of fun to produce beautiful
>     parser errors :P).
>
>     Anyway, for anyone interested, you can find us on Github and
>     #d.sdc on FreeNode.
>
>
> Just out of curiosity, why would anyone write a code gen these days?
> With projects like LLVM, which can perform great codegen to basically
> any architecture, you'd be crazy not to use that...
> Surely 90% of the value of writing your own D compiler would be the
> unique front end, which may have different design principles (like use
> as a lib, usable on tools and stuff as discussed here) ?
>
> I'm sorry to say, if you write your own codegen, I would never use your
> compiler. If you use LLVM in the back end, I'll definitely give it a
> look, then merit will depend entirely on the front end (speed,
> flexibility, quality of error messages, runtime error detection, etc).
> I know it's a fun exercise to write a codegen, so from an educational
> perspective, sure, it's valuable to you as a programmer, but I don't
> think it helps your project at all.

Codegen is done by LLVM in SDC, but you still need some codegen glue.


More information about the Digitalmars-d mailing list