You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The lexical analyzer also inserts `indent` and `outdent` tokensthat represent regions of indented code [at certain points](../reference/other-new-features-indentation.html)
89
+
90
+
In the context-free productions below we use the notation `<<< ts >>>`
91
+
to indicate a token sequence `ts` that is either enclosed in a pair of braces `{ ts }` or that constitutes an indented region `indent ts outdent`.
92
+
93
+
88
94
## Keywords
89
95
90
96
### Regular keywords
91
97
92
98
```
93
-
abstract case catch class def do else enum
94
-
exportextends false final finally for given if
95
-
implicit import lazymatch new null object package
96
-
privateprotected override returnsuper sealed then throw
Copy file name to clipboardExpand all lines: docs/docs/reference/other-new-features/indentation.md
+8-9Lines changed: 8 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -58,23 +58,20 @@ There are two rules:
58
58
59
59
An indentation region can start
60
60
61
-
- after the leading parameters of an `extension`, or
62
-
- after a `with` in a giveninstance, or
63
-
- after a ": at end of line" token (see below)
64
61
- after one of the following tokens:
65
-
66
62
```
67
-
==>?=><-catchdoelsefinallyfor
68
-
ifmatchreturnthenthrowtrywhileyield
63
+
==>?=><-catchdoelsefinallyforif
64
+
matchreturnthenthrowtrywithwhileyield
69
65
```
66
+
- after the leading parameters of an `extension`.
70
67
71
68
If an `<indent>` is inserted, the indentation width of the token on the next line
72
69
is pushed onto `IW`, which makes it the new current indentation width.
73
70
74
71
2. An `<outdent>` is inserted at a line break, if
75
72
76
73
- the first token on the next line has an indentation width strictly less
77
-
than the current indentation width, and
74
+
than the current indentation width, and
78
75
- the last token on the previous line is not one of the following tokens
79
76
which indicate that the previous statement continues:
80
77
```
@@ -87,9 +84,11 @@ There are two rules:
87
84
If the indentation width of the token on the next line is still less than the new current indentation width, step (2) repeats. Therefore, several `<outdent>` tokens
88
85
may be inserted in a row.
89
86
90
-
An `<outdent>` is also inserted if the next token following a statement sequence starting with an `<indent>` closes an indentation region, i.e. is one of `then`, `else`, `do`, `catch`, `finally`, `yield`, `}`, `)`, `]` or `case`.
87
+
The folllowing two additional rules support parsing of legacy code with ad-hoc layout. They might be withdrawn in future language versions:
88
+
89
+
-An `<outdent>` is also inserted if the next token following a statement sequence starting with an `<indent>` closes an indentation region, i.e. is one of `then`, `else`, `do`, `catch`, `finally`, `yield`, `}`, `)`, `]` or `case`.
91
90
92
-
An `<outdent>` is finally inserted in front of a comma that follows a statement sequence starting with an `<indent>` if the indented region is itself enclosed in parentheses
91
+
-An `<outdent>` is finally inserted in front of a comma that follows a statement sequence starting with an `<indent>` if the indented region is itself enclosed in parentheses
93
92
94
93
It is an error if the indentation width of the token following an `<outdent>` does not match the indentation of some previous line in the enclosing indentation region. For instance, the following would be rejected.
0 commit comments