Skip to content

Commit 16c2434

Browse files
committed
Change syntax.md to reflect new syntax
1 parent 42958fa commit 16c2434

File tree

3 files changed

+24
-25
lines changed

3 files changed

+24
-25
lines changed

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

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1278,7 +1278,7 @@ object Parsers {
12781278
* | SimpleExpr1 ArgumentExprs `=' Expr
12791279
* | Expr2
12801280
* | [‘inline’] Expr2 `match' `{' CaseClauses `}'
1281-
* | `delegate' `match' `{' ImplicitCaseClauses `}'
1281+
* | `given' `match' `{' ImplicitCaseClauses `}'
12821282
* Bindings ::= `(' [Binding {`,' Binding}] `)'
12831283
* Binding ::= (id | `_') [`:' Type]
12841284
* Expr2 ::= PostfixExpr [Ascription]
@@ -1482,7 +1482,7 @@ object Parsers {
14821482
*/
14831483
def impliedMatch(start: Int, imods: Modifiers) = {
14841484
def markFirstIllegal(mods: List[Mod]) = mods match {
1485-
case mod :: _ => syntaxError(em"illegal modifier for delegate match", mod.span)
1485+
case mod :: _ => syntaxError(em"illegal modifier for given match", mod.span)
14861486
case _ =>
14871487
}
14881488
imods.mods match {
@@ -1497,7 +1497,7 @@ object Parsers {
14971497
case pat => isVarPattern(pat)
14981498
}
14991499
if (!isImplicitPattern(pat))
1500-
syntaxError(em"not a legal pattern for a delegate match", pat.span)
1500+
syntaxError(em"not a legal pattern for a given match", pat.span)
15011501
}
15021502
result
15031503
}
@@ -2396,7 +2396,7 @@ object Parsers {
23962396
wildcardIdent() :: Nil
23972397
case FOR =>
23982398
if (!importDelegate)
2399-
syntaxError(em"`for` qualifier only allowed in `import delegate`")
2399+
syntaxError(em"`for` qualifier only allowed in `import given`")
24002400
atSpan(in.skipToken()) {
24012401
var t = infixType()
24022402
while (in.token == COMMA) {
@@ -2695,7 +2695,7 @@ object Parsers {
26952695
/** TmplDef ::= ([‘case’] ‘class’ | ‘trait’) ClassDef
26962696
* | [‘case’] ‘object’ ObjectDef
26972697
* | ‘enum’ EnumDef
2698-
* | ‘instance’ InstanceDef
2698+
* | ‘given’ GivenDef
26992699
*/
27002700
def tmplDef(start: Int, mods: Modifiers): Tree = {
27012701
in.token match {
@@ -2804,10 +2804,9 @@ object Parsers {
28042804
Template(constr, parents, Nil, EmptyValDef, Nil)
28052805
}
28062806

2807-
/** InstanceDef ::= [id] [DefTypeParamClause] InstanceBody
2808-
* InstanceParams ::= [DefTypeParamClause] {GivenParamClause}
2809-
* InstanceBody ::= [‘for’ ConstrApp {‘,’ ConstrApp }] {GivenParamClause} [TemplateBody]
2810-
* | ‘for’ Type {GivenParamClause} ‘=’ Expr
2807+
/** GivenDef ::= [id] [DefTypeParamClause] GivenBody
2808+
* GivenBody ::= [‘as ConstrApp {‘,’ ConstrApp }] {GivenParamClause} [TemplateBody]
2809+
* | ‘as’ Type {GivenParamClause} ‘=’ Expr
28112810
*/
28122811
def instanceDef(newStyle: Boolean, start: Offset, mods: Modifiers, instanceMod: Mod) = atSpan(start, nameStart) {
28132812
var mods1 = addMod(mods, instanceMod)

compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
319319
case _ => tree
320320
}
321321

322-
def importText(deleg: Boolean, expr: Tree, selectors: List[Tree]) = {
322+
def importText(givenOnly: Boolean, expr: Tree, selectors: List[Tree]) = {
323323
def selectorText(sel: Tree): Text = sel match {
324324
case Thicket(l :: r :: Nil) => toTextGlobal(l) ~ " => " ~ toTextGlobal(r)
325325
case _: Ident => toTextGlobal(sel)
@@ -329,7 +329,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
329329
case id :: Nil => toText(id)
330330
case _ => "{" ~ Text(selectors map selectorText, ", ") ~ "}"
331331
}
332-
(keywordText("delegate ") provided deleg) ~
332+
(keywordText("given ") provided givenOnly) ~
333333
toTextLocal(expr) ~ "." ~ selectorsText
334334
}
335335

docs/docs/internals/syntax.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -92,20 +92,20 @@ semi ::= ‘;’ | nl {nl}
9292
### Regular keywords
9393

9494
```
95-
abstract case catch class def delegate do else
96-
enum export extends false final finally for given
97-
if implicit import lazy match new null object
98-
package private protected override return super sealed then
99-
throw trait true try type val var while
100-
with yield
95+
abstract case catch class def do else enum
96+
export extends false final finally for given if
97+
implicit import lazy match new null object package
98+
private protected override return super sealed then throw
99+
trait true try type val var while with
100+
yield
101101
: = <- => <: :> # @
102102
=>>
103103
```
104104

105105
### Soft keywords
106106

107107
```
108-
derives inline opaque
108+
as derives inline opaque
109109
~ * | & + -
110110
```
111111

@@ -203,7 +203,7 @@ Expr1 ::= ‘if’ ‘(’ Expr ‘)’ {nl}
203203
| SimpleExpr1 ArgumentExprs ‘=’ Expr Assign(expr, expr)
204204
| Expr2
205205
| [‘inline’] Expr2 ‘match’ ‘{’ CaseClauses ‘}’ Match(expr, cases) -- point on match
206-
| ‘implicit’ ‘match’ ‘{’ ImplicitCaseClauses ‘}’
206+
| ‘given’ ‘match’ ‘{’ ImplicitCaseClauses ‘}’
207207
Expr2 ::= PostfixExpr [Ascription]
208208
Ascription ::= ‘:’ InfixType Typed(expr, tp)
209209
| ‘:’ Annotation {Annotation} Typed(expr, Annotated(EmptyTree, annot)*)
@@ -336,14 +336,14 @@ AccessQualifier ::= ‘[’ (id | ‘this’) ‘]’
336336
337337
Annotation ::= ‘@’ SimpleType {ParArgumentExprs} Apply(tpe, args)
338338
339-
Import ::= ‘import’ [‘delegate’] ImportExpr {‘,’ ImportExpr}
339+
Import ::= ‘import’ [‘given’] ImportExpr {‘,’ ImportExpr}
340340
ImportExpr ::= StableId ‘.’ (id | ‘_’ | ImportSelectors) Import(expr, sels)
341341
ImportSelectors ::= ‘{’ {ImportSelector ‘,’} FinalSelector ‘}’
342342
FinalSelector ::= ImportSelector Ident(name)
343343
| ‘_’ Pair(id, id)
344344
| ‘for’ InfixType {‘,’ InfixType} TypeBoundsTree(EmptyTree, tpt)
345345
ImportSelector ::= id [‘=>’ id | ‘=>’ ‘_’]
346-
Export ::= ‘export’ [‘delegate’] ImportExpr {‘,’ ImportExpr}
346+
Export ::= ‘export’ [‘given’] ImportExpr {‘,’ ImportExpr}
347347
```
348348

349349
### Declarations and Definitions
@@ -379,16 +379,16 @@ DefDef ::= DefSig [(‘:’ | ‘<:’) Type] ‘=’ Expr
379379
TmplDef ::= ([‘case’] ‘class’ | ‘trait’) ClassDef
380380
| [‘case’] ‘object’ ObjectDef
381381
| ‘enum’ EnumDef
382-
| ‘delegate’ DelegateDef
382+
| ‘given’ GivenDef
383383
| Export
384384
ClassDef ::= id ClassConstr [Template] ClassDef(mods, name, tparams, templ)
385385
ClassConstr ::= [ClsTypeParamClause] [ConstrMods] ClsParamClauses with DefDef(_, <init>, Nil, vparamss, EmptyTree, EmptyTree) as first stat
386386
ConstrMods ::= {Annotation} [AccessModifier]
387387
ObjectDef ::= id [Template] ModuleDef(mods, name, template) // no constructor
388388
EnumDef ::= id ClassConstr InheritClauses EnumBody EnumDef(mods, name, tparams, template)
389-
DelegateDef ::= [id] [DefTypeParamClause] DelegateBody
390-
DelegateBody ::= [‘for’ ConstrApp {‘,’ ConstrApp }] {GivenParamClause} [TemplateBody]
391-
| ‘for’ Type {GivenParamClause} ‘=’ Expr
389+
GivenDef ::= [id] [DefTypeParamClause] GivenBody
390+
GivenBody ::= [‘as ConstrApp {‘,’ ConstrApp }] {GivenParamClause} [TemplateBody]
391+
| ‘as’ Type {GivenParamClause} ‘=’ Expr
392392
Template ::= InheritClauses [TemplateBody] Template(constr, parents, self, stats)
393393
InheritClauses ::= [‘extends’ ConstrApps] [‘derives’ QualId {‘,’ QualId}]
394394
ConstrApps ::= ConstrApp {‘with’ ConstrApp}

0 commit comments

Comments
 (0)