www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - how to parse mangled/demangled name into function name, arguments etc.

reply Timothee Cour <thelastmammoth gmail.com> writes:
demangle D15bootstrap_utils4util15replace_macros2FKHAyaAyaAyaZAya

immutable(char)[] bootstrap_utils.util.replace_macros2(ref
immutable(char)[][immutable(char)[]], immutable(char)[])

I want to obtain function name, arguments, etc (eg AST as  json output
would show)
is there a reliable library solution that works in the potentially
complex cases where the involved arguments / template arguments are
relatively complex themselves?

thanks!
Mar 26 2013
parent reply Jacob Carlborg <doob me.com> writes:
On 2013-03-26 22:17, Timothee Cour wrote:
 demangle D15bootstrap_utils4util15replace_macros2FKHAyaAyaAyaZAya

 immutable(char)[] bootstrap_utils.util.replace_macros2(ref
 immutable(char)[][immutable(char)[]], immutable(char)[])

 I want to obtain function name, arguments, etc (eg AST as  json output
 would show)
 is there a reliable library solution that works in the potentially
 complex cases where the involved arguments / template arguments are
 relatively complex themselves?
There's core.demangle, but that won't give you an AST and it will probably fail in some cases. I would try and modify core.demangle to produce an AST instead of a string. Perhaps this old project has something useful: http://flectioned.kuehne.cn/ -- /Jacob Carlborg
Mar 27 2013
parent Jacob Carlborg <doob me.com> writes:
On 2013-03-27 08:17, Jacob Carlborg wrote:

 There's core.demangle, but that won't give you an AST and it will
 probably fail in some cases. I would try and modify core.demangle to
 produce an AST instead of a string. Perhaps this old project has
 something useful:

 http://flectioned.kuehne.cn/
I actually started to work on that a couple of years ago. I wonder if I have the code left, somewhere. -- /Jacob Carlborg
Mar 27 2013