|
Packit Service |
a2ae7a |
(*
|
|
Packit Service |
a2ae7a |
Module: Yaml
|
|
Packit Service |
a2ae7a |
Only valid for the following subset:
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
> defaults: &anchor
|
|
Packit Service |
a2ae7a |
> repo1: master
|
|
Packit Service |
a2ae7a |
>
|
|
Packit Service |
a2ae7a |
> host:
|
|
Packit Service |
a2ae7a |
> # Inheritance
|
|
Packit Service |
a2ae7a |
> <<: *anchor
|
|
Packit Service |
a2ae7a |
> repo2: branch
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
Author: Dimitar Dimitrov <mitkofr@yahoo.fr>
|
|
Packit Service |
a2ae7a |
*)
|
|
Packit Service |
a2ae7a |
module YAML =
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* Group: helpers *)
|
|
Packit Service |
a2ae7a |
let dash = Util.del_str "-"
|
|
Packit Service |
a2ae7a |
let colon = Sep.colon
|
|
Packit Service |
a2ae7a |
let space = Sep.space
|
|
Packit Service |
a2ae7a |
let val = store Rx.word
|
|
Packit Service |
a2ae7a |
let eol = Util.eol
|
|
Packit Service |
a2ae7a |
let empty = Util.empty
|
|
Packit Service |
a2ae7a |
let comment = Util.comment_noindent
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(*
|
|
Packit Service |
a2ae7a |
View: indent
|
|
Packit Service |
a2ae7a |
the imposed indent is 2 spaces
|
|
Packit Service |
a2ae7a |
*)
|
|
Packit Service |
a2ae7a |
let indent = del /[ \t]+/ " "
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let mval = [ label "@mval" . Util.del_str "|-" . eol
|
|
Packit Service |
a2ae7a |
. [ label "@line" . indent . store Rx.space_in . eol ]+ ]
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(*
|
|
Packit Service |
a2ae7a |
View: inherit
|
|
Packit Service |
a2ae7a |
> <<: *anchor
|
|
Packit Service |
a2ae7a |
*)
|
|
Packit Service |
a2ae7a |
let _inherit = [ key "<<" . colon . space . Util.del_str "*" . val . eol ]
|
|
Packit Service |
a2ae7a |
let inherit = indent . _inherit . (indent . comment)*
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(*
|
|
Packit Service |
a2ae7a |
View: repo
|
|
Packit Service |
a2ae7a |
> { "repo" = "branch" }
|
|
Packit Service |
a2ae7a |
*)
|
|
Packit Service |
a2ae7a |
let _repo = [ key Rx.word . colon . space . (val | mval) . eol ]
|
|
Packit Service |
a2ae7a |
let repo = indent . _repo . (indent . comment)*
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(*
|
|
Packit Service |
a2ae7a |
View: anchor
|
|
Packit Service |
a2ae7a |
> &anchor
|
|
Packit Service |
a2ae7a |
*)
|
|
Packit Service |
a2ae7a |
let anchor = Util.del_str "&" . val
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(*
|
|
Packit Service |
a2ae7a |
View: entry
|
|
Packit Service |
a2ae7a |
> host:
|
|
Packit Service |
a2ae7a |
> # Inheritance
|
|
Packit Service |
a2ae7a |
> <<: *anchor
|
|
Packit Service |
a2ae7a |
> repo2: branch
|
|
Packit Service |
a2ae7a |
*)
|
|
Packit Service |
a2ae7a |
let entry = [ key Rx.word . colon . (space . anchor)? . eol
|
|
Packit Service |
a2ae7a |
. (indent . comment)*
|
|
Packit Service |
a2ae7a |
. ((inherit . (repo+)?) | repo+)
|
|
Packit Service |
a2ae7a |
]
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: top level sequence *)
|
|
Packit Service |
a2ae7a |
let sequence = [ label "@sequence" . counter "sequence" . dash . repo+ ]
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: header *)
|
|
Packit Service |
a2ae7a |
let header = [ label "@yaml" . Util.del_str "---"
|
|
Packit Service |
a2ae7a |
. (Sep.space . store Rx.space_in)? . eol ]
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(*
|
|
Packit Service |
a2ae7a |
View: lns
|
|
Packit Service |
a2ae7a |
The yaml lens
|
|
Packit Service |
a2ae7a |
*)
|
|
Packit Service |
a2ae7a |
let lns = ((empty|comment)* . header)? . (sequence | entry | comment | empty)*
|