arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 1807.06702cs.PL
收藏

Merlin:OCaml语言服务器(体验报告)

Merlin: A Language Server for OCaml (Experience Report)

Frédéric Bour, Thomas Refis, Gabriel Scherer

摘要:

我们报告自2013年以来开发OCaml程序设计语言的语言服务器Merlin的经验。Merlin是一个连接到您最喜欢的文本编辑器的守护程序,并提供需要细粒度理解程序设计语言语法和静态语义的服务:关于警告和错误的即时反馈、自动完成、“光标下的代码类型”、“转到定义”等。语言服务器需要处理不完整和部分不正确的程序,并尝试增量,以尽量减少小的编辑操作后的重新计算。Merlin是通过仔细调整现有工具(OCamllex lexer和Menhir解析器生成器)来构建的,以更好地支持增量,不完整性和错误处理。这些扩展是优雅和通用的,正如OCaml社区为它们找到的有趣的、无计划的用途所证明的那样。它们可以适应任何语言的其他前端。除了增量,我们讨论了梅林与编辑器的沟通方式,描述了一些苛刻的功能和报告的一些非明显的困难,在建立良好的编辑器支持,从表达程序设计语言或令人沮丧的工具生态系统。我们希望这份经验报告能引起任何程序设计语言的交互式语言工具的作者的兴趣;许多设计选择可以重用,一些来之不易的教训可以作为警告。

英文摘要:

We report on the experience of developing Merlin, a language server for the OCaml programming language in development since 2013. Merlin is a daemon that connects to your favourite text editor and provides services that require a fine-grained understanding of the programming language syntax and static semantics: instant feedback on warnings and errors, autocompletion, `type of the code under the cursor', `go to definition', etc. Language servers need to handle incomplete and partially-incorrect programs, and try to be incremental to minimize recomputation after small editing actions. Merlin was built by carefully adapting the existing tools (the OCamllex lexer and Menhir parser generators) to better support incrementality, incompleteness and error handling. These extensions are elegant and general, as demonstrated by the interesting, unplanned uses that the OCaml community found for them. They could be adapted to other frontends -- in any language. Besides incrementality, we discuss the way Merlin communicates with editors, describe the design decisions that went into some demanding features and report on some of the non-apparent difficulties in building good editor support, emerging from expressive programming languages or frustrating tooling ecosystems. We expect this experience report to be of interest to authors of interactive language tooling for any programming language; many design choices may be reused, and some hard-won lessons can serve as warnings.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑