www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - how to parse a demangled symbol into parse tree or other form

Is there a way to parse a demangled symbol into a parse tree, or 
json representation, or other form?

eg:

string 
name="std.format.formatValue!(std.array.Appender!(immutable(char)[]).Appender, 
TypeInfo_Class, 
char).formatValue(std.array.Appender!(immutable(char)[]).Appender, 
TypeInfo_Class, ref std.format.FormatSpec!(char).FormatSpec)"

=>
1)
assert(fullyQualifiedNameSymbol(name)="std.format.formatValue");
assert(aritySymbol(name)=3);

2)
better yet, get a parse tree

3)
additionally, dump it to a json string:
{
"name" : "std.format.formatValue",
"template_args" : [...]
...
}

If not, I guess Pegged could be useful.

This is to postprocess unreadable stack traces
Sep 20 2012