Disable type checking on identifiers for parse?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Disable type checking on identifiers for parse?

andrewh
In my program I'm placing a macro function body into a normal function body so that the macro will be expanded and if there are no syntax errors, generate an ast of it.
e.g:
#define macronum 5
#define macrofunc(x,y) x+y*macronum
void func(char *x, char *y) {macrofunc(x,y);}

expanding into:
void func(char *x, char *y) {x+y*5;}
to get an ast like: (+ x (* y 5))

I won't know the param types, so I was hoping to skip the type checking.

Is this possible? e.g. by doing something with the 'Sema' or 'Parser' classes?

Thanks.
Reply | Threaded
Open this post in threaded view
|

Re: Disable type checking on identifiers for parse?

Sean Silva-2
Sadly, it is impossible to correctly parse C++ (and C also I believe) without being aware of types.

--Sean Silva

On Tue, Jun 12, 2012 at 9:57 PM, andrewh <[hidden email]> wrote:
In my program I'm placing a macro function body into a normal function body
so that the macro will be expanded and if there are no syntax errors,
generate an ast of it.
e.g:
#define macronum 5
#define macrofunc(x,y) x+y*macronum
void func(char *x, char *y) {macrofunc(x,y);}

expanding into:
void func(char *x, char *y) {x+y*5;}
to get an ast like: (+ x (* y 5))

I won't know the param types, so I was hoping to skip the type checking.

Is this possible? e.g. by doing something with the 'Sema' or 'Parser'
classes?

Thanks.


--
View this message in context: http://clang-developers.42468.n3.nabble.com/Disable-type-checking-on-identifiers-for-parse-tp4024483.html
Sent from the Clang Developers mailing list archive at Nabble.com.
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev


_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Disable type checking on identifiers for parse?

andrewh
Thanks, I had a feeling that might be the case.

Back to the drawing board.