首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Camlp4示例:未绑定的模块Printers.Ocaml

Camlp4示例:未绑定的模块Printers.Ocaml
EN

Stack Overflow用户
提问于 2012-11-23 16:47:05
回答 2查看 426关注 0票数 0

我正在浏览Camlp4,关注this上一系列有用的博客文章,但我遇到了编译问题。这是我的test.ml文件的代码:

代码语言:javascript
复制
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 camlp4lib.cma test.ml但ocamlc发出:错误:未绑定模块Printers.Ocaml

我猜是编译命令的问题,但我不知道Printers.Ocaml是在哪里实现的。

谢谢你的帮助!_ Fr.

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2012-11-23 17:48:43

您正在尝试访问Camlp4.PreCast.Printers.OCaml.print_implem,它在您的open Camlp4.PreCast之后可以作为Printers.OCaml.print_implem访问;请注意OCamlOcaml的不同大小写;OCaml是标准的,应该在OCaml工具和文档中一致使用(如果某些随编译器分发的库违反了约定,您可以提交一个次要的错误报告)。

PS:供您参考,下一版本的OCaml (4.01)可能会打印以下错误消息(用开发版本测试)

代码语言:javascript
复制
File "test.ml", line 13, characters 1-43:
Error: Unbound module Camlp4.PreCast.Printers.Ocaml
Did you mean OCaml?
票数 3
EN

Stack Overflow用户

发布于 2012-11-23 17:48:29

抱歉,我的错误是mudule Printers.Ocaml不存在,Printers.OCaml (大写C)存在。

我已经试了两天了。

解决了。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/13525580

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档