1
(************************************************************************)
2
(* v * The Coq Proof Assistant / The Coq Development Team *)
3
(* <O___,, * CNRS-Ecole Polytechnique-INRIA Futurs-Universite Paris Sud *)
4
(* \VV/ **************************************************************)
5
(* // * This file is distributed under the terms of the *)
6
(* * GNU Lesser General Public License Version 2.1 *)
7
(************************************************************************)
9
(* $Id: find_phrase.mll 9240 2006-10-13 17:51:11Z notin $ *)
12
exception Lex_error of string
14
let buff = Buffer.create 513
20
rule next_phrase = parse
21
| "(*" { incr length; incr length;
24
| '"'[^'"']*'"' { let lexeme = Lexing.lexeme lexbuf in
25
let ulen = Glib.Utf8.length lexeme in
26
length := !length + ulen;
27
Buffer.add_string buff lexeme;
30
| phrase_sep[' ''\n''\t''\r'] {
32
if !Preferences.current.Preferences.lax_syntax
33
then length := !length + 1
34
else length := !length + 2
36
Buffer.add_string buff (Lexing.lexeme lexbuf);
40
length := !length + 1;
41
Buffer.add_string buff (Lexing.lexeme lexbuf);
43
| phrase_sep phrase_sep
45
length := !length + 2;
46
Buffer.add_string buff (Lexing.lexeme lexbuf);
51
let c = Lexing.lexeme_char lexbuf 0 in
52
if Ideutils.is_char_start c then incr length;
53
Buffer.add_char buff c ;
56
| eof { raise (Lex_error "Phrase should end with . followed by a separator") }
57
and skip_comment = parse
58
| "*)" {incr length; incr length; ()}
59
| "(*" {incr length; incr length;
62
| _ { if Ideutils.is_char_start (Lexing.lexeme_char lexbuf 0) then
65
| eof { raise (Lex_error "No closing *)") }