authorgravatar for auguste.rame@gmail.comSuperAuguste <auguste.rame@gmail.com> 2020-04-04 17:56:25-04:00
committergravatar for auguste.rame@gmail.comSuperAuguste <auguste.rame@gmail.com> 2020-04-04 17:56:25-04:00
log027e2a16734d5a1ac884474ed688ecea9a785e73
tree8e5cc24015dc35c00f2e4c762f74b8bcfdd10467
parente7f555ca550cc73288adbdf4ec8d0e4abbc7a987

fix multichar literals in translate_c


1 files changed, 18 insertions(+), 6 deletions(-)

src-self-hosted/translate_c.zig+18-6
...@@ -5387,12 +5387,24 @@ fn parseCPrimaryExpr(c: *Context, it: *CTokenList.Iterator, source: []const u8,...@@ -5387,12 +5387,24 @@ fn parseCPrimaryExpr(c: *Context, it: *CTokenList.Iterator, source: []const u8,
5387 switch (tok.id) {5387 switch (tok.id) {
5388 .CharLiteral => {5388 .CharLiteral => {
5389 const first_tok = it.list.at(0);5389 const first_tok = it.list.at(0);
5390 const token = try appendToken(c, .CharLiteral, try zigifyEscapeSequences(c, source[tok.start..tok.end], source[first_tok.start..first_tok.end], source_loc));5390 if (
5391 const node = try c.a().create(ast.Node.CharLiteral);5391 (source[tok.start+1] == '\\' and tok.end - tok.start == 4)
5392 node.* = .{5392 or (source[tok.start+1] != '\\' and tok.end - tok.start == 3)
5393 .token = token,5393 ) {
5394 };5394 const token = try appendToken(c, .CharLiteral, try zigifyEscapeSequences(c, source[tok.start..tok.end], source[first_tok.start..first_tok.end], source_loc));
5395 return &node.base;5395 const node = try c.a().create(ast.Node.CharLiteral);
5396 node.* = .{
5397 .token = token,
5398 };
5399 return &node.base;
5400 } else {
5401 const token = try appendTokenFmt(c, .IntegerLiteral, "0x{x}", .{source[tok.start+1..tok.end-1]});
5402 const node = try c.a().create(ast.Node.IntegerLiteral);
5403 node.* = .{
5404 .token = token,
5405 };
5406 return &node.base;
5407 }
5396 },5408 },
5397 .StringLiteral => {5409 .StringLiteral => {
5398 const first_tok = it.list.at(0);5410 const first_tok = it.list.at(0);