ned14 / pcpp

A C99 preprocessor written in pure Python
Other
215 stars 39 forks source link

LL suffix not parsed correctly #82

Open Melsius opened 1 year ago

Melsius commented 1 year ago

When trying to parse an integer suffixed with "LL", parsing fails. E.g. in

#define very_long_one (1LL)

To reproduce I boiled it down to:

import pcpp
proc = pcpp.Preprocessor()
tokens = proc.tokenize("1LL")
proc.evalexpr(tokens)

Yields: :3 error: Could not evaluate expression due to SyntaxError("around token 'L' type CPP_ID") (passed to evaluator: '1LL')

This can be easily fixed by changing the CPP_INTEGER regex in pcpp.parser to allow one more optional 'L' at the end, however I'm kind of puzzled why nobody else has ran into this issue. Am I missing something?

ned14 commented 1 year ago

We ought to do a better job in pcpp parsing U, L, LL, ULL etc.

Thanks for the BR.