================ @@ -89,6 +91,75 @@ class RootSignatureLexer { } }; +class RootSignatureParser { +public: + RootSignatureParser(SmallVector<RootElement> &Elements, + const SmallVector<RootSignatureToken> &Tokens); + + // Iterates over the provided tokens and constructs the in-memory + // representations of the RootElements. + // + // The return value denotes if there was a failure and the method will + // return on the first encountered failure, or, return false if it + // can sucessfully reach the end of the tokens. + bool Parse(); + +private: + bool ReportError(); // TODO: Implement this to report error through Diags + + // Root Element helpers + bool ParseRootElement(); + bool ParseDescriptorTable(); + bool ParseDescriptorTableClause(); + + // Common parsing helpers + bool ParseRegister(Register &Register); + + // Various flags/enum parsing helpers + bool ParseDescriptorRangeFlags(DescriptorRangeFlags &Flags); + bool ParseShaderVisibility(ShaderVisibility &Flag); + + // Increment the token iterator if we have not reached the end. + // Return value denotes if we were already at the last token. + bool ConsumeNextToken(); + + // Attempt to retrieve the next token, if TokenKind is invalid then there was + // no next token. + RootSignatureToken PeekNextToken(); + + // Is the current token one of the expected kinds + bool IsCurExpectedToken(ArrayRef<TokenKind> AnyExpected); ---------------- damyanp wrote:
Any reason this doesn't have an overload that takes a single `Expected` like all the ones below? Alternatively, if this one doesn't need the overload then do we need the other ones? https://github.com/llvm/llvm-project/pull/122982 _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits