Skip to content

Commit a7d5ec0

Browse files
committed
syntax.md: update syntax of for-expressions
1 parent 98e3839 commit a7d5ec0

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2491,9 +2491,9 @@ object Parsers {
24912491
GenFrom(pat, subExpr(), checkMode)
24922492
}
24932493

2494-
/** ForExpr ::= `for' (`(' Enumerators `)' | `{' Enumerators `}')
2495-
* {nl} [`yield'] Expr
2496-
* | `for' Enumerators (`do' Expr | `yield' Expr)
2494+
/** ForExpr ::= for’ ‘(’ Enumerators ‘)’ {nl} [‘do‘ | ‘yield’] Expr
2495+
* | ‘for’ ‘{’ Enumerators ‘}’ {nl} [‘do‘ | ‘yield] Expr
2496+
* | forEnumerators {nl} (‘do‘ | ‘yield’) Expr
24972497
*/
24982498
def forExpr(): Tree =
24992499
atSpan(in.skipToken()) {

docs/docs/internals/syntax.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -263,9 +263,10 @@ BlockStat ::= Import
263263
| Expr1
264264
| EndMarker
265265
266-
ForExpr ::= ‘for’ (‘(’ Enumerators ‘)’ | ‘{’ Enumerators ‘}’) ForYield(enums, expr)
267-
{nl} [‘yield’] Expr
268-
| ‘for’ Enumerators (‘do’ Expr | ‘yield’ Expr) ForDo(enums, expr)
266+
ForExpr ::= ‘for’ ‘(’ Enumerators0 ‘)’ {nl} [‘do‘ | ‘yield’] Expr ForYield(enums, expr) / ForDo(enums, expr)
267+
| ‘for’ ‘{’ Enumerators0 ‘}’ {nl} [‘do‘ | ‘yield’] Expr
268+
| ‘for’ Enumerators0 {nl} (‘do‘ | ‘yield’) Expr
269+
Enumerators0 ::= {nl} Enumerators [semi]
269270
Enumerators ::= Generator {semi Enumerator | Guard}
270271
Enumerator ::= Generator
271272
| Guard

docs/docs/reference/syntax.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,10 @@ BlockStat ::= Import
259259
| Expr1
260260
| EndMarker
261261
262-
ForExpr ::= ‘for’ (‘(’ Enumerators ‘)’ | ‘{’ Enumerators ‘}’) {nl} [‘yield’] Expr
263-
| ‘for’ Enumerators (‘do’ Expr | ‘yield’ Expr)
262+
ForExpr ::= ‘for’ ‘(’ Enumerators0 ‘)’ {nl} [‘do‘ | ‘yield’] Expr
263+
| ‘for’ ‘{’ Enumerators0 ‘}’ {nl} [‘do‘ | ‘yield’] Expr
264+
| ‘for’ Enumerators0 {nl} (‘do‘ | ‘yield’) Expr
265+
Enumerators0 ::= {nl} Enumerators [semi]
264266
Enumerators ::= Generator {semi Enumerator | Guard}
265267
Enumerator ::= Generator
266268
| Guard

0 commit comments

Comments
 (0)