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

Chris B via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 11 09:27:07 PST 2025


================
@@ -0,0 +1,194 @@
+#include "clang/Parse/ParseHLSLRootSignature.h"
+
+namespace clang {
+namespace hlsl {
+
+// Lexer Definitions
+
+static bool IsNumberChar(char C) {
+  // TODO(#126565): extend for float support exponents
+  return isdigit(C); // integer support
+}
+
+bool RootSignatureLexer::LexNumber(RootSignatureToken &Result) {
----------------
llvm-beanz wrote:

As another note, lexing would usually identify the token, not try to interpret it, meaning any string of characters that meet the definition of a numeric constant. For example in the following code:

```
int8_t C = 2048;
float F = -2.8;
```

The token sequence generated by the lexer is [ `int8_t`, `C`, `=`, `2048`, `;`, `float`, `F`, `=` ,`-`, `2.8`, `;`].
Lexing does not validate that 2048 cannot fit into C.

I think most of what this function does is more accurately "parsing" a number rather than lexing.

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


More information about the cfe-commits mailing list