@@ -85,6 +85,15 @@ comment ::= ‘/*’ “any sequence of characters; nested comments ar
85
85
86
86
nl ::= “new line character”
87
87
semi ::= ‘;’ | nl {nl}
88
+
89
+ // trailing comma support
90
+ <(> ::= ‘(’
91
+ <)> ::= [ ‘,’ nl ] ‘)’
92
+ <[> ::= ‘[’
93
+ <]> ::= [ ‘,’ nl ] ‘]’
94
+ <{> ::= ‘{’
95
+ <}> ::= [ ‘,’ nl ] ‘}’
96
+
88
97
```
89
98
90
99
@@ -166,9 +175,9 @@ Type ::= FunType
166
175
FunType ::= FunTypeArgs (‘=>’ | ‘?=>’) Type Function(ts, t)
167
176
| HKTypeParamClause '=>' Type PolyFunction(ps, t)
168
177
FunTypeArgs ::= InfixType
169
- | ‘(’ [ FunArgTypes ] ‘)’
178
+ | <(> [ FunArgTypes ] <)>
170
179
| FunParamClause
171
- FunParamClause ::= ‘(’ TypedFunParam {‘,’ TypedFunParam } ‘)’
180
+ FunParamClause ::= <(> TypedFunParam {‘,’ TypedFunParam } <)>
172
181
TypedFunParam ::= id ‘:’ Type
173
182
MatchType ::= InfixType `match` <<< TypeCaseClauses >>>
174
183
InfixType ::= RefinedType {id [nl] RefinedType} InfixOp(t1, op, t2)
@@ -181,7 +190,7 @@ SimpleType ::= SimpleLiteral
181
190
SimpleType1 ::= id Ident(name)
182
191
| Singleton ‘.’ id Select(t, name)
183
192
| Singleton ‘.’ ‘type’ SingletonTypeTree(p)
184
- | ‘(’ Types ‘)’ Tuple(ts)
193
+ | <(> Types <)> Tuple(ts)
185
194
| Refinement RefinedTypeTree(EmptyTree, refinement)
186
195
| ‘$’ ‘{’ Block ‘}’ -- unless inside quoted pattern
187
196
| ‘$’ ‘{’ Pattern ‘}’ -- only inside quoted pattern
@@ -196,7 +205,7 @@ FunArgType ::= Type
196
205
FunArgTypes ::= FunArgType { ‘,’ FunArgType }
197
206
ParamType ::= [‘=>’] ParamValueType
198
207
ParamValueType ::= Type [‘*’] PostfixOp(t, "*")
199
- TypeArgs ::= ‘[’ Types ‘]’ ts
208
+ TypeArgs ::= <[> Types <)> ts
200
209
Refinement ::= ‘{’ [RefineDcl] {semi [RefineDcl]} ‘}’ ds
201
210
TypeBounds ::= [‘>:’ Type] [‘<:’ Type] TypeBoundsTree(lo, hi)
202
211
TypeParamBounds ::= TypeBounds {‘:’ Type} ContextBounds(typeBounds, tps)
@@ -249,7 +258,7 @@ SimpleExpr ::= SimpleRef
249
258
| quoteId -- only inside splices
250
259
| ‘new’ ConstrApp {‘with’ ConstrApp} [TemplateBody] New(constr | templ)
251
260
| ‘new’ TemplateBody
252
- | ‘(’ ExprsInParens ‘)’ Parens(exprs)
261
+ | <(> ExprsInParens <)> Parens(exprs)
253
262
| SimpleExpr ‘.’ id Select(expr, id)
254
263
| SimpleExpr ‘.’ MatchClause
255
264
| SimpleExpr TypeArgs TypeApply(expr, args)
@@ -264,8 +273,8 @@ Quoted ::= ‘'’ ‘{’ Block ‘}’
264
273
ExprsInParens ::= ExprInParens {‘,’ ExprInParens}
265
274
ExprInParens ::= PostfixExpr ‘:’ Type -- normal Expr allows only RefinedType here
266
275
| Expr
267
- ParArgumentExprs ::= ‘(’ [‘using’] ExprsInParens ‘)’ exprs
268
- | ‘(’ [ExprsInParens ‘,’] PostfixExpr ‘*’ ‘)’ exprs :+ Typed(expr, Ident(wildcardStar))
276
+ ParArgumentExprs ::= <(> [‘using’] ExprsInParens <)> exprs
277
+ | <(> [ExprsInParens ‘,’] PostfixExpr ‘*’ <)> exprs :+ Typed(expr, Ident(wildcardStar))
269
278
ArgumentExprs ::= ParArgumentExprs
270
279
| BlockExpr
271
280
BlockExpr ::= <<< CaseClauses | Block >>>
@@ -299,7 +308,7 @@ Pattern2 ::= [id ‘@’] InfixPattern
299
308
InfixPattern ::= SimplePattern { id [nl] SimplePattern } InfixOp(pat, op, pat)
300
309
SimplePattern ::= PatVar Ident(wildcard)
301
310
| Literal Bind(name, Ident(wildcard))
302
- | ‘(’ [Patterns] ‘)’ Parens(pats) Tuple(pats)
311
+ | <(> [Patterns] <)> Parens(pats) Tuple(pats)
303
312
| Quoted
304
313
| XmlPattern (to be dropped)
305
314
| SimplePattern1 [TypeArgs] [ArgumentPatterns]
@@ -309,44 +318,44 @@ SimplePattern1 ::= SimpleRef
309
318
PatVar ::= varid
310
319
| ‘_’
311
320
Patterns ::= Pattern {‘,’ Pattern}
312
- ArgumentPatterns ::= ‘(’ [Patterns] ‘)’ Apply(fn, pats)
313
- | ‘(’ [Patterns ‘,’] PatVar ‘*’ ‘)’
321
+ ArgumentPatterns ::= <(> [Patterns] <)> Apply(fn, pats)
322
+ | <(> [Patterns ‘,’] PatVar ‘*’ <)>
314
323
```
315
324
316
325
### Type and Value Parameters
317
326
``` ebnf
318
- ClsTypeParamClause::= ‘[’ ClsTypeParam {‘,’ ClsTypeParam} ‘]’
327
+ ClsTypeParamClause::= <[> ClsTypeParam {‘,’ ClsTypeParam} <]>
319
328
ClsTypeParam ::= {Annotation} [‘+’ | ‘-’] TypeDef(Modifiers, name, tparams, bounds)
320
329
id [HkTypeParamClause] TypeParamBounds Bound(below, above, context)
321
330
322
- DefTypeParamClause::= ‘[’ DefTypeParam {‘,’ DefTypeParam} ‘]’
331
+ DefTypeParamClause::= <[> DefTypeParam {‘,’ DefTypeParam} <]>
323
332
DefTypeParam ::= {Annotation} id [HkTypeParamClause] TypeParamBounds
324
333
325
- TypTypeParamClause::= ‘[’ TypTypeParam {‘,’ TypTypeParam} ‘]’
334
+ TypTypeParamClause::= <[> TypTypeParam {‘,’ TypTypeParam} <]>
326
335
TypTypeParam ::= {Annotation} id [HkTypeParamClause] TypeBounds
327
336
328
- HkTypeParamClause ::= ‘[’ HkTypeParam {‘,’ HkTypeParam} ‘]’
337
+ HkTypeParamClause ::= <[> HkTypeParam {‘,’ HkTypeParam} <]>
329
338
HkTypeParam ::= {Annotation} [‘+’ | ‘-’] (id [HkTypeParamClause] | ‘_’)
330
339
TypeBounds
331
340
332
- ClsParamClauses ::= {ClsParamClause} [[nl] ‘(’ [‘implicit’] ClsParams ‘)’ ]
333
- ClsParamClause ::= [nl] ‘(’ ClsParams ‘)’
334
- | [nl] ‘(’ ‘using’ (ClsParams | FunArgTypes) ‘)’
341
+ ClsParamClauses ::= {ClsParamClause} [[nl] <(> [‘implicit’] ClsParams <)> ]
342
+ ClsParamClause ::= [nl] <(> ClsParams <)>
343
+ | [nl] <(> ‘using’ (ClsParams | FunArgTypes) <)>
335
344
ClsParams ::= ClsParam {‘,’ ClsParam}
336
345
ClsParam ::= {Annotation} ValDef(mods, id, tpe, expr) -- point of mods on val/var
337
346
[{Modifier} (‘val’ | ‘var’) | ‘inline’] Param
338
347
Param ::= id ‘:’ ParamType [‘=’ Expr]
339
348
340
- DefParamClauses ::= {DefParamClause} [[nl] ‘(’ [‘implicit’] DefParams ‘)’ ]
341
- DefParamClause ::= [nl] ‘(’ DefParams ‘)’ | UsingParamClause
342
- UsingParamClause ::= [nl] ‘(’ ‘using’ (DefParams | FunArgTypes) ‘)’
349
+ DefParamClauses ::= {DefParamClause} [[nl] <(> [‘implicit’] DefParams <)> ]
350
+ DefParamClause ::= [nl] <(> DefParams <)> | UsingParamClause
351
+ UsingParamClause ::= [nl] <(> ‘using’ (DefParams | FunArgTypes) <)>
343
352
DefParams ::= DefParam {‘,’ DefParam}
344
353
DefParam ::= {Annotation} [‘inline’] Param ValDef(mods, id, tpe, expr) -- point of mods at id.
345
354
```
346
355
347
356
### Bindings and Imports
348
357
``` ebnf
349
- Bindings ::= ‘(’ [Binding {‘,’ Binding}] ‘)’
358
+ Bindings ::= <(> [Binding {‘,’ Binding} <)>
350
359
Binding ::= (id | ‘_’) [‘:’ Type] ValDef(_, id, tpe, EmptyTree)
351
360
352
361
Modifier ::= LocalModifier
@@ -371,7 +380,7 @@ ImportExpr ::= SimpleRef {‘.’ id} ‘.’ ImportSpec
371
380
| SimpleRef ‘as’ id Import(EmptyTree, ImportSelector(ref, id))
372
381
ImportSpec ::= NamedSelector
373
382
| WildcardSelector
374
- | ‘{’ ImportSelectors) ‘}’
383
+ | <{> ImportSelectors <}>
375
384
NamedSelector ::= id [‘as’ (id | ‘_’)]
376
385
WildCardSelector ::= ‘*' | ‘given’ [InfixType]
377
386
ImportSelectors ::= NamedSelector [‘,’ ImportSelectors]
0 commit comments