Closed denismazzucato closed 9 months ago
CParser doesn't seem to work well with comments:
from pycparser.c_parser import CParser ast = CParser().parse(r''' int main() { // comment } ''')
raises "ParseError: :3:3: before: /"
In fact, one needs to activate cpp parsing with flag "-E" to obtain the ast of such code, the following works:
from pycparser import parse_file ast = parse_file('examples/example.c', use_cpp=True, cpp_path='gcc', cpp_args=r'-E')
Please read the README file carefully, especially this section: https://github.com/eliben/pycparser?tab=readme-ov-file#31interaction-with-the-c-preprocessor
CParser doesn't seem to work well with comments:
raises "ParseError: :3:3: before: /"
In fact, one needs to activate cpp parsing with flag "-E" to obtain the ast of such code, the following works: