21 ||
C ==
'e' ||
C ==
'E' ||
C ==
'-' ||
C ==
'+'
22 ||
C ==
'f' ||
C ==
'F';
25RootSignatureToken RootSignatureLexer::lexToken() {
27 advanceBuffer(Buffer.take_while(isspace).size());
30 return RootSignatureToken(TokenKind::end_of_stream, LocOffset);
33 RootSignatureToken
Result(LocOffset);
35 char C = Buffer.front();
39#define PUNCTUATOR(X, Y) \
41 Result.TokKind = TokenKind::pu_##X; \
45#include "clang/Lex/HLSLRootSignatureTokenKinds.def"
51 if (isdigit(
C) ||
C ==
'.') {
55 bool IsInteger = Result.NumSpelling.find_if_not(isdigit) == StringRef::npos;
58 IsInteger ? TokenKind::int_literal : TokenKind::float_literal;
59 advanceBuffer(Result.NumSpelling.size());
64 if (Buffer.size() <= 1) {
65 Result = RootSignatureToken(TokenKind::invalid, LocOffset);
70 char NextC = Buffer[1];
73 if ((
C ==
't' ||
C ==
's' ||
C ==
'u' ||
C ==
'b') && isdigit(NextC)) {
77 Result.TokKind = TokenKind::bReg;
80 Result.TokKind = TokenKind::tReg;
83 Result.TokKind = TokenKind::uReg;
86 Result.TokKind = TokenKind::sReg;
89 llvm_unreachable(
"Switch for an expected token was not provided");
96 advanceBuffer(
Result.NumSpelling.size());
102 StringRef TokSpelling =
103 Buffer.take_while([](
char C) {
return isalnum(
C) ||
C ==
'_'; });
106 auto Switch = llvm::StringSwitch<TokenKind>(TokSpelling);
107#define KEYWORD(NAME) Switch.CaseLower(#NAME, TokenKind::kw_##NAME);
108#define ENUM(NAME, LIT) Switch.CaseLower(LIT, TokenKind::en_##NAME);
109#include "clang/Lex/HLSLRootSignatureTokenKinds.def"
113 advanceBuffer(TokSpelling.size());
119 if (NextToken && NextToken->TokKind != TokenKind::end_of_stream) {
121 NextToken = std::nullopt;
132 NextToken = lexToken();
RootSignatureToken peekNextToken()
Returns the token that proceeds CurToken.
RootSignatureToken consumeToken()
Consumes and returns the next token.
static bool isNumberChar(char C)
RootSignatureToken::Kind TokenKind
The JSON file list parser is used to communicate input to InstallAPI.
@ Result
The result type of a method or function.