[Prev][Next][Index]

Re: Problems unparsing C code



>Since I'm feeding the resulting source code to a C compiler, the
>missing 'struct' drives the compiler strange. Is there an easy way  
>to
>fix the unparser so it outputs the keyword 'struct'? I need this
>badly because I will not be handling C++ code, so using a C++  
>compiler
>is not an option.
______
Diego,
I think it would be easy to modify the unparser to do what you want.  
I can look into this tomorrow morning.  But could you give a more  
complete example?
if I try parsing/unparsing a file that contains only:

struct someStruct *f(int){ int j;}

then it unparses to 


struct someStruct *  f(int ){
      int j;
}

Similarly:

struct someStruct;
struct someStruct *f(int){ int j;}

unparses to:

struct someStruct   ;
struct someStruct *  f(int ){
      int j;
}


However,
struct someStruct{int k;};
struct someStruct *f(int){ int j;}

unparses to:

struct someStruct   {
      int k;
} ;
someStruct *  f(int ){
      int j;
}

I assume that the last example is how struct is used in your program.
        --Beata