Allow arbitrary flags in (pps ...) forms
This commit is contained in:
parent
a26b787456
commit
da43937663
|
@ -96,23 +96,28 @@ module Pp = struct
|
||||||
let compare : t -> t -> int = Pervasives.compare
|
let compare : t -> t -> int = Pervasives.compare
|
||||||
end
|
end
|
||||||
|
|
||||||
module Pp_or_flag = struct
|
module Pp_or_flags = struct
|
||||||
type t =
|
type t =
|
||||||
| PP of Pp.t
|
| PP of Pp.t
|
||||||
| Flag of string
|
| Flags of string list
|
||||||
|
|
||||||
let of_string s =
|
let of_string s =
|
||||||
if String.is_prefix s ~prefix:"-" then
|
if String.is_prefix s ~prefix:"-" then
|
||||||
Flag s
|
Flags [s]
|
||||||
else
|
else
|
||||||
PP (Pp.of_string s)
|
PP (Pp.of_string s)
|
||||||
|
|
||||||
let t sexp = of_string (string sexp)
|
let t = function
|
||||||
|
| Atom (_, s) -> of_string s
|
||||||
|
| List (_, l) -> Flags (List.map l ~f:string)
|
||||||
|
|
||||||
let split l =
|
let split l =
|
||||||
List.partition_map l ~f:(function
|
let pps, flags =
|
||||||
| PP pp -> Inl pp
|
List.partition_map l ~f:(function
|
||||||
| Flag s -> Inr s)
|
| PP pp -> Inl pp
|
||||||
|
| Flags s -> Inr s)
|
||||||
|
in
|
||||||
|
(pps, List.concat flags)
|
||||||
end
|
end
|
||||||
|
|
||||||
module Dep_conf = struct
|
module Dep_conf = struct
|
||||||
|
@ -162,8 +167,8 @@ module Preprocess = struct
|
||||||
sum
|
sum
|
||||||
[ cstr "no_preprocessing" nil No_preprocessing
|
[ cstr "no_preprocessing" nil No_preprocessing
|
||||||
; cstr "command" (String_with_vars.t @> nil) (fun x -> Command x)
|
; cstr "command" (String_with_vars.t @> nil) (fun x -> Command x)
|
||||||
; cstr "pps" (list Pp_or_flag.t @> nil) (fun l ->
|
; cstr "pps" (list Pp_or_flags.t @> nil) (fun l ->
|
||||||
let pps, flags = Pp_or_flag.split l in
|
let pps, flags = Pp_or_flags.split l in
|
||||||
Pps { pps; flags })
|
Pps { pps; flags })
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -218,8 +223,8 @@ module Lint = struct
|
||||||
|
|
||||||
let t =
|
let t =
|
||||||
sum
|
sum
|
||||||
[ cstr "pps" (list Pp_or_flag.t @> nil) (fun l ->
|
[ cstr "pps" (list Pp_or_flags.t @> nil) (fun l ->
|
||||||
let pps, flags = Pp_or_flag.split l in
|
let pps, flags = Pp_or_flags.split l in
|
||||||
Pps { pps; flags })
|
Pps { pps; flags })
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue