ilya-biryukov added inline comments.

================
Comment at: clang-tools-extra/clangd/dexplorer/Dexplorer.cpp:39
+
+// FIXME(kbobyrev): Make this an actual REPL: probably use LLVM Command Line
+// library for parsing flags and arguments.
----------------
kbobyrev wrote:
> ilya-biryukov wrote:
> > Maybe we could expose `CommandLineParser` from 
> > `llvm/lib/Support/CommandLine.cpp` as a public API and use it here?
> > Not sure if there are any obstacles to doing so or how much work is it, 
> > though.
> > E.g. `cl::opt` seem to rely on being registered in the global parser and 
> > I'm not sure if there's an easy way out of it.
> Yes, that might be tricky. I have thought about a few options, e.g. consuming 
> the first token from the input string as the command and dispatching 
> arguments parsed via `CommandLineParser` manually (discarding those which are 
> not accepted by provided command, etc). There are still few complications: 
> help wouldn't be separate and easily accessible (unless hardcoded, which is 
> suboptimal).
> 
> Another approach I could think of would be simplifying the interface of each 
> command so that it would be easily parsed:
> 
> * `> fuzzy-find request.json`: this would require `FuzzyFindRequest` JSON 
> (de)serialization implementation, but that would be useful for the benchmark 
> tool, too
> * `> lookup-id symbolid`
> * `> load symbol.yaml`/`swap symbol.yaml`
> * `> density-hist`
> * `> tokens-distribution`
> * `> dense-tokens`
> * `> sparse-tokens`
> 
> And also a generic `> help` for the short reference of each command. Out of 
> all these commands, only Fuzzy Find request would benefit a lot from a proper 
> parsing of arguments, having JSON file representation might not be ideal, but 
> it looks OK for the first iteration for me. Fuzzy Find request would 
> presumably be one of the most used commands, though, but then again, we could 
> iterate if that is not really convinient.
The single-argument and no-arg commands certainly look nice. However, creating 
a separate file for each fuzzy-find request feels like a pain.

Have you tried prototyping parsing with `CommandLineParser `? What are the 
complications to exposing it from LLVM? 


https://reviews.llvm.org/D51628



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to