@@ -86,6 +86,7 @@ nl ::= “new line character”
86
86
semi ::= ‘;’ | nl {nl}
87
87
```
88
88
89
+
89
90
## Context-free Syntax
90
91
91
92
The context-free syntax of Scala is given by the following EBNF
@@ -202,12 +203,9 @@ BlockStat ::= Import
202
203
| {Annotation} [‘implicit’ | ‘lazy’] Def
203
204
| {Annotation} {LocalModifier} TmplDef
204
205
| Expr1
205
- |
206
206
207
- ForExpr ::= ‘for’ (‘(’ Enumerators ‘)’ | ‘{’ Enumerators ‘}’)
208
- {nl} [‘yield’] Expr
207
+ ForExpr ::= ‘for’ (‘(’ Enumerators ‘)’ | ‘{’ Enumerators ‘}’) {nl} [‘yield’] Expr
209
208
| ‘for’ Enumerators (‘do’ Expr | ‘yield’ Expr)
210
-
211
209
Enumerators ::= Generator {semi Enumerator | Guard}
212
210
Enumerator ::= Generator
213
211
| Guard
@@ -217,7 +215,6 @@ Guard ::= ‘if’ PostfixExpr
217
215
218
216
CaseClauses ::= CaseClause { CaseClause }
219
217
CaseClause ::= ‘case’ (Pattern [Guard] ‘=>’ Block | INT)
220
-
221
218
Pattern ::= Pattern1 { ‘|’ Pattern1 }
222
219
Pattern1 ::= PatVar ‘:’ RefinedType
223
220
| Pattern2
@@ -330,27 +327,24 @@ DefDef ::= DefSig [‘:’ Type] ‘=’ Expr
330
327
331
328
TmplDef ::= ([‘case’] ‘class’ | ‘trait’) ClassDef
332
329
| [‘case’] ‘object’ ObjectDef
333
- ClassDef ::= id [ClsTypeParamClause]
334
- [ConstrMods] ClsParamClauses TemplateOpt
330
+ ClassDef ::= id [ClsTypeParamClause] [ConstrMods] ClsParamClauses TemplateOpt
335
331
ConstrMods ::= AccessModifier
336
332
| Annotation {Annotation} (AccessModifier | ‘this’)
337
333
ObjectDef ::= id TemplateOpt
338
334
TemplateOpt ::= [‘extends’ Template | [nl] TemplateBody]
339
335
Template ::= ConstrApps [TemplateBody] | TemplateBody
340
336
ConstrApps ::= ConstrApp {‘with’ ConstrApp}
341
337
ConstrApp ::= AnnotType {ArgumentExprs}
342
-
343
338
ConstrExpr ::= SelfInvocation
344
339
| ConstrBlock
345
- ConstrBlock ::= ‘{’ SelfInvocation {semi BlockStat} ‘}’
346
340
SelfInvocation ::= ‘this’ ArgumentExprs {ArgumentExprs}
341
+ ConstrBlock ::= ‘{’ SelfInvocation {semi BlockStat} ‘}’
347
342
348
343
TopStatSeq ::= TopStat {semi TopStat}
349
344
TopStat ::= {Annotation [nl]} {Modifier} TmplDef
350
345
| Import
351
346
| Packaging
352
347
| PackageObject
353
- |
354
348
Packaging ::= ‘package’ QualId [nl] ‘{’ TopStatSeq ‘}’
355
349
PackageObject ::= ‘package’ ‘object’ ObjectDef
356
350
0 commit comments