2013-11-08 08:08:23 +08:00
|
|
|
//===--- QueryParser.h - clang-query ----------------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_QUERY_QUERY_PARSER_H
|
|
|
|
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_QUERY_QUERY_PARSER_H
|
|
|
|
|
|
|
|
#include "Query.h"
|
2014-04-23 22:04:52 +08:00
|
|
|
#include "QuerySession.h"
|
2014-02-01 09:42:46 +08:00
|
|
|
#include "llvm/LineEditor/LineEditor.h"
|
2016-03-18 01:02:25 +08:00
|
|
|
#include <cstddef>
|
2014-02-01 09:42:46 +08:00
|
|
|
|
2013-11-08 08:08:23 +08:00
|
|
|
namespace clang {
|
|
|
|
namespace query {
|
|
|
|
|
2014-02-01 09:42:46 +08:00
|
|
|
class QuerySession;
|
|
|
|
|
|
|
|
class QueryParser {
|
|
|
|
public:
|
2014-03-03 00:48:59 +08:00
|
|
|
/// Parse \a Line as a query.
|
2014-02-01 09:42:46 +08:00
|
|
|
///
|
|
|
|
/// \return A QueryRef representing the query, which may be an InvalidQuery.
|
2014-04-23 22:04:52 +08:00
|
|
|
static QueryRef parse(StringRef Line, const QuerySession &QS);
|
2014-02-01 09:42:46 +08:00
|
|
|
|
2014-03-03 00:48:59 +08:00
|
|
|
/// Compute a list of completions for \a Line assuming a cursor at
|
|
|
|
/// \param Pos characters past the start of \a Line, ordered from most
|
2014-02-01 09:42:46 +08:00
|
|
|
/// likely to least likely.
|
|
|
|
///
|
2014-03-03 00:48:59 +08:00
|
|
|
/// \return A vector of completions for \a Line.
|
2014-04-23 22:04:52 +08:00
|
|
|
static std::vector<llvm::LineEditor::Completion>
|
|
|
|
complete(StringRef Line, size_t Pos, const QuerySession &QS);
|
2014-02-01 09:42:46 +08:00
|
|
|
|
|
|
|
private:
|
2014-04-23 22:04:52 +08:00
|
|
|
QueryParser(StringRef Line, const QuerySession &QS)
|
2016-11-08 15:50:19 +08:00
|
|
|
: Begin(Line.begin()), End(Line.end()), CompletionPos(nullptr), QS(QS) {}
|
2014-02-01 09:42:46 +08:00
|
|
|
|
|
|
|
StringRef lexWord();
|
|
|
|
|
|
|
|
template <typename T> struct LexOrCompleteWord;
|
|
|
|
|
|
|
|
QueryRef parseSetBool(bool QuerySession::*Var);
|
|
|
|
QueryRef parseSetOutputKind();
|
2014-04-23 22:04:52 +08:00
|
|
|
QueryRef completeMatcherExpression();
|
2014-02-01 09:42:46 +08:00
|
|
|
|
|
|
|
QueryRef endQuery(QueryRef Q);
|
|
|
|
|
|
|
|
/// \brief Parse [\p Begin,\p End).
|
|
|
|
///
|
|
|
|
/// \return A reference to the parsed query object, which may be an
|
|
|
|
/// \c InvalidQuery if a parse error occurs.
|
|
|
|
QueryRef doParse();
|
|
|
|
|
|
|
|
const char *Begin;
|
|
|
|
const char *End;
|
|
|
|
|
|
|
|
const char *CompletionPos;
|
|
|
|
std::vector<llvm::LineEditor::Completion> Completions;
|
2014-04-23 22:04:52 +08:00
|
|
|
|
|
|
|
const QuerySession &QS;
|
2014-02-01 09:42:46 +08:00
|
|
|
};
|
2013-11-08 08:08:23 +08:00
|
|
|
|
|
|
|
} // namespace query
|
|
|
|
} // namespace clang
|
|
|
|
|
2016-03-18 01:02:25 +08:00
|
|
|
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_QUERY_QUERY_PARSER_H
|