================ @@ -169,5 +220,399 @@ bool RootSignatureLexer::LexToken(RootSignatureToken &Result) { return false; } +// Parser Definitions + +RootSignatureParser::RootSignatureParser( + SmallVector<RootElement> &Elements, + const SmallVector<RootSignatureToken> &Tokens, DiagnosticsEngine &Diags) + : Elements(Elements), Diags(Diags) { + CurTok = Tokens.begin(); + LastTok = Tokens.end(); +} + +bool RootSignatureParser::Parse() { + // Handle edge-case of empty RootSignature() + if (CurTok == LastTok) + return false; + + bool First = true; + // Iterate as many RootElements as possible + while (!ParseRootElement(First)) { + First = false; + // Avoid use of ConsumeNextToken here to skip incorrect end of tokens error + CurTok++; + if (CurTok == LastTok) + return false; + if (EnsureExpectedToken(TokenKind::pu_comma)) + return true; + } + + return true; +} + +bool RootSignatureParser::ParseRootElement(bool First) { + if (First && EnsureExpectedToken(TokenKind::kw_DescriptorTable)) + return true; + if (!First && ConsumeExpectedToken(TokenKind::kw_DescriptorTable)) + return true; + + // Dispatch onto the correct parse method + switch (CurTok->Kind) { ---------------- inbelic wrote:
This pr only adds support for `DescriptorTable` as a root element. So there is no added support for a root descriptor range at the moment. A future pr that will handle the `RootCBV, etc` would be added to this switch statement and then dispatched onto its own method. 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