What is the "easiest" way to parse D code?

Given an Expression/Statement/Function/Template.... I want to put it into a program, and it returns me an AST.

D-Scanner seems to do that with `--ast` argument. I would need to dig into it, to get it programmatically, instead of as XML on the stdout.
https://github.com/dlang-community/D-Scanner

libdparse seems to do it as well with `parseModule` function.
https://github.com/dlang-community/libdparse/blob/master/src/dparse/parser.d

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


I am also a little confused about who uses what. Does D-Scanner use libdparse?
Is there a D grammar for pegged?
https://github.com/PhilippeSigaud/Pegged

Thank you for any hints!

Reply via email to