OCaml Box Meta model - mn-mikke/Model-driven-Pretty-Printer-for-Xtext-Framework GitHub Wiki

The box meta-model is present in a pretty-printing engine provided by the Format module of standard libraries of the OCaml system which is the main implementation of the general-purpose programming language Caml supporting functional, imperative, and object-oriented programming styles.

Since the source of this box meta-model conceives operator as a function of a programming language transforming one character sequence to another, the box meta-model does not have any textual usage of operators known from the previous descriptions of box meta-models. The source also defines overall formatting differently. The elementary inner boxes are represented by corresponding text directly and further they are separated by a special break. All texts of boxes together with special breaks represent an input character sequence for an operator which subsequently transforms. After the character sequence is transformed by all necessary operators, the special breaks are replaced by white characters ensuring indentation, horizontal or vertical spacing. The function performing this action knows exactly whether to indent or make same spacing gaps on the position of a special break in the input character sequence. Since indentation and spacing are solved globally, the operators do not hold any parameters. The following list of operators is part of this box meta-model. Just to clarify, the "-" means an arbitrary character and the "b" represents a special break in the following description.

  • H - The operator aligns inner boxes horizontally similarly like the H operators from other box meta-models. The operator preserves the input character sequence and does not wrap it.

Operator H

  • V - The operator aligns inner boxes horizontally similarly like the V operators from other box meta-models. The operator wraps the input character sequence after each occurrence of a special break.

Operator V

  • HOV - The operator aligns inner boxes like the HV operators from other box meta-models. The functionalities of the operators HV and HOV are swapped in this box meta-model. The operator fills the first line gradually by the inner boxes from the character sequence until an additional box together with a following special break fit into the line. In case it does not fit, the box together with a special break is added into the next line.

Operator HOV

  • HV - The operator aligns inner boxes like the HOV operators from other box meta-models. The functionalities of the operators HV and HOV are swapped in this box meta-model. The operator formats the character sequence like the H operator when the length of the sequence does not exceed maximum line size. Otherwise, it works like the V operator.

Operator HV