#ifndef MLIR_TOOLS_MLIRQUERY_QUERYPARSER_H
#define MLIR_TOOLS_MLIRQUERY_QUERYPARSER_H
#include "Matcher/Parser.h"
#include "mlir/Query/Query.h"
#include "mlir/Query/QuerySession.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/LineEditor/LineEditor.h"
namespace mlir::query {
class QuerySession;
class QueryParser {
public:
static QueryRef parse(llvm::StringRef line, const QuerySession &qs);
static std::vector<llvm::LineEditor::Completion>
complete(llvm::StringRef line, size_t pos, const QuerySession &qs);
private:
QueryParser(llvm::StringRef line, const QuerySession &qs)
: line(line), completionPos(nullptr), qs(qs) {}
llvm::StringRef lexWord();
template <typename T>
struct LexOrCompleteWord;
QueryRef completeMatcherExpression();
QueryRef endQuery(QueryRef queryRef);
QueryRef doParse();
llvm::StringRef line;
const char *completionPos;
std::vector<llvm::LineEditor::Completion> completions;
const QuerySession &qs;
};
}
#endif