Base language is the most widely extended language in MPS. Since it's very likely that a MPS project use many of different extensions from different sources, there is a need in having unified style across languages. In this document we describe conventions that should be applied to all extensions.
Keywords
Keyword is a widely used string which identifies import concept from a language. For example, all the primitive types from baseLanguage are keywords. Also names of such a statements as ifStatement, forStatement are keywords. Use KeyWord style from base language's stylesheet for keywords.
Curly braces
Curly braces are often used to demarcate a block of code inside of containing construction. If you create a if-like construct, place opening curly brace on the same line as the construct header. I.e. use:
abc {
code
}
instead of
abc
{
code
}
Use LeftBrace and RightBrace Styles to set correct offsets. Make sure that the space between a character which is to left to opening curly brace and the curly brace itself is equal to 1 space. You can do so with a help of padding-left/padding-right style.
Parentheses
When you use parentheses, set LeftParen/RightParent style to the left/right parenthesis. If a parenthesis cell's sibling is a named node's property, disable the first/last position of a parenthesis with first/last-position-allowed style.
Identifiers
When you use named nodes: methods, variables, fields, etc, it's advisable to make their name properties have 0 left and right padding. Making identifier declaration and reference having the same color is also a good idea. For example, in base language, field declarations and references have the same color.
Punctuation
If you have a semicolon somewhere, set its style to semicolon. If you have a dot, use Dot style. If you have a binary operator, use operator style for it.
Add Comment