OCaml 解析器

Parser for OCaml

谁能给我推荐一个开源的完整 OCaml 解析器?

基本上,我想为 OCaml 实现我自己的类型检查器。理想情况下,解析器是用 OCaml 编写的。我只会用它来获取输入程序的 AST。 (要求预先填充标准库函数签名的初始打字环境可能太多了)

使用在 QPL license. It has everything needed to create your own compiler (and even has some documentation 下与 OCaml 一起分发的 compiler-libcompiler-lib 本质上是作为库提供的编译器。

否则,您可以使用 camlp4 获取分析树,但您需要从头开始重新实现其他所有内容。但在这种情况下,您不受 QPL 的限制。

it is probably too much to ask for the initial typing environment pre-filled with standard library function signatures

不是!查看文件 typing/predef.ml(i)

至于 stdlib,只使用与编译器相同的标准库,除了使用 Predef 中的值的 pervasive 之外,其余都是正常的 OCaml 代码,没有任何特殊情况(显然,引导程序除外)。