Go to the documentation of this file.
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/Optional.h"
43 #include "llvm/ADT/StringMap.h"
44 #include "llvm/ADT/StringRef.h"
49 namespace ast_matchers {
131 virtual std::vector<MatcherCompletion>
151 llvm::ArrayRef<std::pair<MatcherCtor, unsigned>> Context)
override;
162 std::vector<MatcherCompletion>
230 static std::vector<MatcherCompletion>
233 static std::vector<MatcherCompletion>
237 static std::vector<MatcherCompletion>
244 struct ScopedContextEntry;
253 bool parseMatcherBuilder(
MatcherCtor Ctor,
const TokenInfo &NameToken,
255 bool parseMatcherExpressionImpl(
const TokenInfo &NameToken,
256 const TokenInfo &OpenToken,
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;
283 #endif // LLVM_CLANG_ASTMATCHERS_DYNAMIC_PARSER_H
static bool parseExpression(StringRef &Code, Sema *S, const NamedValueMap *NamedValues, VariantValue *Value, Diagnostics *Error)
Parse an expression.
virtual ASTNodeKind nodeMatcherType(MatcherCtor) const =0
virtual std::vector< ArgKind > getAcceptedCompletionTypes(llvm::ArrayRef< std::pair< MatcherCtor, unsigned >> Context)
Compute the list of completion types for Context.
static llvm::Optional< DynTypedMatcher > parseMatcherExpression(StringRef &MatcherCode, Sema *S, const NamedValueMap *NamedValues, Diagnostics *Error)
Parse a matcher expression.
static std::vector< MatcherCompletion > completeExpression(StringRef &Code, unsigned CompletionOffset, Sema *S)
virtual llvm::Optional< MatcherCtor > lookupMatcherCtor(StringRef MatcherName)=0
Look up a matcher by name.
Sema implementation that uses the matcher registry to process the tokens.
llvm::Optional< MatcherCtor > lookupMatcherCtor(StringRef MatcherName) override
Look up a matcher by name.
static bool parseExpression(StringRef &Code, VariantValue *Value, Diagnostics *Error)
static std::vector< MatcherCompletion > completeExpression(StringRef &Code, unsigned CompletionOffset, Sema *S, const NamedValueMap *NamedValues)
Complete an expression at the given offset.
VariantMatcher actOnMatcherExpression(MatcherCtor Ctor, SourceRange NameRange, StringRef BindID, ArrayRef< ParserValue > Args, Diagnostics *Error) override
Process a matcher expression.
std::vector< ArgKind > getAcceptedCompletionTypes(llvm::ArrayRef< std::pair< MatcherCtor, unsigned >> Context) override
Compute the list of completion types for Context.
llvm::StringMap< VariantValue > NamedValueMap
static std::vector< MatcherCompletion > completeExpression(StringRef &Code, unsigned CompletionOffset)
static llvm::Optional< DynTypedMatcher > parseMatcherExpression(StringRef &MatcherCode, Diagnostics *Error)
static bool parseExpression(StringRef &Code, Sema *S, VariantValue *Value, Diagnostics *Error)
bool isBuilderMatcher(MatcherCtor Ctor) const override
Matcher expression parser.
virtual std::vector< MatcherCompletion > getMatcherCompletions(llvm::ArrayRef< ArgKind > AcceptedTypes)
Compute the list of completions that match any of AcceptedTypes.
Interface to connect the parser with the registry and more.
virtual internal::MatcherDescriptorPtr buildMatcherCtor(MatcherCtor, SourceRange NameRange, ArrayRef< ParserValue > Args, Diagnostics *Error) const =0
A variant matcher object.
Sema - This implements semantic analysis and AST building for C.
Matcher descriptor interface.
internal::MatcherDescriptorPtr buildMatcherCtor(MatcherCtor, SourceRange NameRange, ArrayRef< ParserValue > Args, Diagnostics *Error) const override
virtual bool isBuilderMatcher(MatcherCtor) const =0
std::vector< MatcherCompletion > getMatcherCompletions(llvm::ArrayRef< ArgKind > AcceptedTypes) override
Compute the list of completions that match any of AcceptedTypes.
Helper class to manage error messages.
static llvm::Optional< DynTypedMatcher > parseMatcherExpression(StringRef &MatcherCode, Sema *S, Diagnostics *Error)
A smart (owning) pointer for MatcherDescriptor.
virtual VariantMatcher actOnMatcherExpression(MatcherCtor Ctor, SourceRange NameRange, StringRef BindID, ArrayRef< ParserValue > Args, Diagnostics *Error)=0
Process a matcher expression.
ASTNodeKind nodeMatcherType(MatcherCtor) const override