-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbark.mli
171 lines (125 loc) · 3.5 KB
/
bark.mli
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
(* Parsers *)
type ('context, 'problem, 'value) parser
type 'context located =
{ row : int
; col : int
; context : 'context
}
type ('context, 'problem) dead_end =
{ row : int
; col : int
; problem : 'problem
; context_stack : 'context located list
}
val run :
('c, 'x, 'a) parser ->
string ->
('a, ('c, 'x) dead_end list) result
val in_context :
'context ->
('context, 'x, 'a) parser ->
('context, 'x, 'a) parser
type 'x token =
| Token of string * 'x
(* Building blocks *)
val is_alpha : char -> bool
val is_num : char -> bool
val int : 'x -> ('c, 'x, int) parser
val float : 'x -> 'x -> ('c, 'x, float) parser
val symbol : 'x token -> ('c, 'x, unit) parser
val keyword : 'x token -> ('c, 'x, unit) parser
module String_set : sig
include Set.S with type elt = string
end
val variable :
start:(char -> bool) ->
inner:(char -> bool) ->
reserved:String_set.t ->
expecting:'x ->
('c, 'x, string) parser
val endd : 'x -> ('c, 'x, unit) parser
(* Pipelines *)
val succeed : 'a -> ('c, 'x, 'a) parser
val (|=) :
('c, 'x, 'a -> 'b) parser ->
('c, 'x, 'a) parser ->
('c, 'x, 'b) parser
val (|.) :
('c, 'x, 'keep) parser ->
('c, 'x, 'ignore) parser ->
('c, 'x, 'keep) parser
val lazily : (unit -> ('c, 'x, 'a) parser) -> ('c, 'x, 'a) parser
val and_then :
('a -> ('c, 'x, 'b) parser) ->
('c, 'x, 'a) parser ->
('c, 'x, 'b) parser
val problem : 'x -> ('c, 'x, 'a) parser
(* Branches *)
val one_of : ('c, 'x, 'a) parser list -> ('c, 'x, 'a) parser
val map : ('a -> 'b) -> ('c, 'x, 'a) parser -> ('c, 'x, 'b) parser
val backtrackable : ('c, 'x, 'a) parser -> ('c, 'x, 'a) parser
val commit : 'a -> ('c, 'x, 'a) parser
val token : 'x token -> ('c, 'x, unit) parser
(* Loops *)
type trailing =
| Forbidden
| Optional
| Mandatory
val sequence :
start:('x token) ->
separator:('x token) ->
endd:('x token) ->
spaces:(('c, 'x, unit) parser) ->
item:(('c, 'x, 'a) parser) ->
trailing:trailing ->
('c, 'x, 'a list) parser
type ('state, 'a) step =
| Loop of 'state
| Done of 'a
val loop :
'state ->
('state -> ('c, 'x, ('state, 'a) step) parser) ->
('c, 'x, 'a) parser
(* Whitespace *)
val spaces : ('c, 'x, unit) parser
val line_comment : 'x token -> ('c, 'x, unit) parser
type nestable =
| NotNestable
| Nestable
val multi_comment : 'x token -> 'x token -> nestable -> ('c, 'x, unit) parser
(* Chompers *)
val get_chomped_string : ('c, 'x, 'a) parser -> ('c, 'x, string) parser
val chomp_if : (char -> bool) -> 'x -> ('c, 'x, unit) parser
val chomp_while : (char -> bool) -> ('c, 'x, unit) parser
val chomp_until : 'x token -> ('c, 'x, unit) parser
val chomp_until_end_or : string -> ('c, 'x, unit) parser
val map_chomped_string :
(string -> 'a -> 'b) -> ('c, 'x, 'a) parser -> ('c, 'x, 'b) parser
val with_indent : int -> ('c, 'x, 'a) parser -> ('c, 'x, 'a) parser
(* Indentation *)
val get_indent : ('c, 'x, int) parser
val get_position : ('c, 'x, int * int) parser
(* Positions *)
val get_row : ('c, 'x, int) parser
val get_col : ('c, 'x, int) parser
val get_offset : ('c, 'x, int) parser
val get_source : ('c, 'x, string) parser
(* Syntax *)
module Syntax : sig
val ( let+ ) :
('c, 'x, 'a) parser ->
('a -> 'b) ->
('c, 'x, 'b) parser
val ( and+ ) :
('c, 'x, 'a) parser ->
('c, 'x, 'b) parser ->
('c, 'x, 'a * 'b) parser
val ( and* ) :
('c, 'x, 'a) parser ->
('c, 'x, 'b) parser ->
('c, 'x, 'a * 'b) parser
val ( let* ) :
('c, 'x, 'a) parser ->
('a -> ('c, 'x, 'b) parser) ->
('c, 'x, 'b) parser
end