]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/ocaml/ocaml/contrib/ocamldoc/odoc_see_lexer.mll
Update
[l4.git] / l4 / pkg / ocaml / ocaml / contrib / ocamldoc / odoc_see_lexer.mll
1 {
2 (***********************************************************************)
3 (*                             OCamldoc                                *)
4 (*                                                                     *)
5 (*            Maxence Guesdon, projet Cristal, INRIA Rocquencourt      *)
6 (*                                                                     *)
7 (*  Copyright 2001 Institut National de Recherche en Informatique et   *)
8 (*  en Automatique.  All rights reserved.  This file is distributed    *)
9 (*  under the terms of the Q Public License version 1.0.               *)
10 (*                                                                     *)
11 (***********************************************************************)
12
13 (* $Id: odoc_see_lexer.mll 5973 2003-11-24 10:44:07Z starynke $ *)
14
15 let print_DEBUG2 s = print_string s ; print_newline ()
16
17 (** the lexer for special comments. *)
18
19 open Lexing
20 open Odoc_parser
21
22 let buf = Buffer.create 32
23
24
25
26 rule main = parse
27   [' ' '\013' '\009' '\012'] +
28   { 
29     print_DEBUG2 "[' ' '\013' '\009' '\012'] +";
30     main lexbuf 
31   }
32
33   | [ '\010' ] 
34       { 
35         print_DEBUG2 " [ '\010' ] ";
36         main lexbuf 
37       }
38
39   | "<" 
40       { 
41         print_DEBUG2 "call url lexbuf" ;
42         url lexbuf 
43       } 
44
45   | "\"" 
46       { 
47         print_DEBUG2 "call doc lexbuf" ;
48         doc lexbuf
49       } 
50
51
52   | '\''
53       {
54         print_DEBUG2 "call file lexbuf" ;
55         file lexbuf
56       } 
57
58   | eof
59       { 
60         print_DEBUG2 "EOF";
61         EOF 
62       }
63
64   | _
65       { 
66         Buffer.reset buf ;
67         Buffer.add_string buf (Lexing.lexeme lexbuf); 
68         desc lexbuf
69       } 
70
71 and url = parse
72   | ([^'>'] | '\n')+">"
73       {
74         let s = Lexing.lexeme lexbuf in
75         print_DEBUG2 ("([^'>'] | '\n')+ \">\" with "^s) ;
76         See_url (String.sub s 0 ((String.length s) -1))
77       }
78
79       
80 and doc = parse
81   | ([^'"'] | '\n' | "\\'")* "\""
82       {
83         let s = Lexing.lexeme lexbuf in
84         See_doc (String.sub s 0 ((String.length s) -1))
85       }
86
87 and file = parse
88   | ([^'\''] | '\n' | "\\\"")* "'"
89       {
90         let s = Lexing.lexeme lexbuf in
91         See_file (String.sub s 0 ((String.length s) -1))
92       }
93
94
95 and desc = parse
96     eof
97       { Desc (Buffer.contents buf) }
98   | _ 
99       { 
100         Buffer.add_string buf (Lexing.lexeme lexbuf);
101         desc lexbuf
102       }