forked from Soonad/Moonad
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Parser.fm
170 lines (118 loc) · 4.5 KB
/
Parser.fm
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
Parser.Error: Type
Parsec.Error(Unit)
Parser.Error.show: Parser.Error -> String
(e)
e<() String>
| (position) (unexpect) (expected)
String.concat("Error at ") |
String.concat(Nat.show(position)) |
String.concat(":") |
String.concat
| unexpect<() String>("")
| (v) String.concat(" unexpected ") |
String.concat(Parsec.Error.Item.show(v))(",");;;
|
String.concat(" expected ")
| List.show<Parsec.Error.Item>(Parsec.Error.Item.show)(expected);;;;;;
| (position) (messages) "fancy";
Parser.Reply: Type -> Type
(A) Parsec.Reply(Unit)(Unit)(A)
Parser.State.default: String -> Parser.State
(input) Parsec.State.default<Unit><Unit>(input)(Unit.new)
Parser.State : Type
Parsec.State(Unit)(Unit)
Parser.any_char : Parser(Char)
Parsec.any_char<Unit><Unit>
Parser.ap: <A: Type> -> <B: Type> -> Parser(A -> B) -> Parser(A) -> Parser(B)
<A> <B> (pf) (pa)
Parsec.ap<Unit><Unit><A><B>(pf)(pa)
Parser.bind: <A: Type> -> <B: Type> -> Parser(A) -> (A -> Parser(B)) -> Parser(B)
<A> <B> (pa) (pf) Parsec.bind<Unit><Unit><A><B>(pa)(pf)
Parser.char : Char -> Parser(Char)
(c) Parsec.char<Unit><Unit>(c)
Parser.choice: <A: Type> -> List(Parser(A)) -> Parser(A)
<A> (ps) Parsec.choice<Unit><Unit><A>(ps)
Parser.eof : Parser(Unit)
Parsec.eof<Unit><Unit>
Parser.fail: <A: Type> -> String -> Parser(A)
<A> (msg) Parsec.fail<Unit><Unit><A>(msg)
Parser : Type -> Type
(A) Parsec(Unit)(Unit)(A)
Parser.label : <A: Type> -> String -> Parser(A) -> Parser(A)
<A> (label) (p)
Parsec.label<Unit><Unit><A>(label)(p)
Parser.many: <A: Type> -> Parser(A) -> Parser(List(A))
<A> (p) Parsec.many<Unit><Unit><A>(p)
Parser.many_till: <A: Type> -> <B: Type> -> Parser(A) -> Parser(B) -> Parser(List(A))
<A> <B> (p) (q)
Parser.plus<List(A)>
| Parser.then<B><List(A)>(q)(Parser.pure<List(A)>(List.nil<A>));
| Parser.bind<A><List(A)>(p) | (x)
Parser.bind<List(A)><List(A)>(Parser.many_till<A><B>(p)(q)) | (xs)
Parser.pure<List(A)>(List.cons<A>(x)(xs));;;
Parser.observing: <A: Type> -> Parser(A) -> Parser(Either(Parser.Error)(A))
<A> (p)
Parsec.observing<Unit><Unit><A>(p)
Parser.optional: <A: Type> -> Parser(A) -> Parser(Maybe(A))
<A> (p) Parsec.optional<Unit><Unit><A>(p)
Parser.parse:
<A: Type> ->
(p: Parser(A)) ->
(s: String) ->
Parser.type(A)(Parser.run<A>(p)(Parser.State.default(s)))
<A> (p) (s)
Parsec.parse<Unit><Unit><A>(p)(Parser.State.default(s))
Parser.plus: <A: Type> -> Parser(A) -> Parser(A) -> Parser(A)
<A> (p) (q)
Parsec.plus<Unit><Unit><A>(p)(q)
Parser.pure: <A: Type> -> (a: A) -> Parser(A)
<A> (a)
<X> (s) (empty_value) () () () empty_value(s)(a)
Parser.run: <A: Type> -> Parser(A) -> Parser.State -> Parser.Reply(A)
<A> (p) (s)
Parsec.run<Unit><Unit><A>(p)(s)
Parser.run_default: <A: Type> -> Parser(A) -> String -> Parser.Reply(A)
<A> (p) (s)
Parsec.run<Unit><Unit><A>(p)(Parser.State.default(s))
Parser.run_either: <A: Type> -> Parser(A) -> String -> Either(Parser.Error)(A)
<A> (p) (s)
let reply = Parsec.run<Unit><Unit><A>(p)(Parser.State.default(s))
reply<() Either(Parser.Error)(A)>
| () (x) Either.right<Parser.Error><A>(x);
| () (e) Either.left<Parser.Error><A>(e);
| () (x) Either.right<Parser.Error><A>(x);
| () (e) Either.left<Parser.Error><A>(e);
Parser.skip_many: <A: Type> -> Parser(A) -> Parser(Unit)
<A> (p)
Parsec.skip_many<Unit><Unit><A>(p)
Parser.take: <A: Type> -> String -> Nat -> Parser(String)
<A> (err) (n)
Parsec.take<Unit><Unit><A>(err)(n)
Parser.take_while: (Char -> Bool) -> Parser(String)
(f) Parsec.take_while<Unit><Unit>(f)
Parser.take_while1: String -> (Char -> Bool) -> Parser(String)
(err) (f) Parsec.take_while1<Unit><Unit>(err)(f)
//Parser.test : String
// Parser.parse<String>
// | Parser.tokens("a");
// | "a";
Parser.then: <A: Type> -> <B: Type> -> Parser(A) -> Parser(B) -> Parser(B)
<A> <B> (pa) (pb)
Parsec.then<Unit><Unit><A><B>(pa)(pb)
// parse a single character with a validator function
// and a list of expected tokens
Parser.token:
<A: Type> ->
(Char -> Maybe(A)) ->
List(Parsec.Error.Item) ->
Parser(A)
<A> (f) (es)
Parsec.token<Unit><Unit><A>(f)(es)
Parser.tokens: String -> Parser(String)
(str) Parsec.tokens<Unit><Unit>(str)
Parser.try : <A: Type> -> Parser(A) -> Parser(A)
<A> (p) Parsec.try<Unit><Unit><A>(p)
Parser.type: (A: Type) -> Parser.Reply(A) -> Type
(A) (reply) Parsec.type(Unit)(Unit)(A)(reply)
Parser.zero: <A: Type> -> Parser(A)
<A> Parsec.zero<Unit><Unit><A>