Module Sstt.Prec

Precedence of operators and associativity

type unop =
  1. | Neg

Unary operators

type binop =
  1. | Diff
  2. | Arrow

Binary operators

type varop =
  1. | Tuple
  2. | Cup
  3. | Cap

Variadic operators

type assoc =
  1. | Left
  2. | Right
  3. | NoAssoc

Associativity

val varop_info : varop -> string * int * assoc

Returns the separator, the priority (as an integer) and the associativity of a variadic operator.

val binop_info : binop -> string * int * assoc

Returns the separator, the priority (as an integer) and the associativity of a binary operator.

val unop_info : unop -> string * int * assoc

Returns the separator, the priority (as an integer) and the associativity of a unary operator.

val max_prec : int

Maximum priority

val min_prec : int

Minimum priority

val need_parentheses : int -> assoc -> (string * int * assoc) -> bool

need_parentheses lvl assoc info returns true if the operator described by info needs parentheses for the current printing level lvl and the current associativity assoc.

val fprintf : int -> assoc -> (string * int * assoc) -> Stdlib.Format.formatter -> ('a, Stdlib.Format.formatter, unit, unit, unit, unit) Stdlib.format6 -> 'a

fprintf lvl assoc info fmt f … works as Format.fprintf but will add parentheses around the formatted output if required by lvl assoc and info.