From bc08ed7c94271a8ef0c73cfdeaae0245cfc32c99 Mon Sep 17 00:00:00 2001 From: Andrii Kurdiumov Date: Mon, 18 Nov 2024 13:00:07 +0500 Subject: [PATCH] Add bit precision to hex int literals (#164) Closes #161 --- Sources/SynKit/Libraries/C.Syntax/CLexer.cs | 1 + Sources/SynKit/Tests/C.Syntax.Tests/CLexerTests.cs | 1 + 2 files changed, 2 insertions(+) diff --git a/Sources/SynKit/Libraries/C.Syntax/CLexer.cs b/Sources/SynKit/Libraries/C.Syntax/CLexer.cs index 6c35fde7..e51ffdde 100644 --- a/Sources/SynKit/Libraries/C.Syntax/CLexer.cs +++ b/Sources/SynKit/Libraries/C.Syntax/CLexer.cs @@ -268,6 +268,7 @@ public CToken Next() if (this.TakeWhile(text, IsHex, ref offset) > 0) { this.TakeWhile(text, IsIntSuffix, ref offset); + this.TakeWhile(text, char.IsDigit, ref offset); return Make(CTokenType.IntLiteral, text.ToString()); } else diff --git a/Sources/SynKit/Tests/C.Syntax.Tests/CLexerTests.cs b/Sources/SynKit/Tests/C.Syntax.Tests/CLexerTests.cs index 9638de28..c4ed9446 100644 --- a/Sources/SynKit/Tests/C.Syntax.Tests/CLexerTests.cs +++ b/Sources/SynKit/Tests/C.Syntax.Tests/CLexerTests.cs @@ -84,6 +84,7 @@ public class CLexerTests [InlineData(Kind.IntLiteral, "0x1fbU")] [InlineData(Kind.IntLiteral, "0x1fbL")] [InlineData(Kind.IntLiteral, "0XABCU")] + [InlineData(Kind.IntLiteral, "0XABCU16")] [InlineData(Kind.IntLiteral, "123")] [InlineData(Kind.IntLiteral, "0123")]