Skip to content

Commit a60c4e7

Browse files
committed
Highlight all EBNF snippets. Add missing semicolons.
1 parent 0443992 commit a60c4e7

23 files changed

+128
-128
lines changed

docs/_docs/reference/changed-features/imports.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,14 @@ are offered under settings `-source 3.1-migration -rewrite`.
4646

4747
### Syntax
4848

49-
```
50-
Import ::= ‘import’ ImportExpr {‘,’ ImportExpr}
51-
ImportExpr ::= SimpleRef {‘.’ id} ‘.’ ImportSpec
49+
```ebnf
50+
Import ::= ‘import’ ImportExpr {‘,’ ImportExpr} ;
51+
ImportExpr ::= SimpleRef {‘.’ id} ‘.’ ImportSpec ;
5252
ImportSpec ::= NamedSelector
5353
| WildcardSelector
54-
| ‘{’ ImportSelectors) ‘}’
55-
NamedSelector ::= id [‘as’ (id | ‘_’)]
56-
WildCardSelector ::= ‘*' | ‘given’ [InfixType]
54+
| ‘{’ ImportSelectors) ‘}’ ;
55+
NamedSelector ::= id [‘as’ (id | ‘_’)] ;
56+
WildCardSelector ::= ‘*' | ‘given’ [InfixType] ;
5757
ImportSelectors ::= NamedSelector [‘,’ ImportSelectors]
58-
| WildCardSelector {‘,’ WildCardSelector}
58+
| WildCardSelector {‘,’ WildCardSelector} ;
5959
```

docs/_docs/reference/changed-features/match-syntax.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ The syntactical precedence of match expressions has been changed.
4747

4848
The new syntax of match expressions is as follows.
4949

50-
```
50+
```ebnf
5151
InfixExpr ::= ...
52-
| InfixExpr MatchClause
52+
| InfixExpr MatchClause ;
5353
SimpleExpr ::= ...
54-
| SimpleExpr ‘.’ MatchClause
55-
MatchClause ::= ‘match’ ‘{’ CaseClauses ‘}’
54+
| SimpleExpr ‘.’ MatchClause ;
55+
MatchClause ::=match’ ‘{’ CaseClauses ‘}’ ;
5656
```

docs/_docs/reference/changed-features/pattern-bindings.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ for case (x, y) <- elems yield (y, x) // returns List((2, 1), (4, 3))
5050
## Syntax Changes
5151

5252
Generators in for expressions may be prefixed with `case`.
53-
```
54-
Generator ::= [‘case’] Pattern1 ‘<-’ Expr
53+
```ebnf
54+
Generator ::= [‘case’] Pattern1 ‘<-’ Expr ;
5555
```
5656

5757
## Migration

docs/_docs/reference/changed-features/structural-types-spec.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ movedTo: https://docs.scala-lang.org/scala3/reference/changed-features/structura
66

77
## Syntax
88

9-
```
10-
SimpleType ::= ... | Refinement
11-
Refinement ::= ‘{’ RefineStatSeq ‘}’
12-
RefineStatSeq ::= RefineStat {semi RefineStat}
13-
RefineStat ::= ‘val’ VarDcl | ‘def’ DefDcl | ‘type’ {nl} TypeDcl
9+
```ebnf
10+
SimpleType ::= ... | Refinement ;
11+
Refinement ::= ‘{’ RefineStatSeq ‘}’ ;
12+
RefineStatSeq ::= RefineStat {semi RefineStat} ;
13+
RefineStat ::= ‘val’ VarDcl | ‘def’ DefDcl | ‘type’ {nl} TypeDcl ;
1414
```
1515

1616
## Implementation of Structural Types

docs/_docs/reference/changed-features/vararg-splices.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ The old syntax for splice arguments will be phased out.
2424

2525
## Syntax
2626

27-
```
27+
```ebnf
2828
ArgumentPatterns ::= ‘(’ [Patterns] ‘)’
29-
| ‘(’ [Patterns ‘,’] Pattern2 ‘*’ ‘)’
29+
| ‘(’ [Patterns ‘,’] Pattern2 ‘*’ ‘)’ ;
3030
3131
ParArgumentExprs ::= ‘(’ [‘using’] ExprsInParens ‘)’
32-
| ‘(’ [ExprsInParens ‘,’] PostfixExpr ‘*’ ‘)’
32+
| ‘(’ [ExprsInParens ‘,’] PostfixExpr ‘*’ ‘)’ ;
3333
```
3434

3535
## Compatibility considerations

docs/_docs/reference/contextual/context-bounds.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ done automatically under `-rewrite`.
4040

4141
## Syntax
4242

43-
```
44-
TypeParamBounds ::= [SubtypeBounds] {ContextBound}
45-
ContextBound ::= ‘:’ Type
43+
```ebnf
44+
TypeParamBounds ::= [SubtypeBounds] {ContextBound} ;
45+
ContextBound ::= ‘:’ Type ;
4646
```

docs/_docs/reference/contextual/context-functions-spec.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ movedTo: https://docs.scala-lang.org/scala3/reference/contextual/context-functio
66

77
## Syntax
88

9-
```
9+
```ebnf
1010
Type ::= ...
11-
| FunArgTypes ‘?=>’ Type
11+
| FunArgTypes ‘?=>’ Type ;
1212
Expr ::= ...
13-
| FunParams ‘?=>’ Expr
13+
| FunParams ‘?=>’ Expr ;
1414
```
1515

1616
Context function types associate to the right, e.g.

docs/_docs/reference/contextual/derivation.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -354,12 +354,12 @@ hand side of this definition in the same way as an instance defined in ADT compa
354354

355355
### Syntax
356356

357-
```
358-
Template ::= InheritClauses [TemplateBody]
359-
EnumDef ::= id ClassConstr InheritClauses EnumBody
360-
InheritClauses ::= [‘extends’ ConstrApps] [‘derives’ QualId {‘,’ QualId}]
357+
```ebnf
358+
Template ::= InheritClauses [TemplateBody] ;
359+
EnumDef ::= id ClassConstr InheritClauses EnumBody ;
360+
InheritClauses ::= [‘extends’ ConstrApps] [‘derives’ QualId {‘,’ QualId}] ;
361361
ConstrApps ::= ConstrApp {‘with’ ConstrApp}
362-
| ConstrApp {‘,’ ConstrApp}
362+
| ConstrApp {‘,’ ConstrApp} ;
363363
```
364364

365365
**Note:** To align `extends` clauses and `derives` clauses, Scala 3 also allows multiple

docs/_docs/reference/contextual/extension-methods.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -285,20 +285,20 @@ def position(s: String)(ch: Char, n: Int): Int =
285285
Here are the syntax changes for extension methods and collective extensions relative
286286
to the [current syntax](../syntax.md).
287287

288-
```
289-
BlockStat ::= ... | Extension
290-
TemplateStat ::= ... | Extension
291-
TopStat ::= ... | Extension
288+
```ebnf
289+
BlockStat ::= ... | Extension ;
290+
TemplateStat ::= ... | Extension ;
291+
TopStat ::= ... | Extension ;
292292
Extension ::= ‘extension’ [DefTypeParamClause] {UsingParamClause}
293-
‘(’ DefParam ‘)’ {UsingParamClause} ExtMethods
294-
ExtMethods ::= ExtMethod | [nl] <<< ExtMethod {semi ExtMethod} >>>
295-
ExtMethod ::= {Annotation [nl]} {Modifier} ‘def’ DefDef
293+
‘(’ DefParam ‘)’ {UsingParamClause} ExtMethods ;
294+
ExtMethods ::= ExtMethod | [nl] <<< ExtMethod {semi ExtMethod} >>> ;
295+
ExtMethod ::= {Annotation [nl]} {Modifier} ‘def’ DefDef ;
296296
```
297297

298298
In the above the notation `<<< ts >>>` in the production rule `ExtMethods` is defined as follows :
299299

300-
```
301-
<<< ts >>> ::= ‘{’ ts ‘}’ | indent ts outdent
300+
```ebnf
301+
<<< ts >>> ::= ‘{’ ts ‘}’ | indent ts outdent ;
302302
```
303303

304304
`extension` is a soft keyword. It is recognized as a keyword only if it appears

docs/_docs/reference/contextual/given-imports.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -103,15 +103,15 @@ given instances once their user base has migrated.
103103

104104
### Syntax
105105

106-
```
107-
Import ::= ‘import’ ImportExpr {‘,’ ImportExpr}
108-
Export ::= ‘export’ ImportExpr {‘,’ ImportExpr}
109-
ImportExpr ::= SimpleRef {‘.’ id} ‘.’ ImportSpec
106+
```ebnf
107+
Import ::= ‘import’ ImportExpr {‘,’ ImportExpr} ;
108+
Export ::= ‘export’ ImportExpr {‘,’ ImportExpr} ;
109+
ImportExpr ::= SimpleRef {‘.’ id} ‘.’ ImportSpec ;
110110
ImportSpec ::= NamedSelector
111111
| WildcardSelector
112-
| ‘{’ ImportSelectors) ‘}’
113-
NamedSelector ::= id [‘as’ (id | ‘_’)]
114-
WildCardSelector ::= ‘*' | ‘given’ [InfixType]
112+
| ‘{’ ImportSelectors) ‘}’ ;
113+
NamedSelector ::= id [‘as’ (id | ‘_’)] ;
114+
WildCardSelector ::= ‘*' | ‘given’ [InfixType] ;
115115
ImportSelectors ::= NamedSelector [‘,’ ImportSelectors]
116-
| WildCardSelector {‘,’ WildCardSelector}
116+
| WildCardSelector {‘,’ WildCardSelector} ;
117117
```

docs/_docs/reference/contextual/givens.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,14 +173,14 @@ is created for each reference.
173173

174174
Here is the syntax for given instances:
175175

176-
```
176+
```ebnf
177177
TmplDef ::= ...
178-
| ‘given’ GivenDef
178+
| ‘given’ GivenDef ;
179179
GivenDef ::= [GivenSig] StructuralInstance
180180
| [GivenSig] AnnotType ‘=’ Expr
181-
| [GivenSig] AnnotType
182-
GivenSig ::= [id] [DefTypeParamClause] {UsingParamClause} ‘:’
183-
StructuralInstance ::= ConstrApp {‘with’ ConstrApp} ‘with’ TemplateBody
181+
| [GivenSig] AnnotType ;
182+
GivenSig ::= [id] [DefTypeParamClause] {UsingParamClause} ‘:’ ;
183+
StructuralInstance ::= ConstrApp {‘with’ ConstrApp} ‘with’ TemplateBody ;
184184
```
185185

186186
A given instance starts with the reserved word `given` and an optional _signature_. The signature

docs/_docs/reference/contextual/using-clauses.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,10 @@ def summon[T](using x: T): x.type = x
144144

145145
Here is the new syntax of parameters and arguments seen as a delta from the [standard context free syntax of Scala 3](../syntax.md). `using` is a soft keyword, recognized only at the start of a parameter or argument list. It can be used as a normal identifier everywhere else.
146146

147-
```
148-
ClsParamClause ::= ... | UsingClsParamClause
149-
DefParamClauses ::= ... | UsingParamClause
150-
UsingClsParamClause ::= ‘(’ ‘using’ (ClsParams | Types) ‘)’
151-
UsingParamClause ::= ‘(’ ‘using’ (DefParams | Types) ‘)’
152-
ParArgumentExprs ::= ... | ‘(’ ‘using’ ExprsInParens ‘)’
147+
```ebnf
148+
ClsParamClause ::= ... | UsingClsParamClause ;
149+
DefParamClauses ::= ... | UsingParamClause ;
150+
UsingClsParamClause ::= ‘(’ ‘using’ (ClsParams | Types) ‘)’ ;
151+
UsingParamClause ::= ‘(’ ‘using’ (DefParams | Types) ‘)’ ;
152+
ParArgumentExprs ::= ... | ‘(’ ‘using’ ExprsInParens ‘)’ ;
153153
```

docs/_docs/reference/enums/adts.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -154,18 +154,18 @@ The changes are specified below as deltas with respect to the Scala syntax given
154154

155155
1. Enum definitions are defined as follows:
156156

157-
```
158-
TmplDef ::= `enum' EnumDef
159-
EnumDef ::= id ClassConstr [`extends' [ConstrApps]] EnumBody
160-
EnumBody ::= [nl] ‘{’ [SelfType] EnumStat {semi EnumStat} ‘}’
157+
```ebnf
158+
TmplDef ::= `enum' EnumDef ;
159+
EnumDef ::= id ClassConstr [`extends' [ConstrApps]] EnumBody ;
160+
EnumBody ::= [nl] ‘{’ [SelfType] EnumStat {semi EnumStat} ‘}’ ;
161161
EnumStat ::= TemplateStat
162-
| {Annotation [nl]} {Modifier} EnumCase
162+
| {Annotation [nl]} {Modifier} EnumCase ;
163163
```
164164
165165
2. Cases of enums are defined as follows:
166166
167-
```
168-
EnumCase ::= `case' (id ClassConstr [`extends' ConstrApps]] | ids)
167+
```ebnf
168+
EnumCase ::= `case' (id ClassConstr [`extends' ConstrApps]] | ids) ;
169169
```
170170
171171
### Reference

docs/_docs/reference/experimental/named-typeargs-spec.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ In this section we give more details about the [named type arguments](named-type
1010

1111
The addition to the grammar is:
1212

13-
```
13+
```ebnf
1414
SimpleExpr1 ::= ...
15-
| SimpleExpr (TypeArgs | NamedTypeArgs)
16-
NamedTypeArgs ::= ‘[’ NamedTypeArg {‘,’ NamedTypeArg} ‘]’
17-
NamedTypeArg ::= id ‘=’ Type
15+
| SimpleExpr (TypeArgs | NamedTypeArgs) ;
16+
NamedTypeArgs ::= ‘[’ NamedTypeArg {‘,’ NamedTypeArg} ‘]’ ;
17+
NamedTypeArg ::= id ‘=’ Type ;
1818
```
1919

2020
Note in particular that named arguments cannot be passed to type constructors:

docs/_docs/reference/metaprogramming/macros-spec.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ movedTo: https://docs.scala-lang.org/scala3/reference/metaprogramming/macros-spe
1010

1111
Compared to the [Scala 3 reference grammar](../syntax.md)
1212
there are the following syntax changes:
13-
```
13+
```ebnf
1414
SimpleExpr ::= ...
1515
| ‘'’ ‘{’ Block ‘}’
1616
| ‘'’ ‘[’ Type ‘]’
17-
| ‘$’ ‘{’ Block ‘}’
17+
| ‘$’ ‘{’ Block ‘}’ ;
1818
SimpleType ::= ...
19-
| ‘$’ ‘{’ Block ‘}’
19+
| ‘$’ ‘{’ Block ‘}’ ;
2020
```
2121
In addition, an identifier `$x` starting with a `$` that appears inside
2222
a quoted expression or type is treated as a splice `${x}` and a quoted identifier
@@ -57,36 +57,36 @@ extends simply-typed lambda calculus with quotes and splices.
5757
### Syntax
5858

5959
The syntax of terms, values, and types is given as follows:
60-
```
60+
```ebnf
6161
Terms t ::= x variable
6262
(x: T) => t lambda
6363
t t application
6464
't quote
65-
$t splice
65+
$t splice ;
6666
6767
Values v ::= (x: T) => t lambda
68-
'u quote
68+
'u quote ;
6969
70-
Simple terms u ::= x | (x: T) => u | u u | 't
70+
Simple terms u ::= x | (x: T) => u | u u | 't ;
7171
7272
Types T ::= A base type
7373
T -> T function type
74-
expr T quoted
74+
expr T quoted ;
7575
```
7676
Typing rules are formulated using a stack of environments
7777
`Es`. Individual environments `E` consist as usual of variable
7878
bindings `x: T`. Environments can be combined using the two
7979
combinators `'` and `$`.
80-
```
80+
```ebnf
8181
Environment E ::= () empty
82-
E, x: T
82+
E, x: T ;
8383
8484
Env. stack Es ::= () empty
8585
E simple
86-
Es * Es combined
86+
Es * Es combined ;
8787
8888
Separator * ::= '
89-
$
89+
$ ;
9090
```
9191
The two environment combinators are both associative with left and
9292
right identity `()`.
@@ -108,9 +108,9 @@ rule says that splice and quotes cancel each other out. The third rule
108108
is a context rule; it says that reduction is allowed in the hole `[ ]`
109109
position of an evaluation context. Evaluation contexts `e` and
110110
splice evaluation context `e_s` are defined syntactically as follows:
111-
```
112-
Eval context e ::= [ ] | e t | v e | 'e_s[${e}]
113-
Splice context e_s ::= [ ] | (x: T) => e_s | e_s t | u e_s
111+
```ebnf
112+
Eval context e ::= [ ] | e t | v e | 'e_s[${e}] ;
113+
Splice context e_s ::= [ ] | (x: T) => e_s | e_s t | u e_s ;
114114
```
115115

116116
### Typing rules

docs/_docs/reference/metaprogramming/simple-smp.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,21 @@ replace evaluation contexts with contextual typing rules. While this
2323
is more verbose, it makes it easier to set up the meta theory.
2424

2525
## Syntax
26-
```
26+
```ebnf
2727
Terms t ::= x variable
2828
(x: T) => t lambda
2929
t t application
3030
’t quote
31-
~t splice
31+
~t splice ;
3232
33-
Simple terms u ::= x | (x: T) => u | u u
33+
Simple terms u ::= x | (x: T) => u | u u ;
3434
3535
Values v ::= (x: T) => t lambda
36-
’u quoted value
36+
’u quoted value ;
3737
3838
Types T ::= A base type
3939
T -> T function type
40-
’T quoted type
40+
’T quoted type ;
4141
```
4242
## Operational semantics
4343

docs/_docs/reference/new-types/dependent-function-types-spec.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ Initial implementation in [PR #3464](https://github.com/lampepfl/dotty/pull/3464
88

99
## Syntax
1010

11-
```
11+
```ebnf
1212
FunArgTypes ::= InfixType
1313
| ‘(’ [ FunArgType {',' FunArgType } ] ‘)’
14-
| ‘(’ TypedFunParam {',' TypedFunParam } ‘)’
15-
TypedFunParam ::= id ‘:’ Type
14+
| ‘(’ TypedFunParam {',' TypedFunParam } ‘)’ ;
15+
TypedFunParam ::= id ‘:’ Type ;
1616
```
1717

1818
Dependent function types associate to the right, e.g.

docs/_docs/reference/new-types/intersection-types-spec.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ with the usual precedence and subject to usual resolving rules.
1212
Unless shadowed by another definition, it resolves to the type `scala.&`,
1313
which acts as a type alias to an internal representation of intersection types.
1414

15-
```
16-
Type ::= ...| InfixType
17-
InfixType ::= RefinedType {id [nl] RefinedType}
15+
```ebnf
16+
Type ::= ...| InfixType ;
17+
InfixType ::= RefinedType {id [nl] RefinedType} ;
1818
```
1919

2020
## Subtyping Rules

0 commit comments

Comments
 (0)