Demangle D mangled names.
Demangle D mangled names.
If it is not a D mangled name, it returns its argument name.
import core.stdc.stdio : stdin;
import std.stdio;
import std.ascii;
import std.demangle;
void test(int x, float y) { }
int main()
{
string buffer;
bool inword;
int c;
writefln("Try typing in: %s", test.mangleof);
while ((c = fgetc(stdin)) != EOF)
{
if (inword)
{
if (c == '_' || isAlphaNum(c))
buffer ~= cast(char) c;
else
{
inword = false;
write(demangle(buffer), cast(char) c);
}
}
else
{ if (c == '_' || isAlpha(c))
{
inword = true;
buffer.length = 0;
buffer ~= cast(char) c;
}
else
write(cast(char) c);
}
}
if (inword)
write(demangle(buffer));
return 0;
}
© 1999–2017 The D Language Foundation
Licensed under the Boost License 1.0.
https://dlang.org/phobos/std_demangle.html