What is C2XML?


c2xml is a tool that generates a XML representation of pre-processed ANSI C source code. What does it mean? Better give an example.

Example


Original C code
XML representation



unsigned int f1 (void)
{
  return f2 ();
}


<translation_unit>
    <function_definition>
        <type_specifier_atomic token="unsigned"/>
        <type_specifier_atomic token="int"/>
        <declarator>
            <direct_declarator_function>
                <direct_declarator_id token="f1"/>
                <parameter_list>
                    <parameter_declaration>
                        <type_specifier_atomic token="void"/>
                    </parameter_declaration>
                </parameter_list>
            </direct_declarator_function>
        </declarator>
        <compound_statement>
            <return_statement>
                <expression>
                    <expression_function>
                        <expression_id token="f2"/>
                    </expression_function>
                </expression>
            </return_statement>
        </compound_statement>
    </function_definition>
</translation_unit>


What is it useful for?


Isn't original C code more compact and readable? Why need to translate it to XML?
The answer is Yes, for humans. But XML has become a standard for information exchanging, and among other features it can be easily parsed using  XSLT templates to get important information from the code, or to transform it to any other format including text, html or other XML-based format.

C2XML could be used to
  • extract metrics from the source code
  • generate automatic documentation
  • check for syntax, naming conventions
  • perform static verification of the code
  • convert from C to other languages
  • even make a ANSI C compiler !
  • ...
All those uses are specially usefull for mission-critical applications such as aeronautics or automotive embedded systems.

Do all those features come with C2XML? Absolutely not. They all can be done using C2XML combined with other software, scripting or templates, but C2XML itself only translates to XML.


Also note that the source file must be pre-processed. You can use any open source pre-processor to do that (e.g. GNU C)

It would be great to have in the future a collection of applications based on C2XML in a shared repository!






go to project summary:   http://sourceforge.net/projects/c2xml/





This project is maintained by Jordi Aubert (administrator) and David Tuset (developer). Both from FICOSA International.

  contact: jaubert@ficosa.com