我正在使用 Emacs 在 Ocaml 中编写编译器。有人告诉我 -annot
一个文件.annot
可以在编译时生成,这可以帮助 Emacs 显示我的代码类型。但奇怪的是没有.annot
运行此 makefile 后生成.谁能告诉我这有什么问题?
此外,一旦我得到 .annot
,我是否需要设置任何东西(例如 .emacs
?)以便我的 Emacs 读取它并显示我的代码类型?
非常感谢你!
编辑 1:在 make clean
之后和 make
, 我有 .annot
...但是我仍然不知道如何使用这个.annot
在 Emacs 中。
Edit2:实际上有必要遵循 link ,复制本地文件夹中的文件,然后更新.emacs
.那么当一个.ml
在 Emacs 中编辑,C-c C-t 从 .annot
返回其类型.
最佳答案
关于您的 emacs 查询——我不使用 emacs——,这是来自 man-pages对于 ocamlc
,
-annot Dump detailed information about the compilation (types, bindings, tail-calls, etc). The information for file src.ml is put into file src.annot. In case of a type error, dump all the information inferred by the type-checker before the error. The src.annot file can be used with the emacs commands given in emacs/caml-types.el to display types and other annotations interactively.
the thread I mentioned previously 还有其他工具.
至于
Makefile
不创建 .annot
文件,我制作了一个模拟目录并成功拥有.annot
创建的文件。我也看不出你的 Makefile
有什么问题.您可能需要清理目录并重试,或切换到另一种方式来构建您的工具,如 ocamlbuild
--这需要最少的设置,虽然,我没有将它与 menhir
一起使用.我还会注意到
-annot
is new since OCaml 3.11.0 , 之前的标志是 -dtypes
.
关于emacs - 如何在 Emacs 中为 Ocaml 生成和设置注释?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6424751/