eliben / pycparser

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

Unable to parse through comments and can't support directives #534

Closed aerah8 closed 7 months ago

aerah8 commented 7 months ago

The following c file will generate a pycparser.plyparser.ParseError

#include <stdio.h> 
int main(void) 
{     
  //comments
  printf("Executing critical code...\n");
  return 0;
}
aerah8 commented 7 months ago

I have attempted to solve this issue here: https://github.com/aerah8/pycparser/blob/main/pycparser/preprocessing.py

eliben commented 7 months ago

pycparser requires preprocessed code: https://github.com/eliben/pycparser?tab=readme-ov-file#interaction-with-the-c-preprocessor