35 #ifndef LLVM_CLANG_ASTMATCHERS_DYNAMIC_PARSER_H
36 #define LLVM_CLANG_ASTMATCHERS_DYNAMIC_PARSER_H
41 #include "llvm/ADT/ArrayRef.h"
42 #include "llvm/ADT/StringMap.h"
43 #include "llvm/ADT/StringRef.h"
49 namespace ast_matchers {
100 virtual std::optional<MatcherCtor>
131 virtual std::vector<MatcherCompletion>
141 std::optional<MatcherCtor>
151 llvm::ArrayRef<std::pair<MatcherCtor, unsigned>> Context)
override;
162 std::vector<MatcherCompletion>
183 static std::optional<DynTypedMatcher>
186 static std::optional<DynTypedMatcher>
190 static std::optional<DynTypedMatcher>
230 static std::vector<MatcherCompletion>
233 static std::vector<MatcherCompletion>
237 static std::vector<MatcherCompletion>
244 struct ScopedContextEntry;
251 bool parseBindID(std::string &BindID);
253 bool parseMatcherBuilder(
MatcherCtor Ctor,
const TokenInfo &NameToken,
255 bool parseMatcherExpressionImpl(
const TokenInfo &NameToken,
256 const TokenInfo &OpenToken,
257 std::optional<MatcherCtor> Ctor,
261 void addCompletion(
const TokenInfo &CompToken,
263 void addExpressionCompletions();
265 std::vector<MatcherCompletion>
268 CodeTokenizer *
const Tokenizer;
273 using ContextStackTy = std::vector<std::pair<MatcherCtor, unsigned>>;
275 ContextStackTy ContextStack;
276 std::vector<MatcherCompletion> Completions;
Registry of all known matchers.
Sema - This implements semantic analysis and AST building for C.
Helper class to manage error messages.
Sema implementation that uses the matcher registry to process the tokens.
ASTNodeKind nodeMatcherType(MatcherCtor) const override
std::optional< MatcherCtor > lookupMatcherCtor(StringRef MatcherName) override
Look up a matcher by name.
std::vector< ArgKind > getAcceptedCompletionTypes(llvm::ArrayRef< std::pair< MatcherCtor, unsigned >> Context) override
Compute the list of completion types for Context.
std::vector< MatcherCompletion > getMatcherCompletions(llvm::ArrayRef< ArgKind > AcceptedTypes) override
Compute the list of completions that match any of AcceptedTypes.
internal::MatcherDescriptorPtr buildMatcherCtor(MatcherCtor, SourceRange NameRange, ArrayRef< ParserValue > Args, Diagnostics *Error) const override
bool isBuilderMatcher(MatcherCtor Ctor) const override
VariantMatcher actOnMatcherExpression(MatcherCtor Ctor, SourceRange NameRange, StringRef BindID, ArrayRef< ParserValue > Args, Diagnostics *Error) override
Process a matcher expression.
Interface to connect the parser with the registry and more.
virtual VariantMatcher actOnMatcherExpression(MatcherCtor Ctor, SourceRange NameRange, StringRef BindID, ArrayRef< ParserValue > Args, Diagnostics *Error)=0
Process a matcher expression.
virtual internal::MatcherDescriptorPtr buildMatcherCtor(MatcherCtor, SourceRange NameRange, ArrayRef< ParserValue > Args, Diagnostics *Error) const =0
virtual bool isBuilderMatcher(MatcherCtor) const =0
virtual std::vector< ArgKind > getAcceptedCompletionTypes(llvm::ArrayRef< std::pair< MatcherCtor, unsigned >> Context)
Compute the list of completion types for Context.
virtual std::vector< MatcherCompletion > getMatcherCompletions(llvm::ArrayRef< ArgKind > AcceptedTypes)
Compute the list of completions that match any of AcceptedTypes.
virtual std::optional< MatcherCtor > lookupMatcherCtor(StringRef MatcherName)=0
Look up a matcher by name.
virtual ASTNodeKind nodeMatcherType(MatcherCtor) const =0
Matcher expression parser.
static bool parseExpression(StringRef &Code, Sema *S, const NamedValueMap *NamedValues, VariantValue *Value, Diagnostics *Error)
Parse an expression.
static std::vector< MatcherCompletion > completeExpression(StringRef &Code, unsigned CompletionOffset, Sema *S, const NamedValueMap *NamedValues)
Complete an expression at the given offset.
static std::optional< DynTypedMatcher > parseMatcherExpression(StringRef &MatcherCode, Diagnostics *Error)
static bool parseExpression(StringRef &Code, VariantValue *Value, Diagnostics *Error)
llvm::StringMap< VariantValue > NamedValueMap
static bool parseExpression(StringRef &Code, Sema *S, VariantValue *Value, Diagnostics *Error)
static std::vector< MatcherCompletion > completeExpression(StringRef &Code, unsigned CompletionOffset)
static std::vector< MatcherCompletion > completeExpression(StringRef &Code, unsigned CompletionOffset, Sema *S)
static std::optional< DynTypedMatcher > parseMatcherExpression(StringRef &MatcherCode, Sema *S, Diagnostics *Error)
static std::optional< DynTypedMatcher > parseMatcherExpression(StringRef &MatcherCode, Sema *S, const NamedValueMap *NamedValues, Diagnostics *Error)
Parse a matcher expression.
A variant matcher object.
A smart (owning) pointer for MatcherDescriptor.
Matcher descriptor interface.
The JSON file list parser is used to communicate input to InstallAPI.