fix c tokenizer bug

This commit is contained in:
Vexu 2020-02-13 09:09:49 +02:00 committed by Andrew Kelley
parent 1fb70497d2
commit fa377dbd15
2 changed files with 9 additions and 0 deletions

View File

@ -651,6 +651,7 @@ pub const Tokenizer = struct {
state = .StringLiteral;
},
else => {
self.index -= 1;
state = .Identifier;
},
},
@ -660,6 +661,7 @@ pub const Tokenizer = struct {
state = .StringLiteral;
},
else => {
self.index -= 1;
state = .Identifier;
},
},
@ -673,6 +675,7 @@ pub const Tokenizer = struct {
state = .StringLiteral;
},
else => {
self.index -= 1;
state = .Identifier;
},
},
@ -686,6 +689,7 @@ pub const Tokenizer = struct {
state = .StringLiteral;
},
else => {
self.index -= 1;
state = .Identifier;
},
},

View File

@ -1362,12 +1362,17 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
cases.add("basic macro function",
\\extern int c;
\\#define BASIC(c) (c*2)
\\#define FOO(L,b) (L + b)
, &[_][]const u8{
\\pub extern var c: c_int;
,
\\pub inline fn BASIC(c_1: var) @TypeOf(c_1 * 2) {
\\ return c_1 * 2;
\\}
,
\\pub inline fn FOO(L: var, b: var) @TypeOf(L + b) {
\\ return L + b;
\\}
});
cases.add("macro defines string literal with hex",