[antlr-interest] Beginner need some help

Alexander Landa infal at web.de
Sun Aug 21 19:56:20 PDT 2005

  Hello together,

(please, sorry for my English)

I'm absolute newbie in ANTLR and have some question about usability of ANTLR for the following task(s).

I've some really big library written in C++ and like to port it to C#.
I'm sure, this can't be made automatically, but I want to automate same

1. bring together .h and .cpp files and generate appropriate C# classes. Example

class D1: public B1
   void f1();
   void f2();
   void f3();
   void f4();

should became (in C#)

namespace LibName
public class D1: B1
  private void f1(){/*source from Cpp*/}
  private void f2(){/*source from Cpp*/}
  public void f3(){/*source from Cpp*/}
  public void f4(){/*source from Cpp*/}

2. If some function uses references or pointers it should be converted to references an annotated as
comment about its original: Example

void f1(const T1& t1, T2* t2)
can became (in C#) something like
void f1(T1 t1, T2 t2)
// t1: const ref T1
// t2: ptr T2

3. Convert some common <math> functions calls to C# Math function calls. I.e.:
abs(x) ==> Math.Abs(x)
fabs(x) ==>Math.Abs(x) /*because of overloading*/
cos(x) ==> Math.Cos(x)

4. Convert (very important) presented Doxygen Comments to (C#) XML-Comments. I.e.
@param ros some comment text
<param name="ros">some comment text</param>

5. Formal conversion of properties definition. I.e.

     __property TDensity       Density={write=SetDensity, read=GetDensity};
should became:
     public TDensity Density
         get { return SetDensity(); }
         set { SetDensity(value); } /*value is reserved word for value to set*/

6. Removing of "const" (correctness) because it is not supported by C# at all.
7. Converting "->" to "."
8. Converting dynamic_cast<x>(y) to "y as x", etc.
9. Support for Borland extensions and event definition and maybe eliminate some of this. I.e.
__fastcall can be eliminated.
Replace "typedef declspec" by "event" , etc.

I would be very glad, if someone can provide some help for me.
Exceptionally for some related exaples.

Many thanks in advice for your help,

Alexander Landa
Verschicken Sie romantische, coole und witzige Bilder per SMS!
Jetzt bei WEB.DE FreeMail: http://f.web.de/?mc=021193

More information about the antlr-interest mailing list