aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Hugo Herbelin <Hugo.Herbelin@inria.fr>2016-04-09 16:15:15 +0200
committerGravatar Hugo Herbelin <Hugo.Herbelin@inria.fr>2016-04-09 18:26:00 +0200
commitfa2fa0b2e6ca0fbfb9a9278af211d4ef533b6791 (patch)
tree6dbbb2b69ba652361a73eff50b0e6e7baa7e369b
parentb5cc4ac65764b0866bf57caa6f9aa7fa631eabf1 (diff)
Simplifying code for printing VERNAC EXTEND.
-rw-r--r--printing/ppvernac.ml23
1 files changed, 8 insertions, 15 deletions
diff --git a/printing/ppvernac.ml b/printing/ppvernac.ml
index 0b761881d..9054ba0b6 100644
--- a/printing/ppvernac.ml
+++ b/printing/ppvernac.ml
@@ -1213,22 +1213,15 @@ module Make
with Failure _ -> str "<error in " ++ str (fst s) ++ str ">" in
try
let rl = Egramml.get_extend_vernac_rule s in
- let start,rl,cl =
- match rl with
- | Egramml.GramTerminal s :: rl -> str s, rl, cl
- | Egramml.GramNonTerminal _ :: rl -> pr_arg (List.hd cl), rl, List.tl cl
- | [] -> anomaly (Pp.str "Empty entry") in
- let (pp,_) =
- List.fold_left
- (fun (strm,args) pi ->
- let pp,args = match pi with
- | Egramml.GramNonTerminal _ -> (pr_arg (List.hd args), List.tl args)
- | Egramml.GramTerminal s -> (str s, args) in
- (strm ++ spc() ++ pp), args)
- (start,cl) rl in
- hov 1 pp
+ let rec aux rl cl =
+ match rl, cl with
+ | Egramml.GramNonTerminal _ :: rl, arg :: cl -> pr_arg arg :: aux rl cl
+ | Egramml.GramTerminal s :: rl, cl -> str s :: aux rl cl
+ | [], [] -> []
+ | _ -> assert false in
+ hov 1 (pr_sequence (fun x -> x) (aux rl cl))
with Not_found ->
- hov 1 (str "TODO(" ++ str (fst s) ++ prlist_with_sep sep pr_arg cl ++ str ")")
+ hov 1 (str "TODO(" ++ str (fst s) ++ spc () ++ prlist_with_sep sep pr_arg cl ++ str ")")
in pr_vernac