How do I use libdparser, or any library for editing D code?

Liam McGillivray yoshi.pit.link.mario at gmail.com
Mon Mar 25 23:07:43 UTC 2024


I want to do some automated mass-editing of some source code in 
D. If there is such a library available that knows how to process 
D code, similar to `std.json` but for D, then I would like to use 
it.

I looked at libdparser, but the documentation makes it look like 
a nightmare. Only one example is provided, and it's rather 
complicated despite seemingly doing very little.

https://github.com/dlang-community/libdparse/#Example

Are you kidding me?

Anyway, is there any library that can process a D source file and 
split it into pieces, similarly to `std.json`, but in a way that 
makes it easy to use for editing? I would want it to know to 
recognize things like the scope in which a symbol is declared 
(the function, class, enum, struct, etc).

Here are some things I would like to automate:
- Mass-editing an enum to give each member an alternative 
identifier.
- Looking for functions, and adding an overloaded version for 
each function declared with a certain argument type. I would make 
the format for how the overloaded definition will look.


More information about the Digitalmars-d-learn mailing list