summaryrefslogtreecommitdiff
path: root/printing/pputils.ml
blob: 50ce56fb024bab5274be311ee2161d896b1c80e5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
(************************************************************************)
(*  v      *   The Coq Proof Assistant  /  The Coq Development Team     *)
(* <O___,, *   INRIA - CNRS - LIX - LRI - PPS - Copyright 1999-2016     *)
(*   \VV/  **************************************************************)
(*    //   *      This file is distributed under the terms of the       *)
(*         *       GNU Lesser General Public License Version 2.1        *)
(************************************************************************)

open Pp

let pr_located pr (loc, x) =
  if !Flags.beautify && loc <> Loc.ghost then
    let (b, e) = Loc.unloc loc in
    (* Side-effect: order matters *)
    let before = Pp.comment (CLexer.extract_comments b) in
    let x = pr x in
    let after = Pp.comment (CLexer.extract_comments e) in
    before ++ x ++ after
  else pr x