Commit 70137c5
committed
lexer: recognize a preprocessor directive with no trailing newline
The cpp lexer's PREPRO pattern (`^#.-[^\\]\n`) requires a literal trailing
newline, so a `#...` directive on the final line of the input without a
newline never matched. It fell through to the `^.` catch-all and was
tokenized as `#`, then the following words as identifiers, instead of a
single `prepro` token.
Add a PREPRO_EOF pattern (`^#.-[^\\]$`) tried right after PREPRO, so a
trailing directive at end-of-input is recognized while newline-terminated
and backslash-continued directives keep matching PREPRO first.
Fixes #4501 parent 4776299 commit 70137c5
2 files changed
Lines changed: 10 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
54 | 57 | | |
55 | 58 | | |
56 | 59 | | |
| |||
393 | 396 | | |
394 | 397 | | |
395 | 398 | | |
| 399 | + | |
396 | 400 | | |
397 | 401 | | |
398 | 402 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
121 | 121 | | |
122 | 122 | | |
123 | 123 | | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
124 | 130 | | |
125 | 131 | | |
126 | 132 | | |
| |||
0 commit comments