Dear OCaml users,

I have implemented emacs-lisp code that correctly recognizes all
comments and strings in OCaml code, and interfaced it with the
fontification features of Emacs.  The code is committed in the
SVN repository, but if you want to try it before the next
release, I'm including it in attachment.

If you want to know why this is not a trivial problem, consider
the following OCaml program.

=======================================================
let l' _ = ();;
let _' _ = ();;
let l' = ();;
let b2_' = ();;
let a'a' = ();;
let f2 _ _ = ();;
let f3 _ _ _ = ();;

(* ==== easy stuff ==== *)

(* a comment *)
(* "a string" in a comment *)
(* "another string *)" in a comment *)
(* not a string '"' in a comment *)
"a string";;
'"';;              (* not a string *)

(* ==== hard stuff ==== *)

l'"' not not a string ";;
_'"' also not not a string";;
f2 0l'"';;            (* not not not a string *)
f2 0_'"';;            (* also not not not a string *)
f3 0.0l'"' not not not not a string ";;
f3 0.0_'"';;          (* not not not not not a string *)
f2 0b1_'"';;         (* not not not a string *)
f3 0b2_'"'  not not not not a string ";;
f3 0b02_'"';;         (* not not not not not a string *)
'\'';;   (* a char *)
'
';;      (* a char *)
'^M
';;      (* also a char [replace ^M with one CR character] *)
a'a';;   (* not a char *)
type '
a' t = X;;   (* also not a char *)
=======================================================


Obligatory troll: try to do the same in vim!

-- Damien


-- 
Caml-list mailing list.  Subscription management and archives:
https://sympa-roc.inria.fr/wws/info/caml-list
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

Attachment: caml-font.el
Description: Binary data


Reply via email to