ned14 / pcpp

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

Unterminated char or string literal should raise an error. #95

Open mrolle45 opened 8 months ago

mrolle45 commented 8 months ago

If a ' or " doesn't have a matching terminator on the same line, this is not a valid token. The newline character at the end of the line is not allowed. gcc -E issues a warning, and then emits the quote followed by the remainder of the line. I don't know what actual tokens are passed to the compiler without the -E switch. pcpp fails to match the regex and produces a token for just the quote character, then tokenizes the rest of the line. In order to keep a program which is using the tokens produced by pcpp from getting confused, I think that an error should be generated. Perhaps a character or string literal token should be produced as though the missing terminator appeared at the end of the line.

mrolle45 commented 8 months ago

Anyone have a suggestion about what pcpp should do in these cases?