Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tokenizer: stay in .pp_num_exponent state if we encounter 'p' or 'P' #547

Merged
merged 1 commit into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/Tokenizer.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1698,14 +1698,17 @@ pub fn next(self: *Tokenizer) Token {
},
},
.pp_num_exponent => switch (c) {
'a'...'z',
'A'...'Z',
'a'...'o',
'q'...'z',
'A'...'O',
'Q'...'Z',
'0'...'9',
'_',
'.',
'+',
'-',
=> state = .pp_num,
'p', 'P' => {},
else => {
id = .pp_num;
break;
Expand Down
8 changes: 8 additions & 0 deletions test/cases/numbers.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ float m = 12E-2f;
float n = 0x12P+2;
float o = 0x12p-2;
_Static_assert(0xE+0xC == 0xE + 0xC, "");
double p = 0x1.ep-1;
double q = 0x1.eP-1;
double r = 0x1.Ep-1;
double s = 0x1.EP-1;
double t = 1.ep-1;
double u = 1.pp-1;

#define EXPECTED_ERRORS "numbers.c:1:9: error: invalid suffix 'b' on integer constant" \
"numbers.c:2:9: error: invalid suffix 'x' on integer constant" \
Expand All @@ -25,4 +31,6 @@ _Static_assert(0xE+0xC == 0xE + 0xC, "");
"numbers.c:10:12: error: exponent has no digits" \
"numbers.c:11:9: error: invalid suffix 'LLuf' on integer constant" \
"numbers.c:16:16: error: invalid suffix '+0xC' on integer constant" \
"numbers.c:21:12: error: exponent has no digits" \
"numbers.c:22:12: error: invalid suffix 'pp-1' on floating constant" \

Loading