4

使用以下代码编译代码时出现此错误corebuild

~/project $ corebuild debug.byte
ocamlfind ocamldep -syntax camlp4o -package bin_prot.syntax -package sexplib.syntax,comparelib.syntax,fieldslib.syntax,variantslib.syntax -package core -modules globals.ml > globals.ml.depends
+ ocamlfind ocamldep -syntax camlp4o -package bin_prot.syntax -package sexplib.syntax,comparelib.syntax,fieldslib.syntax,variantslib.syntax -package core -modules globals.ml > globals.ml.depends
File "globals.ml", line 744, characters 57-17803 (end at line 1402, character 0):
Quotation not terminated
Preprocessing error on file globals.ml
Error while running external preprocessor
Command line: camlp4 '-I' '/Users/mapleleaf/.opam/4.01.0dev+trunk/lib/ocaml/camlp4' '-I' '/Users/mapleleaf/.opam/4.01.0dev+trunk/lib/type_conv' '-I' '/Users/mapleleaf/.opam/4.01.0dev+trunk/lib/ocaml' '-I\
' '/Users/mapleleaf/.opam/4.01.0dev+trunk/lib/ocaml' '-I' '/Users/mapleleaf/.opam/4.01.0dev+trunk/lib/bin_prot' '-I' '/Users/mapleleaf/.opam/4.01.0dev+trunk/lib/bin_prot' '-I' '/Users/mapleleaf/.opam/4.0\
1.0dev+trunk/lib/ocaml' '-I' '/Users/mapleleaf/.opam/4.01.0dev+trunk/lib/num' '-I' '/Users/mapleleaf/.opam/4.01.0dev+trunk/lib/sexplib' '-I' '/Users/mapleleaf/.opam/4.01.0dev+trunk/lib/sexplib' '-I' '/Us\
ers/mapleleaf/.opam/4.01.0dev+trunk/lib/comparelib' '-I' '/Users/mapleleaf/.opam/4.01.0dev+trunk/lib/comparelib' '-I' '/Users/mapleleaf/.opam/4.01.0dev+trunk/lib/fieldslib' '-I' '/Users/mapleleaf/.opam/4\
.01.0dev+trunk/lib/fieldslib' '-I' '/Users/mapleleaf/.opam/4.01.0dev+trunk/lib/variantslib' '-I

违规行是这样的:

let allow_imm_inv = ref true (* imm inv to add of form @M<:v<:@A *)

这怎么可能?我认为camlp4应该忽略代码注释中的引号?

4

1 回答 1

5

CamlP4 不会“忽略”注释引用。即使在评论中,它们也必须保持平衡。

就像 OCaml 需要在注释中平衡字符串引号一样。例如:

(* " *)        <-  rejected as a syntax error

被拒绝为语法错误。这可能听起来很奇怪,但很容易注释掉像“*)”这样的字符串:

(* " *) " *)   <-  a valid comment (the syntax highlight gone crazy though)

在您的示例中,除了 P4 报价外,也会发生同样的事情<:XXX< >>。修复很容易。使用空格,例如:

(* @M <: v <: @A *)
于 2013-08-21T07:56:46.840 回答