File: pprintf.mli

package info (click to toggle)
camlp5 8.04.00-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 11,972 kB
  • sloc: ml: 137,918; makefile: 2,055; perl: 1,729; sh: 1,653; python: 38
file content (51 lines) | stat: -rw-r--r-- 2,356 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
(* camlp5r *)
(* pprintf.mli,v *)
(* Copyright (c) INRIA 2007-2017 *)

(** Definitions for pprintf statement.

    This module contains types and functions for the "pprintf" statement
    added by the syntax extension "pa_pprintf.cmo". *)

type pr_context = { ind : int; bef : string; aft : string; dang : string };
   (** Printing context.
    - "ind" : the current indendation
    - "bef" : what should be printed before, in the same line
    - "aft" : what should be printed after, in the same line
    - "dang" : the dangling token to know whether parentheses are necessary *)

type pr_fun 'a = pr_context -> 'a -> string;

value empty_pc : pr_context;
   (** Empty printer context, equal to:
       [{ind = 0; bef = ""; aft = ""; dang = ""}] *)

value sprint_break :
  int -> int -> pr_context -> (pr_context -> string) ->
    (pr_context -> string) -> string;
   (** [sprint_break nspaces offset pc f g] concat the two strings returned
       by [f] and [g], either in one line, if it holds without overflowing
       (see module [Pretty]), with [nspaces] spaces betwen them, or in two
       lines with [offset] spaces added in the indentation for the second
       line.
         This function don't need to be called directly. It is generated by
       the [pprintf] statement according to its parameters when the format
       contains breaks, like [@;] and [@ ]. *)

value sprint_break_all :
  bool -> pr_context -> (pr_context -> string) ->
    list (int * int * pr_context -> string) -> string;
   (** [sprint_break_all force_newlines pc f fl] concat all strings returned
       by the list with separators [f]-[fl], the separators being the number
       of spaces and the offset like in the function [sprint_break]. The
       function works as "all or nothing", i.e. if the resulting string
       does not hold on the line, all strings are printed in different
       lines (even if sub-parts could hold in single lines). If the parameter
       [force_newline] is [True], all strings are printed in different
       lines, no horizontal printing is tested.
         This function don't need to be called directly. It is generated by
       the [pprintf] statement according to its parameters when the format
       contains parenthesized parts with "break all" like "@[<a>" and "@]",
       or "@[<b>" and "@]". *)

#load "pa_macro.cmo";