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

Syntax

Definitely, it is good to keep the syntax of a textual usages of operators that was used for operators of most box meta-models, specially the Stratego/XT, DeJonge and Brand-Visser box meta-model because this may act as informal standard.

Operators

Even though common positional operators will meet all requirements for defining relative positions among inner boxes, it would be beneficial to include also non-positional operators in this box meta-model. The operators that associate font configurations with text of inner boxes could be a good tool for defining syntax highlighting for a particular language and will be called highlight operators in the following text. The question is how to deal with comments. When the comments are realized by special tokens in the Xtext framework, highlight operators can be used for differentiation of this text kind because the token can be expressed by some box from the perspective of the box representation as it was realized in the DeJonge or Brand-Visser box meta-model. Still another problem to be solved is how how to wrap or variously format these comments that are represented by one elementary box. One way may be to introduce new kind of operators that would be able to modify text of inner boxes. This kind will be called transforming operators in the following text.

In general, it is not difficult to invent many operators that have different formatting effects, but a box meta-model with high amount of operators would lose clarity and easy usability. Therefore the operators should be as general as possible. The following list of operators suggests what the mentioned box meta-model may look like.

Positional Operators

  • I - Since this operator known from the Brand-Visser box meta-model allows for indenting a box individually in comparison with the indent parameter of vertical operators so this operator is a more general variant of indentation. The parameters is and ic would suit the operator. The is parameter expresses a number of characters needed to indentation and the ic parameter specifies indenting character.
  • H - The operator, which was contained in all mentioned box meta-models, aligns inner boxes horizontally and the parameters hs and hc are related to it. The hs parameter defines a number of characters forming a spacing gap and the hc parameter specifies a spacing character.
  • V - The operator, which was contained in all mentioned box meta-models, aligns inner boxes vertically and the vs parameter defining a number of blank spacing lines is related to it.
  • HV- The operator known from the DeJonge and Brand-Visser box meta-model fills the first line by inner boxes and if there is no space left, it fills the next line. The parameters hs, hc, and vs are related to the operator and have the same functionalities like with the H and V operators. Newly, the rs parameter specifying maximum line size is present.
  • ALT - Since this operator is more general than the HOV operator, only this operator is present in the box meta-model. Reasons why is the ALT operator more general are discussed in the description of the DeJonge box meta-model, from which the ALT operator comes. The operator uses the first inner box as a result when the length of the box does not exceed maximum line size specified by the rs parameter. Otherwise, the operator uses the next inner box.
  • A - The operator known from the Stratego/XT, DeJonge and Brand-Visser box meta-models aligns inner boxes into a table. The parameters hs, hc, and vs are related to the operator and have the same functionalities like with the H and V operators. Newly, the ca parameter specifying alignment of columns is present as it was mentioned in the description of the Brand-Visser box meta-model.
  • R - The operator defines a row of a table specified by the A operator.
  • WD - The operator coming from the Brand-Visser box meta-model that translates inner boxes into an empty boxes with the same size.

Highlight Operators

  • F - The operator known from the DeJonge and Brand-Visser box meta-models associates the text of inner boxes with a font configuration. The font configuration can be defined by the operator f specifying a font name, w specifying a font width, i specifying a font shape, h specifying a font size, c specifying a font color and b specifying a font background color. Since the operator is the most general from all highlight operators of both mentioned box meta-models and can supply them, it is not necessary to involve another highlight operators to this box meta-model.

Transforming Operators

  • SL - The operator formats single line comments. If the maximum line size specified by the rs parameter is exceeded by the length of the comment, the comment is properly splitted. Furthermore, the bs parameter specifying a character sequence that denotes the begin of the comment belongs to the operator.
  • ML - The operator formats multi line comments. If the maximum line size specified by the rs parameter is exceeded by the length of a line containing the comment, than the comment is properly splitted. The following parameters belong to the operator. The parameters bs and es specify character sequences that denotes the begin and the end of the comment. And further the is parameter defines a character sequence serving for indentation of inner lines together with the last line of the comment.