-
Notifications
You must be signed in to change notification settings - Fork 0
/
comb.d.tl
149 lines (125 loc) · 7.16 KB
/
comb.d.tl
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
local record comb
record State<Data, Result>
source: string
data: Data
result: Result
index: integer
end
record Error
message: string
index: integer
end
record Tag<T, R>
tag: T
value: R
end
record TagWithIndex<T, R>
tag: T
index: integer
value: R
end
record Match
match: string
captures: {string}
end
record Binary<O, L, R>
operator: O
left: L
right: R
end
record Parser<Data, ResultFrom, ResultTo>
_transformer: function(State<Data, ResultFrom>): State<Data, ResultTo>, Error
new: function<D, F, T>(function(State<D, F>): State<D, T>, Error): Parser<D, F, T>
run: function<D, F, T>(self: Parser<D, F, T>, state: State<D, F>): State<D, T>, Error
parseData: function<D, F, T>(self: Parser<D, F, T>, data: D, source: string): State<D, T>, string
parseFile: function<D, F, T>(self: Parser<D, F, T>, data: D): State<D, T>, string
map: function<D, F, T, NT>(self: Parser<D, F, T>, mapper: function(state: State<D, T>): State<D, NT>): Parser<D, F, NT>
mapError: function<D, F, T>(self: Parser<D, F, T>, mapper: function(err: Error): Error): Parser<D, F, T>, Error
chain: function<D, F, T, NT>(self: Parser<D, F, T>, resultToParser: function(result: T): Parser<D, T, NT>): Parser<D, F, NT>, Error
noConsume: function<D, F, T>(self: Parser<D, F, T>): Parser<D, F, F>
peek: function<D, F, T>(self: Parser<D, F, T>): Parser<D, F, T>
atLeast: function<D, F, T>(self: Parser<D, F, T>, count: integer): Parser<D, F, {T}>
atMost: function<D, F, T>(self: Parser<D, F, T>, count: integer): Parser<D, F, {T}>
opposite: function<D, F, T>(self: Parser<D, F, T>, message: string): Parser<D, F, F>
tag: function<D, F, T, TT>(self: Parser<D, F, T>, name: TT): Parser<D, F, Tag<TT, T>>
tagWithIndex: function<D, F, T, TT>(self: Parser<D, F, T>, name: TT): Parser<D, F, TagWithIndex<TT, T>>
delimited: function<D, F, T>(self: Parser<D, F | T, T>, delimiter: Parser<D, any, any>): Parser<D, F, {T}>
delimited: function<D, R>(self: Parser<D, R, R>, delimiter: Parser<D, any, any>): Parser<D, R, {R}>
delimited: function<D, R>(self: Parser<D, any, R>, delimiter: Parser<D, any, any>): Parser<D, any, {R}>
enclosed: function<D, F, T>(self: Parser<D, F, T>, left: Parser<D, any, any>, right: Parser<D, any, any>): Parser<D, F, T>
prefix: function<D, F, T>(self: Parser<D, F, T>, other: Parser<D, any, any>): Parser<D, F, T>
suffix: function<D, F, T>(self: Parser<D, F, T>, other: Parser<D, any, any>): Parser<D, F, T>
optional: function<D, F, T>(self: Parser<D, F, T>): Parser<D, F, T>
wsl: function<F, T>(self: Parser<string, F, T>): Parser<string, F, T>
wsr: function<F, T>(self: Parser<string, F, T>): Parser<string, F, T>
wse: function<F, T>(self: Parser<string, F, T>): Parser<string, F, T>
index: function<D, F, T>(self: Parser<D, F, {T}>, key: integer): Parser<D, F, T>
index: function<D, F, K, V>(self: Parser<D, F, {K:V}>, key: K): Parser<D, F, V>
first: function<D, F, T>(self: Parser<D, F, {T}>): Parser<D, F, T>
second: function<D, F, T>(self: Parser<D, F, {T}>): Parser<D, F, T>
third: function<D, F, T>(self: Parser<D, F, {T}>): Parser<D, F, T>
last: function<D, F, T>(self: Parser<D, F, {T}>): Parser<D, F, T>
match: function<R>(self: Parser<string, R, Match>): Parser<string, R, string>
captures: function<R>(self: Parser<string, R, Match>): Parser<string, R, {string}>
concat: function<D, F, T>(self: Parser<D, F, {T}>, sep: string): Parser<D, F, string>
default: function<D, F, T>(self: Parser<D, F, T>, value: T): Parser<D, F, T>
default: function<D, F, T, DV>(self: Parser<D, F, T>, value: DV): Parser<D, F, T | DV>
value: function<D, F, T, V>(self: Parser<D, F, T>, value: V): Parser<D, F, V>
null: function<D, F, T>(self: Parser<D, F, T>): Parser<D, F, nil>
gsub: function(self: Parser<string, string, string>, pattern: string, repl: string, n: integer): Parser<string, string, string>
metamethod __call: function<D, F, T>(self: Parser<D, F, T>, state: State<D, F>): State<D, T>, Error
metamethod __add: function<D, F, T>(self: Parser<D, F, T>, other: Parser<D, F, T>): Parser<D, F, T>
metamethod __add: function<D, F, T, O>(self: Parser<D, F, T>, other: Parser<D, F, O>): Parser<D, F, T | O>
metamethod __sub: function<D, F, T, O>(self: Parser<D, F, T>, other: Parser<D, F, O>): Parser<D, F, T>
metamethod __mul: function<D, F, T, O>(self: Parser<D, F, T>, other: Parser<D, T, O>): Parser<D, F, O>
metamethod __div: function<D, F, T, NT>(self: Parser<D, F, T>, func: function(result: T): NT): Parser<D, F, NT>
metamethod __mod: function<D, F, T>(self: Parser<D, F, T>, func: function(err: Error): Error): Parser<D, F, T>
metamethod __len: function<D, F, T>(self: Parser<D, F, T>): Parser<D, F, F>
metamethod __pow: function<D, F, T>(self: Parser<D, F, T>, exponent: integer): Parser<D, F, {T}>
metamethod __unm: function<D, F, T>(self: Parser<D, F, T>): Parser<D, F, F>
end
isError: function(value: any): boolean
error: function<D, R>(state: State<D, R>, message: string): Error
literal: function(str: string): Parser<string, any, string>
pattern: function(pat: string): Parser<string, any, Match>
uptoLiteral: function(str: string): Parser<string, any, string>
uptoPattern: function(pat: string): Parser<string, any, string>
sequence: function<D, F, T>(parsers: {Parser<D, F | T, T>}): Parser<D, F, {T}>
sequence: function<D, R>(parsers: {Parser<D, R, R>}): Parser<D, R, {R}>
sequence: function<D, R>(parsers: {Parser<D, any, R>}): Parser<D, any, {R}>
choice: function<D, F, T>(parsers: {Parser<D, F, T>}): Parser<D, F, T>
choice: function<D, R>(parsers: {Parser<D, any, R>}): Parser<D, any, R>
choice: function<D>(parsers: {Parser<D, any, any>}): Parser<D, any, any>
proxy: function<D, F, T>(getParser: function(): Parser<D, F, T>): Parser<D, F, T>
delimited: function<D, F, T>(delimiter: Parser<D, any, any>): function(Parser<D, F | T, T>): Parser<D, F, {T}>
delimited: function<D, R>(delimiter: Parser<D, any, any>): function(Parser<D, R, R>): Parser<D, R, {R}>
delimited: function<D, R>(delimiter: Parser<D, any, any>): function(Parser<D, any, R>): Parser<D, any, {R}>
enclosed: function<D, F, T>(left: Parser<D, any, any>, right: Parser<D, any, any>): function(Parser<D, F, T>): Parser<D, F, T>
-- Brain too small for this one
-- binary: function<D, F, T, O>(parser: Parser<D, F | O, T>, precDef: {{Parser<D, T, O>}}):
u8: Parser<string, any, integer>
i8: Parser<string, any, integer>
u16le: Parser<string, any, integer>
i16le: Parser<string, any, integer>
u16be: Parser<string, any, integer>
i16be: Parser<string, any, integer>
u32le: Parser<string, any, integer>
i32le: Parser<string, any, integer>
u32be: Parser<string, any, integer>
i32be: Parser<string, any, integer>
digit: Parser<string, any, string>
digits: Parser<string, any, string>
letter: Parser<string, any, string>
letters: Parser<string, any, string>
whitespace: Parser<string, any, string>
mws: Parser<string, any, string>
cr: Parser<string, any, string>
lf: Parser<string, any, string>
crlf: Parser<string, any, string>
newline: Parser<string, any, string>
-- eof: Parser<string | {any}, any, any>
eof: Parser<string, any, any>
endline: Parser<string, any, any>
identifier: Parser<string, any, string>
end
return comb