Handle \l separately because a string literal can be in code like "string\\literal" with the \l inside. Also on Windows macros FILE produces specific delimiters \ and a directory or file may starts with the letter l.
Fix: Use regex on for replacing all \l (like ,\l, }\l, [\l) except \\l, because a literal as a rule containes multiple \ before \l.
Behavior of this script should not depend on the host platform. Neither should it depend on the target platform if the graph is obtained via cross-compilation. It should only depend on the graph itself, as it's a simple dot file converter. The graph itself may, of course, depend on the target platform (maybe even on the host platform).
So it sounds like this fix should be on the C++ side.