Preprocessing error in code comments

I got this error while compiling my code using 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 line of insult is as follows:

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

How is this possible? I thought camlp4 should ignore quote characters in code comments?

+4
source share
1 answer

CamlP4 does not β€œignore” commented quotes. They should be balanced even in the comments.

This is just like OCaml requires string quotes to be balanced in comments. For instance:

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

rejected as syntax error. This may seem strange, but it is useful to easily comment out lines like "*)":

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

In your example, the same thing happens, but for quote P4 <:XXX< >> . Easy to fix. Use a space, for example:

 (* @M <: v <: @A *) 
+5
source

Source: https://habr.com/ru/post/1498138/


All Articles