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 (***********************************************************************)
18 "[A-Z a-z_\192-\214\216-\246\248-\255'0-9]"
19 let blank = "[ \010\013\009\012]"
21 let remove_beginning_blanks s =
22 Str.global_replace (Str.regexp ("^"^blank^"+")) "" s
24 let remove_trailing_blanks s =
25 Str.global_replace (Str.regexp (blank^"+$")) "" s
27 let print_DEBUG s = print_string s; print_newline ()
32 %token <int * string option> Title
39 %token <string> CUSTOM
70 %token BEGIN_SHORTCUT_LIST_ITEM
71 %token BEGIN_SHORTCUT_ENUM_ITEM
72 %token SHORTCUT_LIST_ITEM
73 %token SHORTCUT_ENUM_ITEM
74 %token END_SHORTCUT_LIST
83 %type <Odoc_types.text> main
92 text_element_list { $1 }
96 text_element { [ $1 ] }
97 | text_element text_element_list { $1 :: $2 }
101 Title text END { let n, l_opt = $1 in Title (n, l_opt, $2) }
102 | BOLD text END { Bold $2 }
103 | ITALIC text END { Italic $2 }
104 | CUSTOM text END { Custom ($1, $2) }
105 | EMP text END { Emphasize $2 }
106 | SUPERSCRIPT text END { Superscript $2 }
107 | SUBSCRIPT text END { Subscript $2 }
108 | CENTER text END { Center $2 }
109 | LEFT text END { Left $2 }
110 | RIGHT text END { Right $2 }
111 | LIST list END { List $2 }
112 | ENUM list END { Enum $2 }
113 | CODE string END_CODE { Code $2 }
114 | CODE_PRE string END_CODE_PRE { CodePre $2 }
115 | ELE_REF string END {
116 let s2 = remove_beginning_blanks $2 in
117 let s3 = remove_trailing_blanks s2 in
120 | VAL_REF string END {
121 let s2 = remove_beginning_blanks $2 in
122 let s3 = remove_trailing_blanks s2 in
123 Ref (s3, Some RK_value)
125 | TYP_REF string END {
126 let s2 = remove_beginning_blanks $2 in
127 let s3 = remove_trailing_blanks s2 in
128 Ref (s3, Some RK_type)
130 | EXC_REF string END {
131 let s2 = remove_beginning_blanks $2 in
132 let s3 = remove_trailing_blanks s2 in
133 Ref (s3, Some RK_exception)
135 | MOD_REF string END {
136 let s2 = remove_beginning_blanks $2 in
137 let s3 = remove_trailing_blanks s2 in
138 Ref (s3, Some RK_module)
140 | MODT_REF string END {
141 let s2 = remove_beginning_blanks $2 in
142 let s3 = remove_trailing_blanks s2 in
143 Ref (s3, Some RK_module_type)
145 | CLA_REF string END {
146 let s2 = remove_beginning_blanks $2 in
147 let s3 = remove_trailing_blanks s2 in
148 Ref (s3, Some RK_class)
150 | CLT_REF string END {
151 let s2 = remove_beginning_blanks $2 in
152 let s3 = remove_trailing_blanks s2 in
153 Ref (s3, Some RK_class_type)
155 | ATT_REF string END {
156 let s2 = remove_beginning_blanks $2 in
157 let s3 = remove_trailing_blanks s2 in
158 Ref (s3, Some RK_attribute)
160 | MET_REF string END {
161 let s2 = remove_beginning_blanks $2 in
162 let s3 = remove_trailing_blanks s2 in
163 Ref (s3, Some RK_method)
165 | SEC_REF string END {
166 let s2 = remove_beginning_blanks $2 in
167 let s3 = remove_trailing_blanks s2 in
168 Ref (s3, Some (RK_section []))
170 | MOD_LIST_REF string END {
171 let s2 = remove_beginning_blanks $2 in
172 let s3 = remove_trailing_blanks s2 in
173 let l = Odoc_misc.split_with_blanks s3 in
176 | INDEX_LIST { Index_list }
177 | VERB string END_VERB { Verbatim $2 }
178 | LATEX string END_LATEX { Latex $2 }
179 | LINK string END text END { Link ($2, $4) }
180 | BLANK_LINE { Newline }
181 | BEGIN_SHORTCUT_LIST_ITEM shortcut_list END_SHORTCUT_LIST { List $2 }
182 | BEGIN_SHORTCUT_LIST_ITEM shortcut_list EOF { List $2 }
183 | BEGIN_SHORTCUT_ENUM_ITEM shortcut_enum END_SHORTCUT_LIST { Enum $2 }
184 | BEGIN_SHORTCUT_ENUM_ITEM shortcut_enum EOF { Enum $2 }
189 | string { [] (* A VOIR : un test pour voir qu'il n'y a que des blancs *) }
193 | item list { $1 :: $2 }
202 text shortcut_list2 { $1 :: $2 }
207 | SHORTCUT_LIST_ITEM shortcut_list { $2 }
211 text shortcut_enum2 { $1 :: $2 }
216 | SHORTCUT_ENUM_ITEM shortcut_enum { $2 }
222 | Char string { $1^$2 }