-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathmap2sym.d
More file actions
51 lines (49 loc) · 1.19 KB
/
map2sym.d
File metadata and controls
51 lines (49 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import std.stdio;
import std.regex;
void main(string[] args)
{
bool ms;
if (args[1] == "-ms")
{
args = args[1..$];
ms = true;
}
assert(args.length == 3);
auto inf = File(args[1], "r");
auto outf = File(args[2], "w");
Regex!char r;
Regex!char r2;
if (ms)
{
r = regex(r"^ \p{Hex_Digit}{4}:\p{Hex_Digit}{8} {7}([^\s]+)\s+(\p{Hex_Digit}{8}).+$$");
r2 = regex(r"^ \p{Hex_Digit}{4}:\p{Hex_Digit}{8} {7}__imp__([^\s]+)\s+(\p{Hex_Digit}{8}).+$$");
}
else
{
r = regex(r"^ \p{Hex_Digit}{4}:\p{Hex_Digit}{8} {7}([^\s]+)\s+(\p{Hex_Digit}{8})$");
r2 = regex(r"^ \p{Hex_Digit}{4}:\p{Hex_Digit}{8} Imp ([^\s]+)\s+(\p{Hex_Digit}{8})$");
}
foreach(l; inf.byLine())
{
try
{
auto m = match(l, r);
if (!m.empty)
{
auto c = m.captures;
outf.writeln(c[2], '\t', c[1]);
}
}
catch {}
try
{
auto m = match(l, r2);
if (!m.empty)
{
auto c = m.captures;
outf.writeln(c[2], '\t', c[1]);
}
}
catch {}
}
}