ocaml-stringpainter / src / Prioritized.mli

(*********************************************************************************************************************
 * Copyrights (C) by
 *  Pawel Wieczorek <wieczyk gmail>
 *
 * http://bitbucket.org/wieczyk/ocaml-stringpainter
 ********************************************************************************************************************)

(**
 Prioritized painters are designed for printing ASTs where indentation
 and brackets are important aspect. This module provides fundamental
 painters.
 *)



(** painter type *)
type painter

(** priority *)
type priority = int


(** associtivity *)
type associativity
    = LeftAssociative
    | RightAssociative
    | NoAssociative

(**
    The [ with_priority prio sp ] embeds a basic string pinter [ sp ] with priority [ prio ]
    as prioritrized painter.
 *) 
val with_priority : priority -> Basic.painter -> painter

(** Is multiline? *)
val is_multiline : painter -> bool

val any_multiline : painter list -> bool

(** Returns priority of given painter. *)
val get_priority : painter -> priority

(** Returns basic painter from prioritized one. *)
val get_painter :  painter -> Basic.painter

(** Combine list of painters priorityo one painter with given priority. *)
val psp_nested : priority -> painter list -> painter

val psp_indent : priority->  painter list -> painter

(** Return painter with different priority. *)
val psp_reprioritize : priority -> painter -> painter

(** Maximal priority. *)
val psp_max_priority : priority

(** Breaks not empty line. *)
val psp_break : painter

(** Breaks line. *)
val psp_newline : painter

(** Paints a word. *)
val psp_word : string -> painter

(** Paints a keyword. *)
val psp_keyword : string -> painter

(** Paints a value. *)
val psp_value : string -> painter

(** Paints a value-keyword. *)
val psp_value_keyword : string -> painter

(** Paints an operator. *)
val psp_operator : string -> painter

(** Paints a syntax-construct. *)
val psp_syntax : string -> painter

(** Paints an integer value.  *)
val psp_value_int : int -> painter

(** Paints an boolean value.  *)
val psp_value_bool : bool -> painter

(**
   The [ psp_bracket opening closing prio elem ] parenthesis [ elem ] with given brackets.
 *)
val psp_bracket : painter -> painter -> priority -> painter -> painter

(**
    Specialized version of [ psp_bracket ] for standard brackets and maximal priority.
  *)
val psp_std_bracket : painter -> painter

(**
    Specialized version of [ psp_bracket ] for standard square brackets and maximal priority.
  *)
val psp_square_bracket : painter -> painter

(**
    Specialized version of [ psp_bracket ] for empty symbols as brackets and with maximal priority.
 *) 
val psp_no_bracket : painter -> painter

val psp_decide_bracket : (painter -> painter) -> bool -> painter -> painter

val psp_decide_std_bracket : bool -> painter -> painter

(**
   The [ psp_infix assoc prio oper left right ] paints an infix operators with auto-parenthesis. 
 *)
val psp_infix : associativity -> priority -> painter -> painter -> painter -> painter

(**
   Prints on standard output with newline.
 *)
val print_painter_nl  : painter -> unit

(**
   Prints on standard output..
 *)
val print_painter     : painter -> unit

(**
    Renders painter into string.
 *)
val render_painter    : painter -> string
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.