Skip to content

Commit 0e472bf

Browse files
authored
Merge pull request #11624 from unkarjedy/syntax.md/for-expression
syntax.md: update syntax of for-expressions
2 parents 46d0b05 + bc604e3 commit 0e472bf

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
@@ -2509,9 +2509,9 @@ object Parsers {
25092509
GenFrom(pat, subExpr(), checkMode)
25102510
}
25112511

2512-
/** ForExpr ::= `for' (`(' Enumerators `)' | `{' Enumerators `}')
2513-
* {nl} [`yield'] Expr
2514-
* | `for' Enumerators (`do' Expr | `yield' Expr)
2512+
/** ForExpr ::= for’ ‘(’ Enumerators ‘)’ {nl} [‘do‘ | ‘yield’] Expr
2513+
* | ‘for’ ‘{’ Enumerators ‘}’ {nl} [‘do‘ | ‘yield] Expr
2514+
* | forEnumerators (‘do‘ | ‘yield’) Expr
25152515
*/
25162516
def forExpr(): Tree =
25172517
atSpan(in.skipToken()) {

docs/docs/internals/syntax.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -272,9 +272,10 @@ BlockStat ::= Import
272272
| Expr1
273273
| EndMarker
274274
275-
ForExpr ::= ‘for’ (‘(’ Enumerators ‘)’ | ‘{’ Enumerators ‘}’) ForYield(enums, expr)
276-
{nl} [‘yield’] Expr
277-
| ‘for’ Enumerators (‘do’ Expr | ‘yield’ Expr) ForDo(enums, expr)
275+
ForExpr ::= ‘for’ ‘(’ Enumerators0 ‘)’ {nl} [‘do‘ | ‘yield’] Expr ForYield(enums, expr) / ForDo(enums, expr)
276+
| ‘for’ ‘{’ Enumerators0 ‘}’ {nl} [‘do‘ | ‘yield’] Expr
277+
| ‘for’ Enumerators0 (‘do‘ | ‘yield’) Expr
278+
Enumerators0 ::= {nl} Enumerators [semi]
278279
Enumerators ::= Generator {semi Enumerator | Guard}
279280
Enumerator ::= Generator
280281
| Guard

docs/docs/reference/syntax.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,10 @@ BlockStat ::= Import
263263
| Expr1
264264
| EndMarker
265265
266-
ForExpr ::= ‘for’ (‘(’ Enumerators ‘)’ | ‘{’ Enumerators ‘}’) {nl} [‘yield’] Expr
267-
| ‘for’ Enumerators (‘do’ Expr | ‘yield’ Expr)
266+
ForExpr ::= ‘for’ ‘(’ Enumerators0 ‘)’ {nl} [‘do‘ | ‘yield’] Expr
267+
| ‘for’ ‘{’ Enumerators0 ‘}’ {nl} [‘do‘ | ‘yield’] Expr
268+
| ‘for’ Enumerators0 (‘do‘ | ‘yield’) Expr
269+
Enumerators0 ::= {nl} Enumerators [semi]
268270
Enumerators ::= Generator {semi Enumerator | Guard}
269271
Enumerator ::= Generator
270272
| Guard

0 commit comments

Comments
 (0)