Skip to content

Commit 9b918f5

Browse files
committed
Update ebnf grammar of methods in Parsers
1 parent f0e77c5 commit 9b918f5

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

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

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2904,6 +2904,10 @@ object Parsers {
29042904

29052905
/* -------- PARAMETERS ------------------------------------------- */
29062906

2907+
/** DefParamClause ::= DefTypeParamClause
2908+
* | DefTermParamClause
2909+
* | UsingParamClause
2910+
*/
29072911
def typeOrTermParamClause(nparams: Int, // number of parameters preceding this clause
29082912
ofClass: Boolean = false, // owner is a class
29092913
ofCaseClass: Boolean = false, // owner is a case class
@@ -2920,7 +2924,9 @@ object Parsers {
29202924
Nil
29212925

29222926
end typeOrTermParamClause
2923-
2927+
2928+
/** DefParamClauses ::= DefParamClause { DefParamClause }
2929+
*/
29242930
def typeOrTermParamClauses(
29252931
ownerKind: ParamOwner.Value,
29262932
ofClass: Boolean = false,
@@ -3017,11 +3023,15 @@ object Parsers {
30173023
* UsingClsParamClause::= ‘(’ ‘using’ [‘erased’] (ClsParams | ContextTypes) ‘)’
30183024
* ClsParams ::= ClsParam {‘,’ ClsParam}
30193025
* ClsParam ::= {Annotation}
3026+
*
3027+
* TypelessClause ::= DefTermParamClause
3028+
* | UsingParamClause
30203029
*
3021-
* DefParamClause ::= ‘(’ [‘erased’] DefParams ‘)’ | UsingParamClause
3022-
* UsingParamClause ::= ‘(’ ‘using’ [‘erased’] (DefParams | ContextTypes) ‘)’
3023-
* DefParams ::= DefParam {‘,’ DefParam}
3024-
* DefParam ::= {Annotation} [‘inline’] Param
3030+
* DefTermParamClause::= [nl] ‘(’ [DefTermParams] ‘)’
3031+
* UsingParamClause ::= ‘(’ ‘using’ [‘erased’] (DefTermParams | ContextTypes) ‘)’
3032+
* DefImplicitClause ::= [nl] ‘(’ ‘implicit’ DefTermParams ‘)’
3033+
* DefTermParams ::= DefTermParam {‘,’ DefTermParam}
3034+
* DefTermParam ::= {Annotation} [‘inline’] Param
30253035
*
30263036
* Param ::= id `:' ParamType [`=' Expr]
30273037
*
@@ -3119,7 +3129,7 @@ object Parsers {
31193129
}
31203130

31213131
/** ClsParamClauses ::= {ClsParamClause} [[nl] ‘(’ [‘implicit’] ClsParams ‘)’]
3122-
* DefParamClauses ::= {DefParamClause} [[nl] ‘(’ [‘implicit’] DefParams ‘)’]
3132+
* TypelessClauses ::= TypelessClause {TypelessClause}
31233133
*
31243134
* @return The parameter definitions
31253135
*/
@@ -3371,9 +3381,9 @@ object Parsers {
33713381
}
33723382

33733383
/** DefDef ::= DefSig [‘:’ Type] ‘=’ Expr
3374-
* | this ParamClause ParamClauses `=' ConstrExpr
3384+
* | this TypelessClauses [DefImplicitClause] `=' ConstrExpr
33753385
* DefDcl ::= DefSig `:' Type
3376-
* DefSig ::= id [DefTypeParamClause] DefParamClauses
3386+
* DefSig ::= id [DefParamClauses] [DefImplicitClause]
33773387
* | ExtParamClause [nl] [‘.’] id DefParamClauses
33783388
*/
33793389
def defDefOrDcl(start: Offset, mods: Modifiers, numLeadParams: Int = 0): DefDef = atSpan(start, nameStart) {
@@ -3412,8 +3422,6 @@ object Parsers {
34123422
val ident = termIdent()
34133423
var name = ident.name.asTermName
34143424
val paramss = typeOrTermParamClauses(ParamOwner.Def, numLeadParams = numLeadParams)
3415-
//val tparams = typeParamClauseOpt(ParamOwner.Def)
3416-
//val vparamss = paramClauses(numLeadParams = numLeadParams)
34173425
var tpt = fromWithinReturnType { typedOpt() }
34183426
if (migrateTo3) newLineOptWhenFollowedBy(LBRACE)
34193427
val rhs =
@@ -3431,7 +3439,6 @@ object Parsers {
34313439
accept(EQUALS)
34323440
expr()
34333441

3434-
//val ddef = DefDef(name, joinParams(tparams, vparamss), tpt, rhs)
34353442
val ddef = DefDef(name, paramss, tpt, rhs)
34363443
if (isBackquoted(ident)) ddef.pushAttachment(Backquoted, ())
34373444
finalizeDef(ddef, mods1, start)
@@ -3694,7 +3701,7 @@ object Parsers {
36943701
finalizeDef(gdef, mods1, start)
36953702
}
36963703

3697-
/** Extension ::= ‘extension’ [DefTypeParamClause] {UsingParamClause} ‘(’ DefParam ‘)’
3704+
/** Extension ::= ‘extension’ [DefTypeParamClause] {UsingParamClause} ‘(’ DefTermParam ‘)’
36983705
* {UsingParamClause} ExtMethods //TODO: Change to {Params} ?
36993706
*/
37003707
def extension(): ExtMethods =

0 commit comments

Comments
 (0)