demangle tool
Sergey Gromov
snake.scaly at gmail.com
Sun Apr 12 15:53:40 PDT 2009
Fri, 10 Apr 2009 14:25:30 -0700, Andrei Alexandrescu wrote:
> Sergey Gromov wrote:
>> Thu, 09 Apr 2009 13:40:36 -0700, Andrei Alexandrescu wrote:
>>
>>> The line wraps are all garbled, but you get the idea: all symbols quoted
>>> `like this' have been demangled appropriately. Below is the source of
>>> the demangle script:
>>>
>>> #!/home/andrei/bin/rdmd
>>> import std.algorithm, std.demangle, std.getopt, std.stdio;
>>>
>>> void main(string[] args)
>>> {
>>> string lSep = "`", rSep = "'";
>>> getopt(args, "lsep", &lSep, "rsep", &rSep);
>>> foreach (line; stdin.byLine())
>>> {
>>> auto sym = find(line, lSep);
>>> if (!sym.length)
>>> {
>>> writeln(line);
>>> continue;
>>> }
>>> sym = sym[1 .. $];
>>> auto before = line[0 .. $ - sym.length];
>>> sym = sym[0 .. $ - find(sym, rSep).length];
>>> auto after = line[before.length + sym.length .. $];
>>> writeln(before, demangle(sym.idup), after);
>>> }
>>> }
>>
>> What happened to the range boolean operations, those
>> before/after/whatever? Do you still plan to implement them?
>
> Curiously, I didn't find a need for them in std.algorithm so far. I only
> defined sameHead, and that's only to help a little improvement in the
> bringToFront algorithm.
I asked because I thought that "blah[foo.length .. $ - bar.length]"
stuff wasn't very nice. Compare:
sym.advance; // popFront, or sym[1 .. $]
auto s1 = line.before(sym);
auto s3 = find(sym, rSep);
writeln(s1, demangle(sym.before(s3).idup), s3);
More information about the Digitalmars-d
mailing list