-
Notifications
You must be signed in to change notification settings - Fork 3
/
$lines.ts
43 lines (40 loc) · 1.57 KB
/
$lines.ts
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
import factory from "../factory";
import $blankLine from "./$blankLine";
import $tocHeadLine from "./$tocHeadLine";
import $articleGroupHeadLine from "./$articleGroupHeadLine";
import $appdxItemHeadLine from "./$appdxItemHeadLine";
import $supplProvisionAppdxItemHeadLine from "./$supplProvisionAppdxItemHeadLine";
import $supplProvisionHeadLine from "./$supplProvisionHeadLine";
import $articleLine from "./$articleLine";
import $paragraphItemLine from "./$paragraphItemLine";
import $tableColumnLine from "./$tableColumnLine";
import $otherLine from "./$otherLine";
import { WithErrorRule } from "../util";
import { Line } from "../../../node/cst/line";
export const $lines: WithErrorRule<Line[]> = factory.withName("lines")
.sequence(s => s
.and(r => r
.zeroOrMore(r => r
.choice(c => c
.or(() => $blankLine)
.or(() => $tableColumnLine)
.or(() => $tocHeadLine)
.or(() => $articleGroupHeadLine)
.or(() => $paragraphItemLine)
.or(() => $supplProvisionHeadLine)
.or(() => $supplProvisionAppdxItemHeadLine)
.or(() => $appdxItemHeadLine)
.or(() => $articleLine)
.or(() => $otherLine)
)
)
, "lines")
.action(({ lines }) => {
return {
value: lines.map(line => line.value),
errors: lines.map(line => line.errors).flat(),
};
})
)
;
export default $lines;