Skip to content

Commit ba9c2fd

Browse files
committed
Add new syntax
1 parent 637b75a commit ba9c2fd

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

docs/docs/internals/syntax.md

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ ClsTypeParamClause::= ‘[’ ClsTypeParam {‘,’ ClsTypeParam} ‘]’
319319
ClsTypeParam ::= {Annotation} [‘+’ | ‘-’] TypeDef(Modifiers, name, tparams, bounds)
320320
id [HkTypeParamClause] TypeParamBounds Bound(below, above, context)
321321
322-
DefTypeParamClause::= ‘[’ DefTypeParam {‘,’ DefTypeParam} ‘]’
322+
DefTypeParamClause::= [nl] ‘[’ DefTypeParam {‘,’ DefTypeParam} ‘]’
323323
DefTypeParam ::= {Annotation} id [HkTypeParamClause] TypeParamBounds
324324
325325
TypTypeParamClause::= ‘[’ TypTypeParam {‘,’ TypTypeParam} ‘]’
@@ -337,11 +337,18 @@ ClsParam ::= {Annotation}
337337
[{Modifier} (‘val’ | ‘var’) | ‘inline’] Param
338338
Param ::= id ‘:’ ParamType [‘=’ Expr]
339339
340-
DefParamClauses ::= {DefParamClause} [[nl] ‘(’ [‘implicit’] DefParams ‘)’]
341-
DefParamClause ::= [nl] ‘(’ DefParams ‘)’ | UsingParamClause
342-
UsingParamClause ::= [nl] ‘(’ ‘using’ (DefParams | FunArgTypes) ‘)’
343-
DefParams ::= DefParam {‘,’ DefParam}
344-
DefParam ::= {Annotation} [‘inline’] Param ValDef(mods, id, tpe, expr) -- point of mods at id.
340+
DefParamClauses ::= DefParamClause { DefParamClause }
341+
DefParamClause ::= DefTypeParamClause
342+
| DefTermParamClause
343+
| UsingParamClause
344+
DefTermParamClause::= [nl] ‘(’ [DefTermParams] ‘)’
345+
UsingParamClause ::= [nl] ‘(’ ‘using’ (DefTermParams | FunArgTypes) ‘)’
346+
DefTermParams ::= DefTermParam {‘,’ DefTermParam}
347+
DefTermParam ::= {Annotation} [‘inline’] Param ValDef(mods, id, tpe, expr) -- point of mods at id.
348+
TypelessClauses ::= TypelessClause {TypelessClause}
349+
TypelessClause ::= DefTermParamClause
350+
| UsingParamClause
351+
DefImplicitClause ::= [nl] ‘(’ ‘implicit’ DefTermParams ‘)’
345352
```
346353

347354
### Bindings and Imports
@@ -392,7 +399,7 @@ Dcl ::= RefineDcl
392399
ValDcl ::= ids ‘:’ Type PatDef(_, ids, tpe, EmptyTree)
393400
VarDcl ::= ids ‘:’ Type PatDef(_, ids, tpe, EmptyTree)
394401
DefDcl ::= DefSig ‘:’ Type DefDef(_, name, tparams, vparamss, tpe, EmptyTree)
395-
DefSig ::= id [DefTypeParamClause] DefParamClauses
402+
DefSig ::= id [DefParamClauses] [DefImplicitClause]
396403
TypeDcl ::= id [TypeParamClause] {FunParamClause} TypeBounds TypeDefTree(_, name, tparams, bound
397404
[‘=’ Type]
398405
@@ -403,8 +410,8 @@ Def ::= ‘val’ PatDef
403410
| TmplDef
404411
PatDef ::= ids [‘:’ Type] ‘=’ Expr
405412
| Pattern2 [‘:’ Type] ‘=’ Expr PatDef(_, pats, tpe?, expr)
406-
DefDef ::= DefSig [‘:’ Type] ‘=’ Expr DefDef(_, name, tparams, vparamss, tpe, expr)
407-
| ‘this’ DefParamClause DefParamClauses ‘=’ ConstrExpr DefDef(_, <init>, Nil, vparamss, EmptyTree, expr | Block)
413+
DefDef ::= DefSig [‘:’ Type] ‘=’ Expr DefDef(_, name, paramss, tpe, expr)
414+
| ‘this’ TypelessClauses [DefImplicitClause] ‘=’ ConstrExpr DefDef(_, <init>, vparamss, EmptyTree, expr | Block)
408415
409416
TmplDef ::= ([‘case’] ‘class’ | ‘trait’) ClassDef
410417
| [‘case’] ‘object’ ObjectDef
@@ -416,10 +423,10 @@ ConstrMods ::= {Annotation} [AccessModifier]
416423
ObjectDef ::= id [Template] ModuleDef(mods, name, template) // no constructor
417424
EnumDef ::= id ClassConstr InheritClauses EnumBody
418425
GivenDef ::= [GivenSig] (AnnotType [‘=’ Expr] | StructuralInstance)
419-
GivenSig ::= [id] [DefTypeParamClause] {UsingParamClause} ‘:’ -- one of `id`, `DefParamClause`, `UsingParamClause` must be present
426+
GivenSig ::= [id] [DefTypeParamClause] {UsingParamClause} ‘:’ -- one of `id`, `DefTypeParamClause`, `UsingParamClause` must be present
420427
StructuralInstance ::= ConstrApp {‘with’ ConstrApp} [‘with’ TemplateBody]
421428
Extension ::= ‘extension’ [DefTypeParamClause] {UsingParamClause}
422-
‘(’ DefParam ‘)’ {UsingParamClause} ExtMethods
429+
‘(’ DefTermParam ‘)’ {UsingParamClause} ExtMethods
423430
ExtMethods ::= ExtMethod | [nl] <<< ExtMethod {semi ExtMethod} >>>
424431
ExtMethod ::= {Annotation [nl]} {Modifier} ‘def’ DefDef
425432
Template ::= InheritClauses [TemplateBody]

0 commit comments

Comments
 (0)