我正在按照这个有用的系列博客文章探索 Camlp4,但我遇到了编译问题。这是我的 test.ml 文件的代码:
open Camlp4.PreCast
let _loc = Loc.ghost in
let cons =
let rec loop () =
try
match read_line () with
| "" -> []
| c -> c :: loop ()
with End_of_file -> [] in
loop () in
Printers.Ocaml.print_implem
<:str_item<
type t =
$Ast.TySum (_loc,
Ast.tyOr_of_list
(List.map
(fun c -> <:ctyp< $uid:c$ >>)
cons))$
let to_string = function
$Ast.mcOr_of_list
(List.map
(fun c -> <:match_case< $uid:c$ -> $`str:c$ >>)
cons)$
let of_string = function
$let ors =
Ast.mcOr_of_list
(List.map
(fun c -> <:match_case< $`str:c$ -> $uid:c$ >>)
cons) in
Ast.McOr(_loc,
ors,
<:match_case< _ -> invalid_arg "bad string" >>)$
>>
我正在使用这个编译命令: ocamlc -pp camlp4of -I +camlp4 -o variant camlp4lib.cma test.ml 但 ocamlc 发出:错误:未绑定模块 Printers.Ocaml
我想是编译命令的问题,但我找不到 Printers.Ocaml 的实现位置。
谢谢您的帮助!_ 神父。