eliben / pycparser

:snake: Complete C99 parser in pure Python
Other
3.21k stars 612 forks source link

Can't parse incomplete types and other syntactically valid but non-compilable code #517

Closed geajack closed 1 year ago

geajack commented 1 year ago

I'd like to be able to parse this declaration:

int SDL_GetPointDisplayIndex(const SDL_Point *point);

Now of course, this won't compile unless I put in a typedef for SDL_Point, but I still feel like I should be able to parse it and get an AST, even if it won't compile. Shouldn't the parser at least be able to infer that SDL_Point is some kind of type and keep going?

eliben commented 1 year ago

See https://eli.thegreenplace.net/2007/11/24/the-context-sensitivity-of-cs-grammar/ and https://eli.thegreenplace.net/2011/05/02/the-context-sensitivity-of-cs-grammar-revisited/