An OCaml comment containing "\" results in "comment not complete"

This comment is in order:

(* "\z" foo *)

This comment results in an error:

(* "\" foo *)

Is there a way to include literal single backslash in OCaml comments? Why doesn't the obvious approach work? I would expect the escape comments in the comments to be simply ignored.

For what it's worth, I'm trying to document tests for code that handles backslashes for its own purposes.

Thanks for reading.

Edit: The plot is thickening. The following comments are possible:

(* "\" "\"    notice-> " *)
(* "\" "  "\"    notice-> " *)
(* "\" foo  "\" notice-> " " " *)
(* "\" " "  "\"    notice-> " *)
(* "\" "" "  "\"    notice-> " *)
(* "\" arbitrary "s  "\"    notice-> " *)
(* " \" note the spacing  " \"    notice-> " *)
(* "\" <- notice-> " *)
(* "\"  "  <- notice -> " " *)
(* "" *) (* """" *)

But add or take one at the ends and it will break. The following errors are not executed (request additional data in the REPL):

(* "\"  "\" *)
(* "\" foo  "\" notice->  *)
(* "\" foo  "\" notice-> " " *)
(* "\" foo "\" notice-> " " " " *)
(* "\" foo " "\" notice-> " "  *)
(* "\" foo " " "\" notice-> " "  *)
(* " *) (* """ *) (* """"" *)

I'm pretty lost. It seems to be trying to balance the quotes, but escaped quotes throw it for a loop.

+4
1

OCaml OCaml (). , . , (* *).

"\\" . "\", OCaml. ( .)

OCaml, Lexical Conventions .

Edit

lukstafi, , , OCaml, , , . , (, , ) .

2

(* "\" "\"    notice-> " *)

( ). \ . \ . . ( OCaml \ , - , lukstafi .)

, , . ( ) Q ( ), B ( ), S , C .

(* "\" "\"    notice-> " *)
  C(QSS)B(SSSSSSSSSSSSS)C

:

(* " *) (* """ *) (* """"" *)
  C(SSSSSSS)()C     C()()(SSS

. , , . .

+6

All Articles