-2

我正在研究一个 Ocsigen 示例(http://ocsigen.org/tuto/manual/macaque)。

尝试编译程序时出现错误,如下所示。

File "testDB.ml", line 15, characters 14-81 (end at line 18, character 4):
While finding quotation "table" in a position of "expr":
Available quotation expanders are:
svglist (in a position of expr)
svg (in a position of expr)
html5list (in a position of expr)
html5 (in a position of expr)
xhtmllist (in a position of expr)
xhtml (in a position of expr)

Camlp4: Uncaught exception: Not_found

我的代码是:

 module Lwt_thread = struct
 include Lwt
 include Lwt_chan
 end
 module Lwt_PGOCaml = PGOCaml_generic.Make(Lwt_thread)
 module Lwt_Query = Query.Make_with_Db(Lwt_thread)(Lwt_PGOCaml)

 let get_db : unit -> unit Lwt_PGOCaml.t Lwt.t =
 let db_handler = ref None in
 fun () ->
   match !db_handler with
      | Some h -> Lwt.return h
      | None -> Lwt_PGOCaml.connect ~database:"testbase" ()

let table = <:table< users (
  login text NOT NULL,
  password text NOT NULL
) >>
..........

我使用 eliom-destillery 生成基本文件。我使用“make”来编译程序。

我尝试了许多不同的方法并进行了谷歌搜索,但我无法找出问题所在。非常感谢任何提示。

4

1 回答 1

0

一般来说,错误信息表明 CamlP4 不知道您使用的引用,这里table,在您的代码中使用为<:table< ... >>。引用可以通过 CamlP4 扩展pa_xxx.cmo(或pa_xxx.cma)模块添加。除非您打错了引用名称,否则您无法加载将其提供给 CamlP4 的扩展。

根据http://ocsigen.org/tuto/manual/macaque,Macaque(或其底层库?我不确定,因为我从未使用过它)提供了报价table。所以你必须指示 CamlP4 加载相应的扩展。我相信 vanilla eliom-destillery 是基本 eliom 编程的最低要求,不包括 Macaque 的扩展。

实际上文档http://ocsigen.org/tuto/manual/macaque指出了这一点:

我们需要在 Makefile 中引用 macaque:

SERVER_PACKAGE := macaque.syntax

这应该是table.

于 2014-03-11T01:42:12.233 回答