On Wednesday, 25 November 2020 at 16:27:41 UTC, Jan Hönig wrote:
What is the "easiest" way to parse D code?
(...)
libdparse seems to do it as well with `parseModule` function.
https://github.com/dlang-community/libdparse/blob/master/src/dparse/parser.d
I recommend libdparse.
dmd has to do it somewhere as well. Although I don't know
exactly where. I do know ldc uses dmd's frontend for parsing.
https://dlang.org/phobos/dmd_parse.html
DMD as a library is still experimental. You can try to use it,
but libdparse is more stable.
I am also a little confused about who uses what. Does D-Scanner
use libdparse?
Yes, most tools that parse D code do, including Adam's
documentation generator: https://github.com/adamdruppe/adrdox
Only LDC, GDC and VisualD use the dmd front-end as far as I know.
Is there a D grammar for pegged?
https://github.com/PhilippeSigaud/Pegged
Not complete and outdated, but it's a start:
https://github.com/PhilippeSigaud/Pegged/tree/master/examples/dgrammar