-
Notifications
You must be signed in to change notification settings - Fork 78
/
Copy pathodoc_parser.mly
121 lines (102 loc) · 2.68 KB
/
odoc_parser.mly
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
%{
(**************************************************************************)
(* *)
(* 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. *)
(* *)
(**************************************************************************)
open Odoc_comments_global
%}
%token <string * (string option)> Description
%token <string> See_url
%token <string> See_file
%token <string> See_doc
%token <string> T_PARAM
%token T_AUTHOR
%token T_VERSION
%token T_SEE
%token T_SINCE
%token <string> T_BEFORE
%token T_DEPRECATED
%token <string> T_RAISES
%token T_RETURN
%token <string> T_CUSTOM
%token EOF
%token <string> Desc
/* Start Symbols */
%start main info_part2 see_info
%type <(string * (string option)) option> main
%type <unit> info_part2
%type <Odoc_types.see_ref * string> see_info
%%
see_info:
see_ref Desc { ($1, $2) }
;
see_ref:
See_url { Odoc_types.See_url $1 }
| See_file { Odoc_types.See_file $1 }
| See_doc { Odoc_types.See_doc $1 }
;
main:
Description { Some $1 }
| EOF { None }
;
info_part2:
element_list EOF { () }
;
element_list:
element { () }
| element element_list { () }
;
element:
| param { () }
| author { () }
| version { () }
| see { () }
| since { () }
| before { () }
| deprecated { () }
| raise_exc { () }
| return { () }
| custom { () }
;
param:
T_PARAM Desc { params := !params @ [($1, $2)] }
;
author:
T_AUTHOR Desc { authors := !authors @ [ $2 ] }
;
version:
T_VERSION Desc { version := Some $2 }
;
see:
T_SEE Desc { sees := !sees @ [$2] }
;
since:
T_SINCE Desc { since := Some $2 }
;
before:
T_BEFORE Desc { before := !before @ [($1, $2)] }
;
deprecated:
T_DEPRECATED Desc { deprecated := Some $2 }
;
raise_exc:
T_RAISES Desc
{ raised_exceptions := !raised_exceptions @ [($1, $2)] }
;
return:
T_RETURN Desc { return_value := Some $2 }
;
custom:
T_CUSTOM Desc { customs := !customs @ [($1, $2)] }
;
%%