2 (***********************************************************************)
5 (* Maxence Guesdon, projet Cristal, INRIA Rocquencourt *)
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. *)
11 (***********************************************************************)
16 open Odoc_comments_global
18 let uppercase = "[A-Z\192-\214\216-\222]"
20 "[A-Za-z_\192-\214\216-\246\248-\255'0-9]"
21 let blank = "[ \010\013\009\012]"
23 let print_DEBUG s = print_string s; print_newline ()
26 %token <string * (string option)> Description
28 %token <string> See_url
29 %token <string> See_file
30 %token <string> See_doc
40 %token <string> T_CUSTOM
47 %start main info_part2 see_info
48 %type <(string * (string option)) option> main
49 %type <unit> info_part2
50 %type <Odoc_types.see_ref * string> see_info
55 see_ref Desc { ($1, $2) }
59 See_url { Odoc_types.See_url $1 }
60 | See_file { Odoc_types.See_file $1 }
61 | See_doc { Odoc_types.See_doc $1 }
65 Description { Some $1 }
70 element_list EOF { () }
75 | element element_list { () }
93 (* isolate the identificator *)
94 (* we only look for simple id, no pattern nor tuples *)
96 match Str.split (Str.regexp (blank^"+")) s with
99 raise (Failure "usage: @param id description")
101 print_DEBUG ("Identificator "^id);
102 let reg = identchar^"+" in
103 print_DEBUG ("reg="^reg);
104 if Str.string_match (Str.regexp reg) id 0 then
105 let remain = String.sub s (String.length id) ((String.length s) - (String.length id)) in
106 print_DEBUG ("T_PARAM Desc remain="^remain);
107 let remain2 = Str.replace_first (Str.regexp ("^"^blank^"+")) "" remain in
108 params := !params @ [(id, remain2)]
110 raise (Failure (id^" is not a valid parameter identificator in \"@param "^s^"\""))
114 T_AUTHOR Desc { authors := !authors @ [ $2 ] }
117 T_VERSION Desc { version := Some $2 }
120 T_SEE Desc { sees := !sees @ [$2] }
123 T_SINCE Desc { since := Some $2 }
126 T_DEPRECATED Desc { deprecated := Some $2 }
131 (* isolate the exception construtor name *)
133 match Str.split (Str.regexp (blank^"+")) s with
136 raise (Failure "usage: @raise Exception description")
138 print_DEBUG ("exception "^id);
139 let reg = uppercase^identchar^"*"^"\\(\\."^uppercase^identchar^"*\\)*" in
140 print_DEBUG ("reg="^reg);
141 if Str.string_match (Str.regexp reg) id 0 then
142 let remain = String.sub s (String.length id) ((String.length s) - (String.length id)) in
143 let remain2 = Str.replace_first (Str.regexp ("^"^blank^"+")) "" remain in
144 raised_exceptions := !raised_exceptions @ [(id, remain2)]
146 raise (Failure (id^" is not a valid exception constructor in \"@raise "^s^"\""))
150 T_RETURN Desc { return_value := Some $2 }
154 T_CUSTOM Desc { customs := !customs @ [($1, $2)] }