File: odoc_see_lexer.mll

package info (click to toggle)
ocaml 4.05.0-11
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 27,060 kB
  • sloc: ml: 199,255; ansic: 44,187; sh: 5,611; makefile: 4,958; lisp: 4,223; asm: 4,220; awk: 306; perl: 87; fortran: 21; cs: 9; sed: 9
file content (103 lines) | stat: -rw-r--r-- 2,587 bytes parent folder | download | duplicates (3)
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
{
(**************************************************************************)
(*                                                                        *)
(*                                 OCaml                                  *)
(*                                                                        *)
(*             Maxence Guesdon, projet Cristal, INRIA Rocquencourt        *)
(*                                                                        *)
(*   Copyright 2001 Institut National de Recherche en Informatique et     *)
(*     en Automatique.                                                    *)
(*                                                                        *)
(*   All rights reserved.  This file is distributed under the terms of    *)
(*   the GNU Lesser General Public License version 2.1, with the          *)
(*   special exception on linking described in the file LICENSE.          *)
(*                                                                        *)
(**************************************************************************)

let print_DEBUG2 s = print_string s ; print_newline ()

(** the lexer for special comments. *)

open Odoc_parser

let buf = Buffer.create 32

}

rule main = parse
  [' ' '\013' '\009' '\012'] +
  {
    print_DEBUG2 "[' ' '\013' '\009' '\012'] +";
    main lexbuf
  }

  | [ '\010' ]
      {
        print_DEBUG2 " [ '\010' ] ";
        main lexbuf
      }

  | "<"
      {
        print_DEBUG2 "call url lexbuf" ;
        url lexbuf
      }

  | "\""
      {
        print_DEBUG2 "call doc lexbuf" ;
        doc lexbuf
      }


  | '\''
      {
        print_DEBUG2 "call file lexbuf" ;
        file lexbuf
      }

  | eof
      {
        print_DEBUG2 "EOF";
        EOF
      }

  | _
      {
        Buffer.reset buf ;
        Buffer.add_string buf (Lexing.lexeme lexbuf);
        desc lexbuf
      }

and url = parse
  | ([^'>'] | '\n')+">"
      {
        let s = Lexing.lexeme lexbuf in
        print_DEBUG2 ("([^'>'] | '\n')+ \">\" with "^s) ;
        See_url (String.sub s 0 ((String.length s) -1))
      }


and doc = parse
  | ([^'"'] | '\n' | "\\'")* "\""
      {
        let s = Lexing.lexeme lexbuf in
        See_doc (String.sub s 0 ((String.length s) -1))
      }

and file = parse
  | ([^'\''] | '\n' | "\\\"")* "'"
      {
        let s = Lexing.lexeme lexbuf in
        See_file (String.sub s 0 ((String.length s) -1))
      }


and desc = parse
    eof
      { Desc (Buffer.contents buf) }
  | _
      {
        Buffer.add_string buf (Lexing.lexeme lexbuf);
        desc lexbuf
      }