[clang] [HLSL][RootSignature] Implement Lexing of DescriptorTables (PR #122981)

Ashley Coleman via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 15 14:25:21 PST 2025


================
@@ -0,0 +1,152 @@
+#include "clang/Parse/ParseHLSLRootSignature.h"
+
+namespace llvm {
+namespace hlsl {
+namespace root_signature {
+
+// Lexer Definitions
+
+static bool IsPreprocessorNumberChar(char C) {
+  // TODO: extend for float support with or without hexadecimal/exponent
+  return isdigit(C); // integer support
+}
+
+bool RootSignatureLexer::LexNumber(RootSignatureToken &Result) {
+  // NumericLiteralParser does not handle the sign so we will manually apply it
+  Result.Signed = Buffer.front() == '-';
+  if (Result.Signed)
+    AdvanceBuffer();
+
+  // Retrieve the possible number
+  StringRef NumSpelling = Buffer.take_while(IsPreprocessorNumberChar);
+
+  // Parse the numeric value and so semantic checks on its specification
----------------
V-FEXrt wrote:

typo?
```suggestion
  // Parse the numeric value and do semantic checks on its specification
```

https://github.com/llvm/llvm-project/pull/122981


More information about the cfe-commits mailing list