Bump to 1.14.1
[platform/upstream/augeas.git] / lenses / yaml.aug
1 (*
2 Module: Yaml
3   Only valid for the following subset:
4
5 > defaults: &anchor
6 >   repo1: master
7 >
8 > host:
9 >   # Inheritance
10 >   <<: *anchor
11 >   repo2: branch
12
13 Author: Dimitar Dimitrov <mitkofr@yahoo.fr>
14 *)
15 module YAML =
16
17 (* Group: helpers *)
18 let dash = Util.del_str "-"
19 let colon = Sep.colon
20 let space = Sep.space
21 let val = store Rx.word
22 let eol = Util.eol
23 let empty = Util.empty
24 let comment = Util.comment_noindent
25
26 (*
27 View: indent
28   the imposed indent is 2 spaces
29 *)
30 let indent = del /[ \t]+/ "  "
31
32 let mval = [ label "@mval" . Util.del_str "|-" . eol
33            . [ label "@line" . indent . store Rx.space_in . eol ]+ ]
34
35 (*
36 View: inherit
37 > <<: *anchor
38 *)
39 let _inherit = [ key "<<" . colon . space . Util.del_str "*" . val . eol ]
40 let inherit = indent . _inherit . (indent . comment)*
41
42 (*
43 View: repo
44 > { "repo" = "branch" }
45 *)
46 let _repo = [ key Rx.word . colon . space . (val | mval) . eol ]
47 let repo = indent . _repo . (indent . comment)*
48
49 (*
50 View: anchor
51 > &anchor
52 *)
53 let anchor = Util.del_str "&" . val
54
55 (*
56 View: entry
57 > host:
58 >   # Inheritance
59 >   <<: *anchor
60 >   repo2: branch
61 *)
62 let entry = [ key Rx.word . colon . (space . anchor)? . eol
63             . (indent . comment)*
64             . ((inherit . (repo+)?) | repo+)
65             ]
66
67 (* View: top level sequence *)
68 let sequence = [ label "@sequence" . counter "sequence" . dash . repo+ ]
69
70 (* View: header *)
71 let header = [ label "@yaml" . Util.del_str "---"
72              . (Sep.space . store Rx.space_in)? . eol ]
73
74 (*
75 View: lns
76   The yaml lens
77 *)
78 let lns = ((empty|comment)* . header)? . (sequence | entry | comment | empty)*