@@ -6,19 +6,20 @@ namespace root_signature {
66
77// Lexer Definitions
88
9- static bool IsPreprocessorNumberChar (char C) {
9+ static bool IsNumberChar (char C) {
1010 // TODO: extend for float support with or without hexadecimal/exponent
1111 return isdigit (C); // integer support
1212}
1313
1414bool RootSignatureLexer::LexNumber (RootSignatureToken &Result) {
1515 // NumericLiteralParser does not handle the sign so we will manually apply it
16- Result.Signed = Buffer.front () == ' -' ;
16+ bool Negative = Buffer.front () == ' -' ;
17+ Result.Signed = Negative || Buffer.front () == ' +' ;
1718 if (Result.Signed )
1819 AdvanceBuffer ();
1920
2021 // Retrieve the possible number
21- StringRef NumSpelling = Buffer.take_while (IsPreprocessorNumberChar );
22+ StringRef NumSpelling = Buffer.take_while (IsNumberChar );
2223
2324 // Parse the numeric value and do semantic checks on its specification
2425 clang::NumericLiteralParser Literal (NumSpelling, SourceLoc,
@@ -35,7 +36,7 @@ bool RootSignatureLexer::LexNumber(RootSignatureToken &Result) {
3536 if (Literal.GetIntegerValue (X))
3637 return true ; // TODO: Report overflow error
3738
38- X = Result. Signed ? -X : X;
39+ X = Negative ? -X : X;
3940 Result.IntLiteral = (uint32_t )X.getZExtValue ();
4041 } else {
4142 return true ; // TODO: report unsupported number literal specification
@@ -84,7 +85,7 @@ bool RootSignatureLexer::LexToken(RootSignatureToken &Result) {
8485 }
8586
8687 // Numeric constant
87- if (isdigit (C) || C == ' -' )
88+ if (isdigit (C) || C == ' -' || C == ' + ' )
8889 return LexNumber (Result);
8990
9091 // All following tokens require at least one additional character
@@ -101,7 +102,8 @@ bool RootSignatureLexer::LexToken(RootSignatureToken &Result) {
101102 if (LexNumber (Result))
102103 return true ;
103104
104- // Lex number could also parse a float so ensure it was an unsigned int
105+ // Lex number could also parse a signed int/float so ensure it was an
106+ // unsigned int
105107 if (Result.Kind != TokenKind::int_literal || Result.Signed )
106108 return true ; // Return invalid number literal for register error
107109
0 commit comments