The C++2XML page

Presentation Direct download Online Generation Utilisation Example of output License Definitions

 

Presentation

At the current time I am working on the C++/Aldor interoperability (C++2Aldor) for the FRISCO project with Yannis Chicha and Stephen Watt.

In order to use C++ classes from Aldor we had to parse C++ header files to convert them in XML. I did it by adding new functionalities to the GNU C++ Compiler.

Back to top

 

Download the latest version of C++2XML:

You will need:

Back to top

Try a generation online !

  1. What you need for the generation:

    The C++ header file you'd like to interface with Aldor (possibly preprocessed, see remarks below)

    Rem1:If your file includes non standard files (most of the cases), or if it needs extra flags to compile (e.g: -DKEY=3) you'll need the preprocessed file instead.

    echo '#include "'ToBeGenerated.H'"' > dummy.C
    g++ -E dummy.C > ToBeGenerated.ii
    

    Rem2: If your example contains templates, use ToBeGenerated.C instead of ToBeGenerated.H. (also possibly preprocessed)

  2. Do the generation
    Choose a file:

Back to top

 

Example of XML generation:

Just to let you know what the generated XML looks like, here is the representation a function:

Float foo(int dummy1, Class1 dummy2);

<function_decl foo> <declaration/> <function/> <function_type> <simple_type> <float/> <modifiers></modifiers> </simple_type> <modifiers></modifiers> </function_type> <arg-types> <param> <simple_type> <int/> >modifiers></modifiers> </simple_type> <initial></initial> </param> <param> <record_type> <name unique="Class1">Class1</name> <modifiers></modifiers> </record_type> <initial></initial> </param> </arg-types> <modifiers></modifiers> </function_decl>

Yes, it's quite verbose but all the syntactical ambiguities of C++ have been removed.

Back to top

 

Utilisation:

C++2xml is a set of options that have been added to gcc. You can replace your actual gcc or you can use it as an independant tool via the a script called cpp2xml (which is an alias for gcc -GenXML described below).

Description of the new options:

-GenXML:

This is the main option which was added to gcc. If it is not set, gcc works as usual... When this option is set, gcc generate the XML represention and no other file (.ii .s .o executable)

The command gcc -GenXML foo.C will generate an XML representation for foo.C in foo.xml

-split:

With this option, the (unique) generated XML is completed with a new tag called "Change Of File". When the source contains "#include" directives - classes, variables and functions are defined in several files - it helps to know in which file was defined such or such item.

-stdDir fileName:

This option was added for C++ to Aldor for which we only need to interface user header files. That's why we added an option to allow the user to specify where standard header files are located in order to do a special treatment with them. In fact we print only global scope type declaration names so that they are known in xml2aldor.
The -stdDir option need another parameter which is the name of a file containing the list of directory prefixes where standard header files are located.

-treeIncludes:

Generate a file named inputfile.inc which contains an XML representation of the hierarchy of header files included in inputfile. This option is not part of the XML generation but it was helpful for a previous version of C++2Aldor.
Example:

foo1.H ____ #include"foo1a.H" ____  #include"foo1a1.H"
        |  
        |__ #include"foo1b.H" ____  #include"foo1b1.H"
        |                      |__  #include"foo1b2.H"
        |
        |__ #include"foo1c.H"

will generate the following file (under the name foo1.H.inc)

<file>
     <name>"foo.H"</name>
     <include>
         <name>"foo1a.H"</name>
         <include>
            <name>"foo1a1.H"</name>
         </include>
     </include>
     <include>
         <name>"foo1b.H"</name>
         <include>
            <name>"foo1b1.H"</name>
         </include>
         <include>
            <name>"foo1b2.H"</name>
         </include>
     </include>
     <include>
         <name>"foo1c.H"</name>
     </include>
</file>

 

License:

C++2xml is distributed under the terms of the GNU General Public License Version 2, like gcc

Back to top

 


 

Definitions and short presentations

Aldor:            
This is an Object Oriented Functional language with strong type checking. It based on computer algebra sytem AXIOM
In aldor types and functions are first values.
It is mostly used by people involved in computer algebra.

 

C++2aldor:  
This is an application I am working on which generates the code needed to use directly C++ classes into Aldor

 

Frisco:          
A Framework for Integrated Symbolic/Numeric Computation
The aim of the FRISCO project is to investigate and develop technologies which can be used to deliver highly efficient, versatile polynomial solvers to industrial users

 

NAG:               
The Numerical Algorithms Group deals with scientific softwares. It produces distributes numerical, symbolic, statistical and visualisation software for the solution of problems in a wide range of applications in such areas as science, engineering, financial analysis and research.
For more information check the web page http://www.nag.co.uk

 

XML:             
The Extensible Mark-up Language (XML) is a data format for structured document interchange on the Web.
For more information check the web page http://www.w3.org/XML/
 


Back to
'SCL Projects'
     Back to
'SCL Home page'

         Florence Defaix for the SCL group.