用ul中的camlp5替换camlp4

时间:2015-05-25 08:24:24

标签: ocaml camlp4 ocamlfind utop

我正在使用需要camlp5的OCaml代码;然而,toplevel(我正在使用utop)会自动加载更新的,不兼容的camlp4。这些是启动消息:

Findlib has been successfully loaded. Additional directives:
   #require "package";;      to load a package
   #list;;                   to list the available packages
   #camlp4o;;                to load camlp4 (standard syntax)
   #camlp4r;;                to load camlp4 (revised syntax)
   #predicates "p,q,...";;   to set these predicates
   Topfind.reset();;         to force that packages will be reloaded
   #thread;;                 to enable threads

.ocamlinit我使用的内容如下所示:

#use "topfind";;
#thread;;

我使用camlp5安装了opam,并在我发出ocamlfind list时显示;文件camlp5.cma也位于/home/<username>/.opam/4.02.1/lib/camlp5/camlp5.cma。 但是,尝试加载camlp5ocamlp5r会因Unknown directive camlp5o而失败。

如何让utop了解camlp5以及如何将camlp4替换为camlp5作为默认预处理器?

非常感谢提前!

1 个答案:

答案 0 :(得分:3)

$ ocaml
    OCaml version 4.02.1

Findlib has been successfully loaded. Additional directives:
  #require "package";;      to load a package
  #list;;                   to list the available packages
  #camlp4o;;                to load camlp4 (standard syntax)
  #camlp4r;;                to load camlp4 (revised syntax)
  #predicates "p,q,...";;   to set these predicates
  Topfind.reset();;         to force that packages will be reloaded
  #thread;;                 to enable threads

# #require "camlp5";;
/home/kakadu/.opam/4.02.1/lib/camlp5: added to search path
# #load "camlp5o.cma";;
    Camlp5 parsing version 6.12

#