Anyone interested on working on a D parser ?

Leandro T. C. Melo via Digitalmars-d digitalmars-d at puremagic.com
Wed Sep 16 18:35:13 PDT 2015


Hi D enthusiasts,

I'm developing a multi-language code modelling engine. The heart of
the project is a language-unifying AST, a generic pipeline of binding,
type checking, code completion, etc, and hooks that allow each
language to plug-in their specific behavior where needed. Also, the
library is not tight to any particular IDE or text editor.

One "issue" I have so far is the D parser.

Mostly because of convenience I prototyped it with Bison. Despite
being tricky to get such LR parsers working in an interactive
environment, it's still possible to error-recover at the right spots
and provide a decent user experience - you can see some action in the
videos below, one for D and another for Go [1]. However, in the case
of D there's an additional challenge due to its grammar. Even though
I'm using a GLR parser (so ambiguities are handled), it's still
difficult to get everything in place.

Would anyone be interested on working out this parser or perhaps
building a recursive descent one? The parser is supposed to be
lightweight, not to perform symbol lookup (it can afford some
impreciseness), and its result must be the special AST. Therefore,
simply taking the official dmd2's parser is not a solution, although
it could certainly server as a reference.

An alternative would be a LL parser generator. I think ANTLR added a
C++ target, but I don't know how mature it is. There's also llgen, but
I never tried it. I might experiment one of them with Rust.

This is a project I work on my free time, but I'm trying to make it
move. So if anyone is interested, please get in touch, I'd be glad to
take contributions: https://github.com/ltcmelo/uaiso

Leandro

[1] https://www.youtube.com/watch?v=ZwMQ_GB-Zv0 and
https://www.youtube.com/watch?v=nUpcVBAw0DM


More information about the Digitalmars-d mailing list