ned14 / pcpp

A C99 preprocessor written in pure Python
Other
222 stars 41 forks source link

# operator keeps comments in the result #94

Open mrolle45 opened 10 months ago

mrolle45 commented 10 months ago

pcpp handles space and newline characters in the macro argument correctly by replacing all of them with a single space. However, it does not consider comments as whitespace. This code:

def mkstr(x) #x
mkstr ( a // comment
    b /* comment
      */ c)

results in

"a // comment b /* comment
      */ c"

This is fixed by simply including comment types in the value of Preprocessor.t_WS.

ned14 commented 10 months ago

Thanks for the BR