Skip to content

Commit 8062c41

Browse files
committed
Improve docs
1 parent 7f4c828 commit 8062c41

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

compiler/src/dotty/tools/dotc/parsing/Parsers.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1325,7 +1325,7 @@ object Parsers {
13251325
in.nextToken()
13261326
if stats.isEmpty || !matches(stats.last) then
13271327
syntaxError("misaligned end marker", Span(start, in.lastCharOffset))
1328-
in.token = IDENTIFIER
1328+
in.token = IDENTIFIER // Leaving it as the original token can confuse newline insertion
13291329
in.nextToken()
13301330
end checkEndMarker
13311331

docs/docs/reference/other-new-features/indentation.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,17 @@ End markers are allowed in statement sequences. The specifier token `s` of an en
216216

217217
It is recommended that `end` markers are used for code where the extent of an indentation region is not immediately apparent "at a glance". Typically this is the case if an indentation region spans 20 lines or more.
218218

219+
**Syntax**
220+
221+
```
222+
EndMarker ::= ‘end’ EndMarkerTag -- when followed by EOL
223+
EndMarkerTag ::= id |if|while|for|match|try
224+
|new|this|given| ‘extension’ |val
225+
BlockStat ::= ... | EndMarker
226+
TemplateStat ::= ... | EndMarker
227+
TopStat ::= ... | EndMarker
228+
```
229+
219230
### Example
220231

221232
Here is a (somewhat meta-circular) example of code using indentation. It provides a concrete representation of indentation widths as defined above together with efficient operations for constructing and comparing indentation widths.

0 commit comments

Comments
 (0)