MLIR: lib/Tools/mlir-pdll-lsp-server/MlirPdllLspServerMain.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
14 #include "llvm/Support/CommandLine.h"
15 #include "llvm/Support/Program.h"
16
17 using namespace mlir;
19
21 llvm:🆑:opt inputStyle{
22 "input-style",
23 llvm:🆑:desc("Input JSON stream encoding"),
25 "usual LSP protocol"),
27 "messages delimited by `// -----` lines, "
28 "with // comment support")),
30 llvm:🆑:Hidden,
31 };
32 llvm:🆑:opt litTest{
33 "lit-test",
34 llvm:🆑:desc(
35 "Abbreviation for -input-style=delimited -pretty -log=verbose. "
36 "Intended to simplify lit tests"),
37 llvm:🆑:init(false),
38 };
39 llvm:🆑:optLogger::Level logLevel{
40 "log",
41 llvm:🆑:desc("Verbosity of log messages written to stderr"),
42 llvm:🆑:values(
45 "High level execution tracing"),
48 };
49 llvm:🆑:opt prettyPrint{
50 "pretty",
51 llvm:🆑:desc("Pretty-print JSON output"),
52 llvm:🆑:init(false),
53 };
54 llvm:🆑:liststd::string extraIncludeDirs(
55 "pdll-extra-dir", llvm:🆑:desc("Extra directory of include files"),
56 llvm:🆑:value_desc("directory"), llvm:🆑:Prefix);
57 llvm:🆑:liststd::string compilationDatabases(
58 "pdll-compilation-database",
59 llvm:🆑:desc("Compilation YAML databases containing additional "
60 "compilation information for .pdll files"));
61
62 llvm:🆑:ParseCommandLineOptions(argc, argv, "PDLL LSP Language Server");
63
64 if (litTest) {
67 prettyPrint = true;
68 }
69
70
72
73
74 llvm::sys::ChangeStdinToBinary();
75 JSONTransport transport(stdin, llvm::outs(), inputStyle, prettyPrint);
76
77
81 }
static llvm::ManagedStatic< PassManagerOptions > options
A transport class that performs the JSON-RPC communication with the LSP client.
static void setLogLevel(Level logLevel)
Set the severity level of the logger.
This class implements all of the PDLL related functionality necessary for a language server.
llvm::LogicalResult runPdllLSPServer(PDLLServer &server, JSONTransport &transport)
Run the main loop of the LSP server using the given PDLL server and transport.
@ Delimited
Messages are delimited by a '// --—' line. Comment lines start with //.
@ Standard
Encoding per the LSP specification, with mandatory Content-Length header.
Include the generated interface declarations.
llvm::LogicalResult MlirPdllLspServerMain(int argc, char **argv)
Implementation for tools like mlir-pdll-lsp-server.