Description:
This transformation generates a XML tree where nodes relate to C++ source code tokens.
The difference between this version and the one named to_xml is that here nodes have names related to token types, which can make it easier for some further XML transformations.
For example, the following file (file.cpp):
#include <iostream> int main() { std::cout << "Hello World\n"; }
will be transformed into new file named file.cpp.xml:
<?xml version="1.0" encoding="ISO-8859-1"?> <cpp-source file-name="test.cpp"> <pp_hheader line="1" column="0">#include <iostream></pp_hheader> <newline line="1" column="19">![CDATA[ ]]</newline> <newline line="2" column="0">![CDATA[ ]]</newline> <int line="3" column="0">int</int> <space line="3" column="3"> </space> <identifier line="3" column="4">main</identifier> <leftparen line="3" column="8">(</leftparen> <rightparen line="3" column="9">)</rightparen> <newline line="3" column="10">![CDATA[ ]]</newline> <leftbrace line="4" column="0">{</leftbrace> <newline line="4" column="1">![CDATA[ ]]</newline> <space line="5" column="0"> </space> <identifier line="5" column="4">std</identifier> <colon_colon line="5" column="7">::</colon_colon> <identifier line="5" column="9">cout</identifier> <space line="5" column="13"> </space> <shiftleft line="5" column="14"><<</shiftleft> <space line="5" column="16"> </space> <stringlit line="5" column="17">"Hello World\n"</stringlit> <semicolon line="5" column="32">;</semicolon> <newline line="5" column="33">![CDATA[ ]]</newline> <rightbrace line="6" column="0">}</rightbrace> <newline line="6" column="1">![CDATA[ ]]</newline> <eof line="7" column="0"></eof> </cpp-source>
Note: If the source code does not use line splicing, then concatenation of all XML node values is equivalent to the original C++ code.