aboutsummaryrefslogtreecommitdiff
path: root/ide/find_phrase.mll
blob: 3c73d8f6728a748ef52fa1a38d61e83c05da2e7d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
{
  exception Lex_error of string
  let length = ref 0
}

rule next_phrase = parse
  | "(*" { incr length; incr length; 
	   skip_comment lexbuf;
	   next_phrase lexbuf}
  | '.'[' ''\n''\t''\r'] {incr length; incr length; Lexing.lexeme lexbuf}
  | _ 
      { 
	let c = Lexing.lexeme lexbuf in 
	if Ideutils.is_char_start c.[0] then incr length; 
	c^(next_phrase lexbuf) 
      }
  | eof  { raise (Lex_error "no phrase") }
and skip_comment = parse
  | "*)" {incr length; incr length; ()}
  | "(*" {incr length; incr length; 
	  skip_comment lexbuf;
	  skip_comment lexbuf}
  | _  { if Ideutils.is_char_start (Lexing.lexeme lexbuf).[0] then incr length; skip_comment lexbuf}
  | eof  { raise (Lex_error "No closing *)") }