Class Layout
java.lang.Object
org.clafer.frontend.Layout
Turns indentation into blocks, as the compiler's layout resolver does
(
LayoutResolver.resolveLayout): a line indented more than the line
before opens a block (TokenKind.INDENT), a line indented less
closes the blocks it leaves (TokenKind.DEDENT), and a line at the
indentation of a sibling is separated from the line before
(TokenKind.SEPARATOR).
The rules are the compiler's, quirks included, so that the parser sees the tokens that the compiler's parser sees:
- layout is off on a line that starts inside
[ ]or{ }; - a line that starts with
{} or {@code }has no layout; - a line that starts with a comment or an escape is indented at the column of the first of them, even one that starts on an earlier line;
- a model whose brackets are open by more than one at its end has
']' bracket missing.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordThe tokens with the layout made explicit. -
Method Summary
Modifier and TypeMethodDescriptionstatic Layout.Resultresolve(ClaferLexer.Result lexed) Resolves the layout of the tokens of a model.
-
Method Details
-
resolve
Resolves the layout of the tokens of a model.- Parameters:
lexed- the tokens, comments and escapes ofClaferLexer- Returns:
- the tokens with the blocks and separators of the layout
-