Created
June 23, 2011 11:11
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import std.stdio; | |
import core.demangle; | |
void main() | |
{ | |
foreach (line; stdin.byLine()) | |
{ | |
size_t beginIdx, endIdx; | |
enum State { searching_, searchingD, searchingEnd, done } | |
State state; | |
foreach (i, char c; line) | |
{ | |
switch (state) | |
{ | |
case State.searching_: | |
if (c == '_') | |
{ | |
beginIdx = i; | |
state = State.searchingD; | |
} | |
break; | |
case State.searchingD: | |
if (c == 'D') | |
state = State.searchingEnd; | |
else if (c != '_') | |
state = State.searching_; | |
break; | |
case State.searchingEnd: | |
if (c == ' ' || c == '"' || c == '\'') | |
{ | |
endIdx = i; | |
state = State.done; | |
} | |
break; | |
} | |
if (state == State.done) | |
break; | |
} | |
if (endIdx > beginIdx) | |
writeln(line[0..beginIdx], demangle(line[beginIdx..endIdx]), | |
line[endIdx..$]); | |
else | |
writeln(line); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment