Use syntax extension for parsing stanza

Signed-off-by: Rudi Grinberg <rudi.grinberg@gmail.com>
This commit is contained in:
Rudi Grinberg 2018-07-18 13:45:10 +02:00
parent bac0a35785
commit 655c10164d
2 changed files with 7 additions and 5 deletions

View File

@ -1,7 +1,6 @@
type stanza = Stanza.t = .. type stanza = Stanza.t = ..
module Stanza = struct module Stanza = struct
open Import
open Stanza.Of_sexp open Stanza.Of_sexp
let field_oslu name = Ordered_set_lang.Unexpanded.field name let field_oslu name = Ordered_set_lang.Unexpanded.field name
@ -38,9 +37,10 @@ module Stanza = struct
(pat, configs)) (pat, configs))
let t = let t =
Syntax.since Stanza.syntax (1, 0) >>= fun () -> let%map () = Syntax.since Stanza.syntax (1, 0)
loc >>= fun loc -> and loc = loc
repeat rule >>| fun rules -> and rules = repeat rule
in
{ loc; rules } { loc; rules }
end end

View File

@ -1592,7 +1592,9 @@ module Stanzas = struct
(let%map () = Syntax.since Stanza.syntax (1, 0) (let%map () = Syntax.since Stanza.syntax (1, 0)
and t = Tests.single in and t = Tests.single in
[Tests t]) [Tests t])
; "env", Dune_env.Stanza.t >>| fun x -> [Dune_env.T x] ; "env",
(let%map x = Dune_env.Stanza.t in
[Dune_env.T x])
] ]
let jbuild_parser = let jbuild_parser =