1use crate::{Col, Row};
10use nash_region::Position;
11
12#[derive(Debug)]
17pub enum Error<'a> {
18 ModuleNameUnspecified(&'a str),
19 ModuleNameMismatch {
20 expected: &'a str,
21 actual: &'a str,
22 row: Row,
23 col: Col,
24 },
25 ParseError(&'a Module<'a>),
26}
27
28#[derive(Debug)]
33pub enum Module<'a> {
34 Space(Space, Row, Col),
35 BadEnd(Row, Col),
36 Problem(Row, Col),
37 Validator(Row, Col),
38 Name(Row, Col),
39 Exposing(&'a Exposing, Row, Col),
40 FreshLine(Row, Col),
41 ImportStart(Row, Col),
42 ImportName(Row, Col),
43 ImportAs(Row, Col),
44 ImportAlias(Row, Col),
45 ImportExposing(Row, Col),
46 ImportExposingList(&'a Exposing, Row, Col),
47 ImportEnd(Row, Col),
48 ImportIndentName(Row, Col),
49 ImportIndentAlias(Row, Col),
50 ImportIndentExposingList(Row, Col),
51 Infix(Row, Col),
52 Declarations(&'a Decl<'a>, Row, Col),
53 Tests(&'a Tests<'a>, Row, Col),
54}
55
56#[derive(Debug)]
57pub enum Tests<'a> {
58 Space(Space, Row, Col),
59 Import(&'a Module<'a>, Row, Col),
60 Test(&'a Test<'a>, Row, Col),
61 Start(Row, Col),
62 IndentStart(Row, Col),
63 Alignment(usize, Row, Col),
64}
65
66#[derive(Debug)]
67pub enum Test<'a> {
68 Space(Space, Row, Col),
69 Name(StringError, Row, Col),
70 NameStart(Row, Col),
71 OnceOnUnitTest(Row, Col),
72 WithinOpen(Row, Col),
73 WithinKind(Row, Col),
74 WithinNumber(Number, Row, Col),
75 WithinDuplicate(Row, Col),
76 WithinEnd(Position, Row, Col),
77 Equals(Row, Col),
78 Do(Row, Col),
79 Body(&'a Do<'a>, Row, Col),
80 Let(Row, Col),
81 Pattern(&'a Pattern<'a>, Row, Col),
82 Via(Row, Col),
83 Fuzzer(&'a Expr<'a>, Row, Col),
84 In(Row, Col),
85 IndentName(Row, Col),
86 IndentEquals(Row, Col),
87 IndentBody(Row, Col),
88 IndentBinder(Row, Col),
89 IndentIn(Row, Col),
90 BinderAlignment(usize, Row, Col),
91}
92
93#[derive(Debug)]
94pub enum Exposing {
95 Space(Space, Row, Col),
96 Start(Row, Col),
97 Value(Row, Col),
98 Operator(Row, Col),
99 OperatorReserved(BadOperator, Row, Col),
100 OperatorRightParen(Position, Row, Col),
101 TypePrivacyEnd(Position, Row, Col),
102 TypePrivacy(Row, Col),
103 TypeName(Row, Col),
104 End(Row, Col),
105 IndentEnd(Row, Col),
106 IndentValue(Row, Col),
107}
108
109#[derive(Debug)]
114pub enum Decl<'a> {
115 Start(Row, Col),
116 Space(Space, Row, Col),
117 Type(&'a DeclType<'a>, Row, Col),
118 Def(&'a str, &'a DeclDef<'a>, Row, Col),
119 FreshLineAfterDocComment(Row, Col),
120 Attribute(&'a Attribute<'a>, Row, Col),
121 Trait(&'a Trait<'a>, Row, Col),
122 Impl(&'a Impl<'a>, Row, Col),
123}
124
125#[derive(Debug)]
126pub enum Impl<'a> {
127 Space(Space, Row, Col),
128 Head(&'a Type<'a>, Row, Col),
129 BadHead(Row, Col),
130 Where(Row, Col),
131 Method(&'a str, &'a Def<'a>, Row, Col),
132 MethodName(Row, Col),
133 IndentHead(Row, Col),
134 IndentWhere(Row, Col),
135 IndentMethod(Row, Col),
136 Alignment(usize, Row, Col),
137}
138
139#[derive(Debug)]
140pub enum Trait<'a> {
141 Space(Space, Row, Col),
142 Name(Row, Col),
143 Param(&'a TypeParam<'a>, Row, Col),
144 Super(&'a Type<'a>, Row, Col),
145 SuperArg(Row, Col),
146 Where(Row, Col),
147 MethodName(Row, Col),
148 Colon(Row, Col),
149 Type(&'a Type<'a>, Row, Col),
150 Default(&'a str, &'a Def<'a>, Row, Col),
151 IndentName(Row, Col),
152 IndentParam(Row, Col),
153 IndentWhere(Row, Col),
154 IndentMethod(Row, Col),
155 IndentColon(Row, Col),
156 IndentType(Row, Col),
157 Alignment(usize, Row, Col),
158}
159
160#[derive(Debug)]
161pub enum Attribute<'a> {
162 Name(Row, Col),
163 Arg(&'a Expr<'a>, Row, Col),
164 End(Position, Row, Col),
165 Space(Space, Row, Col),
166 FreshLine(Row, Col),
167 IndentArg(Row, Col),
168 IndentEnd(Position, Row, Col),
169}
170
171#[derive(Debug)]
172pub enum DeclDef<'a> {
173 Space(Space, Row, Col),
174 Equals(Row, Col),
175 Type(&'a Type<'a>, Row, Col),
176 Arg(&'a Pattern<'a>, Row, Col),
177 Body(&'a Expr<'a>, Row, Col),
178 NameRepeat(Row, Col),
179 NameMatch(&'a str, Row, Col),
180 IndentType(Row, Col),
181 IndentEquals(Row, Col),
182 IndentBody(Row, Col),
183}
184
185#[derive(Debug)]
186pub enum DeclType<'a> {
187 Space(Space, Row, Col),
188 Name(Row, Col),
189 Alias(&'a TypeAlias<'a>, Row, Col),
190 Union(&'a CustomType<'a>, Row, Col),
191 IndentName(Row, Col),
192}
193
194#[derive(Debug)]
195pub enum TypeAlias<'a> {
196 Space(Space, Row, Col),
197 Name(Row, Col),
198 Param(&'a TypeParam<'a>, Row, Col),
199 Equals(Row, Col),
200 Body(&'a Type<'a>, Row, Col),
201 IndentEquals(Row, Col),
202 IndentBody(Row, Col),
203}
204
205#[derive(Debug)]
206pub enum CustomType<'a> {
207 Space(Space, Row, Col),
208 Name(Row, Col),
209 Param(&'a TypeParam<'a>, Row, Col),
210 Equals(Row, Col),
211 Bar(Row, Col),
212 Variant(Row, Col),
213 VariantArg(&'a Type<'a>, Row, Col),
214 IndentEquals(Row, Col),
215 IndentBar(Row, Col),
216 IndentAfterBar(Row, Col),
217 IndentAfterEquals(Row, Col),
218 Field(Row, Col),
219 FieldColon(Row, Col),
220 FieldType(&'a Type<'a>, Row, Col),
221 FieldEnd(Position, Row, Col),
222 IndentField(Row, Col),
223 IndentFieldType(Row, Col),
224}
225
226#[derive(Debug)]
231pub enum Expr<'a> {
232 Let(&'a Let<'a>, Row, Col),
233 Case(&'a Case<'a>, Row, Col),
234 If(&'a If<'a>, Row, Col),
235 List(&'a List<'a>, Row, Col),
236 Record(&'a Record<'a>, Row, Col),
237 Tuple(&'a Tuple<'a>, Row, Col),
238 Func(&'a Func<'a>, Row, Col),
239 Assert(&'a Keyword<'a>, Row, Col),
240 Fail(&'a Keyword<'a>, Row, Col),
241 Todo(&'a Keyword<'a>, Row, Col),
242 Trace(&'a Keyword<'a>, Row, Col),
243 Comptime(&'a Keyword<'a>, Row, Col),
244 Do(&'a Do<'a>, Row, Col),
245 Macro(&'a Macro<'a>, Row, Col),
246 Dot(Row, Col),
247 Access(Row, Col),
248 OperatorRight(&'a str, Row, Col),
249 OperatorReserved(BadOperator, Row, Col),
250 Start(Row, Col),
251 String(StringError, Row, Col),
252 Bytes(Bytes, Row, Col),
253 Number(Number, Row, Col),
254 Space(Space, Row, Col),
255 IndentOperatorRight(&'a str, Row, Col),
256}
257
258#[derive(Debug)]
259pub enum Keyword<'a> {
260 Space(Space, Row, Col),
261 Body(&'a Expr<'a>, Row, Col),
262 Message(&'a Expr<'a>, Row, Col),
263 IndentBody(Row, Col),
264 IndentMessage(Row, Col),
265}
266
267#[derive(Debug)]
268pub enum Do<'a> {
269 Space(Space, Row, Col),
270 Let(&'a Let<'a>, Row, Col),
271 Pattern(&'a Pattern<'a>, Row, Col),
272 Arrow(Row, Col),
273 Expr(&'a Expr<'a>, Row, Col),
274 LastNotExpr(Row, Col),
275 IndentStmt(Row, Col),
276 IndentArrow(Row, Col),
277 IndentExpr(Row, Col),
278 Alignment(usize, Row, Col),
279}
280
281#[derive(Debug)]
282pub enum Macro<'a> {
283 Open(Row, Col),
284 Arg(&'a Expr<'a>, Row, Col),
285 End(Row, Col),
286 Space(Space, Row, Col),
287 IndentArg(Row, Col),
288 IndentEnd(Row, Col),
289}
290
291#[derive(Debug)]
292pub enum Record<'a> {
293 Open(Row, Col),
294 End(Row, Col),
295 Field(Row, Col),
296 Equals(Row, Col),
297 Expr(&'a Expr<'a>, Row, Col),
298 Space(Space, Row, Col),
299 IndentOpen(Row, Col),
300 IndentEnd(Row, Col),
301 IndentField(Row, Col),
302 IndentEquals(Row, Col),
303 IndentExpr(Row, Col),
304}
305
306#[derive(Debug)]
307pub enum Tuple<'a> {
308 Expr(&'a Expr<'a>, Row, Col),
309 Space(Space, Row, Col),
310 End(Row, Col),
311 OperatorClose(Row, Col),
312 OperatorReserved(BadOperator, Row, Col),
313 IndentExpr1(Row, Col),
314 IndentExprN(Row, Col),
315 IndentEnd(Row, Col),
316}
317
318#[derive(Debug)]
319pub enum List<'a> {
320 Space(Space, Row, Col),
321 Open(Row, Col),
322 Expr(&'a Expr<'a>, Row, Col),
323 End(Row, Col),
324 IndentOpen(Row, Col),
325 IndentEnd(Row, Col),
326 IndentExpr(Row, Col),
327}
328
329#[derive(Debug)]
330pub enum Func<'a> {
331 Space(Space, Row, Col),
332 Arg(&'a Pattern<'a>, Row, Col),
333 Body(&'a Expr<'a>, Row, Col),
334 Arrow(Row, Col),
335 IndentArg(Row, Col),
336 IndentArrow(Row, Col),
337 IndentBody(Row, Col),
338}
339
340#[derive(Debug)]
341pub enum Case<'a> {
342 Space(Space, Row, Col),
343 Of(Row, Col),
344 Pattern(&'a Pattern<'a>, Row, Col),
345 Arrow(Row, Col),
346 Expr(&'a Expr<'a>, Row, Col),
347 Branch(&'a Expr<'a>, Row, Col),
348 IndentOf(Row, Col),
349 IndentExpr(Row, Col),
350 IndentPattern(Row, Col),
351 IndentArrow(Row, Col),
352 IndentBranch(Row, Col),
353 PatternAlignment(usize, Row, Col),
354}
355
356#[derive(Debug)]
357pub enum If<'a> {
358 Space(Space, Row, Col),
359 Then(Row, Col),
360 Else(Row, Col),
361 ElseBranchStart(Row, Col),
362 Condition(&'a Expr<'a>, Row, Col),
363 ThenBranch(&'a Expr<'a>, Row, Col),
364 ElseBranch(&'a Expr<'a>, Row, Col),
365 IndentCondition(Row, Col),
366 IndentThen(Row, Col),
367 IndentThenBranch(Row, Col),
368 IndentElseBranch(Row, Col),
369 IndentElse(Row, Col),
370}
371
372#[derive(Debug)]
373pub enum Let<'a> {
374 Space(Space, Row, Col),
375 In(Row, Col),
376 DefAlignment(usize, Row, Col),
377 DefName(Row, Col),
378 Def(&'a str, &'a Def<'a>, Row, Col),
379 Destruct(&'a Destruct<'a>, Row, Col),
380 Body(&'a Expr<'a>, Row, Col),
381 IndentDef(Row, Col),
382 IndentIn(Row, Col),
383 IndentBody(Row, Col),
384}
385
386#[derive(Debug)]
387pub enum Def<'a> {
388 Space(Space, Row, Col),
389 Type(&'a Type<'a>, Row, Col),
390 NameRepeat(Row, Col),
391 NameMatch(&'a str, Row, Col),
392 Arg(&'a Pattern<'a>, Row, Col),
393 Equals(Row, Col),
394 Body(&'a Expr<'a>, Row, Col),
395 IndentEquals(Row, Col),
396 IndentType(Row, Col),
397 IndentBody(Row, Col),
398 Alignment(usize, Row, Col),
399}
400
401#[derive(Debug)]
402pub enum Destruct<'a> {
403 Space(Space, Row, Col),
404 Pattern(&'a Pattern<'a>, Row, Col),
405 Equals(Row, Col),
406 Body(&'a Expr<'a>, Row, Col),
407 IndentEquals(Row, Col),
408 IndentBody(Row, Col),
409}
410
411#[derive(Debug)]
416pub enum Pattern<'a> {
417 Record(&'a PRecord, Row, Col),
418 Pair(&'a PTuple<'a>, Row, Col),
419 Tuple(&'a PTuple<'a>, Row, Col),
420 List(&'a PList<'a>, Row, Col),
421 Start(Row, Col),
422 String(StringError, Row, Col),
423 Bytes(Bytes, Row, Col),
424 Number(Number, Row, Col),
425 Alias(Row, Col),
426 WildcardNotVar(&'a str, i32, Row, Col),
427 Space(Space, Row, Col),
428 IndentStart(Row, Col),
429 IndentAlias(Row, Col),
430}
431
432#[derive(Debug)]
433pub enum Bytes {
434 Endless(Position),
435 OddLength,
436 BadHexDigit(usize),
437}
438
439#[derive(Debug)]
440pub enum PRecord {
441 Open(Row, Col),
442 End(Row, Col),
443 Field(Row, Col),
444 Space(Space, Row, Col),
445 IndentOpen(Row, Col),
446 IndentEnd(Row, Col),
447 IndentField(Row, Col),
448}
449
450#[derive(Debug)]
451pub enum PTuple<'a> {
452 Open(Row, Col),
453 End(Row, Col),
454 Expr(&'a Pattern<'a>, Row, Col),
455 Space(Space, Row, Col),
456 IndentEnd(Row, Col),
457 IndentExpr1(Row, Col),
458 IndentExprN(Row, Col),
459}
460
461#[derive(Debug)]
462pub enum PList<'a> {
463 Open(Row, Col),
464 End(Row, Col),
465 Expr(&'a Pattern<'a>, Row, Col),
466 Space(Space, Row, Col),
467 IndentOpen(Row, Col),
468 IndentEnd(Row, Col),
469 IndentExpr(Row, Col),
470}
471
472#[derive(Debug)]
477pub enum Type<'a> {
478 Record(&'a TRecord<'a>, Row, Col),
479 Tuple(&'a TTuple<'a>, Row, Col),
480 Start(Row, Col),
481 VarStart(Row, Col),
482 Context(Row, Col),
483 IndentAfterContext(Row, Col),
484 Space(Space, Row, Col),
485 IndentStart(Row, Col),
486}
487
488#[derive(Debug)]
489pub enum TypeParam<'a> {
490 Start(Row, Col),
491 Colon(Row, Col),
492 Repr(&'a Repr<'a>, Row, Col),
493 End(Row, Col),
494 Space(Space, Row, Col),
495 IndentColon(Row, Col),
496 IndentRepr(Row, Col),
497 IndentEnd(Row, Col),
498}
499
500#[derive(Debug)]
501pub enum Repr<'a> {
502 Arrow(Row, Col),
504 Start(Row, Col),
505 Name(&'a str, Row, Col),
506 Space(Space, Row, Col),
507}
508
509#[derive(Debug)]
510pub enum TRecord<'a> {
511 Open(Row, Col),
512 End(Row, Col),
513 Field(Row, Col),
514 Colon(Row, Col),
515 Type(&'a Type<'a>, Row, Col),
516 Space(Space, Row, Col),
517 IndentOpen(Row, Col),
518 IndentField(Row, Col),
519 IndentColon(Row, Col),
520 IndentType(Row, Col),
521 IndentEnd(Row, Col),
522}
523
524#[derive(Debug)]
525pub enum TTuple<'a> {
526 Repr(&'a Repr<'a>, Row, Col),
527 IndentRepr(Row, Col),
528 Open(Row, Col),
529 End(Row, Col),
530 Type(&'a Type<'a>, Row, Col),
531 Space(Space, Row, Col),
532 IndentType1(Row, Col),
533 IndentTypeN(Row, Col),
534 IndentEnd(Row, Col),
535}
536
537#[derive(Debug)]
542pub enum StringError {
543 EndlessSingle(Position),
544 EndlessMulti(Position),
545 Escape(Escape),
546}
547
548#[derive(Debug)]
549pub enum Escape {
550 Unknown,
551 BadUnicodeFormat(usize),
552 BadUnicodeCode(usize),
553 BadUnicodeLength {
554 code: usize,
555 expected: i32,
556 actual: i32,
557 },
558}
559
560#[derive(Debug)]
561pub enum Number {
562 End,
563 Dot(i128),
564 HexDigit,
565 NoLeadingZero,
566}
567
568#[derive(Debug)]
573pub enum Space {
574 TooDeep,
575 HasTab,
576 EndlessMultiComment(Position),
577}
578
579#[derive(Debug)]
580pub enum BadOperator {
581 Dot,
582 Pipe,
583 Arrow,
584 Equals,
585 HasType,
586 FatArrow,
587 LeftArrow,
588}