Preprocessing error in code comments

708 views Asked by At

I got this error when compiling my code with 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

The offending line is this:

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

How is this possible? I thought camlp4 is supposed to ignore quotation symbols in code comments?

1

There are 1 answers

1
camlspotter On BEST ANSWER

CamlP4 does not "ignore" commented quotations. They must be balanced even in comments.

It is just like OCaml requires string quotes balanced in comments. For example:

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

is rejected as a syntax error. It may sound strange but is useful to easily comment out strings like " *) ":

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

In your example the same thing happens but for a P4 quotation <:XXX< >>. Fix is easy. Use white space like:

(* @M <: v <: @A *)