12 #include "llvm/Support/CommandLine.h"
13 #include "llvm/Support/LSP/Logging.h"
14 #include "llvm/Support/LSP/Transport.h"
15 #include "llvm/Support/Program.h"
20 using llvm::lsp::JSONStreamStyle;
21 using llvm::lsp::Logger;
24 llvm::cl::opt<JSONStreamStyle> inputStyle{
26 llvm::cl::desc(
"Input JSON stream encoding"),
27 llvm::cl::values(clEnumValN(JSONStreamStyle::Standard,
"standard",
28 "usual LSP protocol"),
29 clEnumValN(JSONStreamStyle::Delimited,
"delimited",
30 "messages delimited by `// -----` lines, "
31 "with // comment support")),
32 llvm::cl::init(JSONStreamStyle::Standard),
35 llvm::cl::opt<bool> litTest{
38 "Abbreviation for -input-style=delimited -pretty -log=verbose. "
39 "Intended to simplify lit tests"),
40 llvm::cl::init(
false),
42 llvm::cl::opt<Logger::Level> logLevel{
44 llvm::cl::desc(
"Verbosity of log messages written to stderr"),
47 clEnumValN(Logger::Level::Info,
"info",
48 "High level execution tracing"),
49 clEnumValN(Logger::Level::Debug,
"verbose",
"Low level details")),
50 llvm::cl::init(Logger::Level::Info),
52 llvm::cl::opt<bool> prettyPrint{
54 llvm::cl::desc(
"Pretty-print JSON output"),
55 llvm::cl::init(
false),
57 llvm::cl::list<std::string> extraIncludeDirs(
58 "pdll-extra-dir", llvm::cl::desc(
"Extra directory of include files"),
59 llvm::cl::value_desc(
"directory"), llvm::cl::Prefix);
60 llvm::cl::list<std::string> compilationDatabases(
61 "pdll-compilation-database",
62 llvm::cl::desc(
"Compilation YAML databases containing additional "
63 "compilation information for .pdll files"));
65 llvm::cl::ParseCommandLineOptions(argc, argv,
"PDLL LSP Language Server");
68 inputStyle = JSONStreamStyle::Delimited;
69 logLevel = Logger::Level::Debug;
74 Logger::setLogLevel(logLevel);
77 llvm::sys::ChangeStdinToBinary();
78 llvm::lsp::JSONTransport transport(stdin, llvm::outs(), inputStyle,
static llvm::ManagedStatic< PassManagerOptions > options
This class implements all of the PDLL related functionality necessary for a language server.
llvm::LogicalResult runPdllLSPServer(PDLLServer &server, llvm::lsp::JSONTransport &transport)
Run the main loop of the LSP server using the given PDLL server and transport.
Include the generated interface declarations.
llvm::LogicalResult MlirPdllLspServerMain(int argc, char **argv)
Implementation for tools like mlir-pdll-lsp-server.