================
@@ -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) {
+  // NumericLiteralParser does not handle the sign so we will manually apply it
+  bool Negative = Buffer.front() == '-';
+  bool Signed = Negative || Buffer.front() == '+';
----------------
llvm-beanz wrote:

I have a grammar question here. Is the `-` or `+` part of the numeric literal 
token, or is it better (as in C++), that the unary operator be its own token? 
The reason I ask, is that if you look at the C++ (& HLSL) grammar leading `-` 
is a unary operator, _not_ part of the numeric literal token string. This is 
why the Clang parser really only supports parsing positive numbers, the 
negation is a modifier.

Where this becomes relevant is a few lines below where you emit the 
`err_hlsl_expected_number_literal`, that's really an error that should be 
coming from _parsing_ not lexing because you're combining adjacent tokens and 
recognizing that the grammar requires a number follow the sign token.

https://github.com/llvm/llvm-project/pull/122981
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to