Skip to content

Revert "Highlight all EBNF snippets. Add missing semicolons." #14958

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions docs/_docs/reference/changed-features/imports.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ are offered under settings `-source 3.1-migration -rewrite`.

### Syntax

```ebnf
Import ::= ‘import’ ImportExpr {‘,’ ImportExpr} ;
ImportExpr ::= SimpleRef {‘.’ id} ‘.’ ImportSpec ;
```
Import ::= ‘import’ ImportExpr {‘,’ ImportExpr}
ImportExpr ::= SimpleRef {‘.’ id} ‘.’ ImportSpec
ImportSpec ::= NamedSelector
| WildcardSelector
| ‘{’ ImportSelectors) ‘}’ ;
NamedSelector ::= id [‘as’ (id | ‘_’)] ;
WildCardSelector ::= ‘*' | ‘given’ [InfixType] ;
| ‘{’ ImportSelectors) ‘}’
NamedSelector ::= id [‘as’ (id | ‘_’)]
WildCardSelector ::= ‘*' | ‘given’ [InfixType]
ImportSelectors ::= NamedSelector [‘,’ ImportSelectors]
| WildCardSelector {‘,’ WildCardSelector} ;
| WildCardSelector {‘,’ WildCardSelector}
```
8 changes: 4 additions & 4 deletions docs/_docs/reference/changed-features/match-syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ The syntactical precedence of match expressions has been changed.

The new syntax of match expressions is as follows.

```ebnf
```
InfixExpr ::= ...
| InfixExpr MatchClause ;
| InfixExpr MatchClause
SimpleExpr ::= ...
| SimpleExpr ‘.’ MatchClause ;
MatchClause ::= ‘match’ ‘{’ CaseClauses ‘}’ ;
| SimpleExpr ‘.’ MatchClause
MatchClause ::= ‘match’ ‘{’ CaseClauses ‘}’
```
4 changes: 2 additions & 2 deletions docs/_docs/reference/changed-features/pattern-bindings.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ for case (x, y) <- elems yield (y, x) // returns List((2, 1), (4, 3))
## Syntax Changes

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

## Migration
Expand Down
10 changes: 5 additions & 5 deletions docs/_docs/reference/changed-features/structural-types-spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ movedTo: https://docs.scala-lang.org/scala3/reference/changed-features/structura

## Syntax

```ebnf
SimpleType ::= ... | Refinement ;
Refinement ::= ‘{’ RefineStatSeq ‘}’ ;
RefineStatSeq ::= RefineStat {semi RefineStat} ;
RefineStat ::= ‘val’ VarDcl | ‘def’ DefDcl | ‘type’ {nl} TypeDcl ;
```
SimpleType ::= ... | Refinement
Refinement ::= ‘{’ RefineStatSeq ‘}’
RefineStatSeq ::= RefineStat {semi RefineStat}
RefineStat ::= ‘val’ VarDcl | ‘def’ DefDcl | ‘type’ {nl} TypeDcl
```

## Implementation of Structural Types
Expand Down
6 changes: 3 additions & 3 deletions docs/_docs/reference/changed-features/vararg-splices.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ The old syntax for splice arguments will be phased out.

## Syntax

```ebnf
```
ArgumentPatterns ::= ‘(’ [Patterns] ‘)’
| ‘(’ [Patterns ‘,’] Pattern2 ‘*’ ‘)’ ;
| ‘(’ [Patterns ‘,’] Pattern2 ‘*’ ‘)’

ParArgumentExprs ::= ‘(’ [‘using’] ExprsInParens ‘)’
| ‘(’ [ExprsInParens ‘,’] PostfixExpr ‘*’ ‘)’ ;
| ‘(’ [ExprsInParens ‘,’] PostfixExpr ‘*’ ‘)’
```

## Compatibility considerations
Expand Down
6 changes: 3 additions & 3 deletions docs/_docs/reference/contextual/context-bounds.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ done automatically under `-rewrite`.

## Syntax

```ebnf
TypeParamBounds ::= [SubtypeBounds] {ContextBound} ;
ContextBound ::= ‘:’ Type ;
```
TypeParamBounds ::= [SubtypeBounds] {ContextBound}
ContextBound ::= ‘:’ Type
```
6 changes: 3 additions & 3 deletions docs/_docs/reference/contextual/context-functions-spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ movedTo: https://docs.scala-lang.org/scala3/reference/contextual/context-functio

## Syntax

```ebnf
```
Type ::= ...
| FunArgTypes ‘?=>’ Type ;
| FunArgTypes ‘?=>’ Type
Expr ::= ...
| FunParams ‘?=>’ Expr ;
| FunParams ‘?=>’ Expr
```

Context function types associate to the right, e.g.
Expand Down
10 changes: 5 additions & 5 deletions docs/_docs/reference/contextual/derivation.md
Original file line number Diff line number Diff line change
Expand Up @@ -354,12 +354,12 @@ hand side of this definition in the same way as an instance defined in ADT compa

### Syntax

```ebnf
Template ::= InheritClauses [TemplateBody] ;
EnumDef ::= id ClassConstr InheritClauses EnumBody ;
InheritClauses ::= [‘extends’ ConstrApps] [‘derives’ QualId {‘,’ QualId}] ;
```
Template ::= InheritClauses [TemplateBody]
EnumDef ::= id ClassConstr InheritClauses EnumBody
InheritClauses ::= [‘extends’ ConstrApps] [‘derives’ QualId {‘,’ QualId}]
ConstrApps ::= ConstrApp {‘with’ ConstrApp}
| ConstrApp {‘,’ ConstrApp} ;
| ConstrApp {‘,’ ConstrApp}
```

**Note:** To align `extends` clauses and `derives` clauses, Scala 3 also allows multiple
Expand Down
18 changes: 9 additions & 9 deletions docs/_docs/reference/contextual/extension-methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -285,20 +285,20 @@ def position(s: String)(ch: Char, n: Int): Int =
Here are the syntax changes for extension methods and collective extensions relative
to the [current syntax](../syntax.md).

```ebnf
BlockStat ::= ... | Extension ;
TemplateStat ::= ... | Extension ;
TopStat ::= ... | Extension ;
```
BlockStat ::= ... | Extension
TemplateStat ::= ... | Extension
TopStat ::= ... | Extension
Extension ::= ‘extension’ [DefTypeParamClause] {UsingParamClause}
‘(’ DefParam ‘)’ {UsingParamClause} ExtMethods ;
ExtMethods ::= ExtMethod | [nl] <<< ExtMethod {semi ExtMethod} >>> ;
ExtMethod ::= {Annotation [nl]} {Modifier} ‘def’ DefDef ;
‘(’ DefParam ‘)’ {UsingParamClause} ExtMethods
ExtMethods ::= ExtMethod | [nl] <<< ExtMethod {semi ExtMethod} >>>
ExtMethod ::= {Annotation [nl]} {Modifier} ‘def’ DefDef
```

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

```ebnf
<<< ts >>> ::= ‘{’ ts ‘}’ | indent ts outdent ;
```
<<< ts >>> ::= ‘{’ ts ‘}’ | indent ts outdent
```

`extension` is a soft keyword. It is recognized as a keyword only if it appears
Expand Down
16 changes: 8 additions & 8 deletions docs/_docs/reference/contextual/given-imports.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,15 @@ given instances once their user base has migrated.

### Syntax

```ebnf
Import ::= ‘import’ ImportExpr {‘,’ ImportExpr} ;
Export ::= ‘export’ ImportExpr {‘,’ ImportExpr} ;
ImportExpr ::= SimpleRef {‘.’ id} ‘.’ ImportSpec ;
```
Import ::= ‘import’ ImportExpr {‘,’ ImportExpr}
Export ::= ‘export’ ImportExpr {‘,’ ImportExpr}
ImportExpr ::= SimpleRef {‘.’ id} ‘.’ ImportSpec
ImportSpec ::= NamedSelector
| WildcardSelector
| ‘{’ ImportSelectors) ‘}’ ;
NamedSelector ::= id [‘as’ (id | ‘_’)] ;
WildCardSelector ::= ‘*' | ‘given’ [InfixType] ;
| ‘{’ ImportSelectors) ‘}’
NamedSelector ::= id [‘as’ (id | ‘_’)]
WildCardSelector ::= ‘*' | ‘given’ [InfixType]
ImportSelectors ::= NamedSelector [‘,’ ImportSelectors]
| WildCardSelector {‘,’ WildCardSelector} ;
| WildCardSelector {‘,’ WildCardSelector}
```
10 changes: 5 additions & 5 deletions docs/_docs/reference/contextual/givens.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,14 +173,14 @@ is created for each reference.

Here is the syntax for given instances:

```ebnf
```
TmplDef ::= ...
| ‘given’ GivenDef ;
| ‘given’ GivenDef
GivenDef ::= [GivenSig] StructuralInstance
| [GivenSig] AnnotType ‘=’ Expr
| [GivenSig] AnnotType ;
GivenSig ::= [id] [DefTypeParamClause] {UsingParamClause} ‘:’ ;
StructuralInstance ::= ConstrApp {‘with’ ConstrApp} ‘with’ TemplateBody ;
| [GivenSig] AnnotType
GivenSig ::= [id] [DefTypeParamClause] {UsingParamClause} ‘:’
StructuralInstance ::= ConstrApp {‘with’ ConstrApp} ‘with’ TemplateBody
```

A given instance starts with the reserved word `given` and an optional _signature_. The signature
Expand Down
12 changes: 6 additions & 6 deletions docs/_docs/reference/contextual/using-clauses.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,10 @@ def summon[T](using x: T): x.type = x

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.

```ebnf
ClsParamClause ::= ... | UsingClsParamClause ;
DefParamClauses ::= ... | UsingParamClause ;
UsingClsParamClause ::= ‘(’ ‘using’ (ClsParams | Types) ‘)’ ;
UsingParamClause ::= ‘(’ ‘using’ (DefParams | Types) ‘)’ ;
ParArgumentExprs ::= ... | ‘(’ ‘using’ ExprsInParens ‘)’ ;
```
ClsParamClause ::= ... | UsingClsParamClause
DefParamClauses ::= ... | UsingParamClause
UsingClsParamClause ::= ‘(’ ‘using’ (ClsParams | Types) ‘)’
UsingParamClause ::= ‘(’ ‘using’ (DefParams | Types) ‘)’
ParArgumentExprs ::= ... | ‘(’ ‘using’ ExprsInParens ‘)’
```
14 changes: 7 additions & 7 deletions docs/_docs/reference/enums/adts.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,18 +154,18 @@ The changes are specified below as deltas with respect to the Scala syntax given

1. Enum definitions are defined as follows:

```ebnf
TmplDef ::= `enum' EnumDef ;
EnumDef ::= id ClassConstr [`extends' [ConstrApps]] EnumBody ;
EnumBody ::= [nl] ‘{’ [SelfType] EnumStat {semi EnumStat} ‘}’ ;
```
TmplDef ::= `enum' EnumDef
EnumDef ::= id ClassConstr [`extends' [ConstrApps]] EnumBody
EnumBody ::= [nl] ‘{’ [SelfType] EnumStat {semi EnumStat} ‘}’
EnumStat ::= TemplateStat
| {Annotation [nl]} {Modifier} EnumCase ;
| {Annotation [nl]} {Modifier} EnumCase
```

2. Cases of enums are defined as follows:

```ebnf
EnumCase ::= `case' (id ClassConstr [`extends' ConstrApps]] | ids) ;
```
EnumCase ::= `case' (id ClassConstr [`extends' ConstrApps]] | ids)
```

### Reference
Expand Down
8 changes: 4 additions & 4 deletions docs/_docs/reference/experimental/named-typeargs-spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ In this section we give more details about the [named type arguments](named-type

The addition to the grammar is:

```ebnf
```
SimpleExpr1 ::= ...
| SimpleExpr (TypeArgs | NamedTypeArgs) ;
NamedTypeArgs ::= ‘[’ NamedTypeArg {‘,’ NamedTypeArg} ‘]’ ;
NamedTypeArg ::= id ‘=’ Type ;
| SimpleExpr (TypeArgs | NamedTypeArgs)
NamedTypeArgs ::= ‘[’ NamedTypeArg {‘,’ NamedTypeArg} ‘]’
NamedTypeArg ::= id ‘=’ Type
```

Note in particular that named arguments cannot be passed to type constructors:
Expand Down
30 changes: 15 additions & 15 deletions docs/_docs/reference/metaprogramming/macros-spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ movedTo: https://docs.scala-lang.org/scala3/reference/metaprogramming/macros-spe

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

The syntax of terms, values, and types is given as follows:
```ebnf
```
Terms t ::= x variable
(x: T) => t lambda
t t application
't quote
$t splice ;
$t splice

Values v ::= (x: T) => t lambda
'u quote ;
'u quote

Simple terms u ::= x | (x: T) => u | u u | 't ;
Simple terms u ::= x | (x: T) => u | u u | 't

Types T ::= A base type
T -> T function type
expr T quoted ;
expr T quoted
```
Typing rules are formulated using a stack of environments
`Es`. Individual environments `E` consist as usual of variable
bindings `x: T`. Environments can be combined using the two
combinators `'` and `$`.
```ebnf
```
Environment E ::= () empty
E, x: T ;
E, x: T

Env. stack Es ::= () empty
E simple
Es * Es combined ;
Es * Es combined

Separator * ::= '
$ ;
$
```
The two environment combinators are both associative with left and
right identity `()`.
Expand All @@ -108,9 +108,9 @@ rule says that splice and quotes cancel each other out. The third rule
is a context rule; it says that reduction is allowed in the hole `[ ]`
position of an evaluation context. Evaluation contexts `e` and
splice evaluation context `e_s` are defined syntactically as follows:
```ebnf
Eval context e ::= [ ] | e t | v e | 'e_s[${e}] ;
Splice context e_s ::= [ ] | (x: T) => e_s | e_s t | u e_s ;
```
Eval context e ::= [ ] | e t | v e | 'e_s[${e}]
Splice context e_s ::= [ ] | (x: T) => e_s | e_s t | u e_s
```

### Typing rules
Expand Down
10 changes: 5 additions & 5 deletions docs/_docs/reference/metaprogramming/simple-smp.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,21 @@ replace evaluation contexts with contextual typing rules. While this
is more verbose, it makes it easier to set up the meta theory.

## Syntax
```ebnf
```
Terms t ::= x variable
(x: T) => t lambda
t t application
’t quote
~t splice ;
~t splice

Simple terms u ::= x | (x: T) => u | u u ;
Simple terms u ::= x | (x: T) => u | u u

Values v ::= (x: T) => t lambda
’u quoted value ;
’u quoted value

Types T ::= A base type
T -> T function type
’T quoted type ;
’T quoted type
```
## Operational semantics

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ Initial implementation in [PR #3464](https://github.com/lampepfl/dotty/pull/3464

## Syntax

```ebnf
```
FunArgTypes ::= InfixType
| ‘(’ [ FunArgType {',' FunArgType } ] ‘)’
| ‘(’ TypedFunParam {',' TypedFunParam } ‘)’ ;
TypedFunParam ::= id ‘:’ Type ;
| ‘(’ TypedFunParam {',' TypedFunParam } ‘)’
TypedFunParam ::= id ‘:’ Type
```

Dependent function types associate to the right, e.g.
Expand Down
6 changes: 3 additions & 3 deletions docs/_docs/reference/new-types/intersection-types-spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ with the usual precedence and subject to usual resolving rules.
Unless shadowed by another definition, it resolves to the type `scala.&`,
which acts as a type alias to an internal representation of intersection types.

```ebnf
Type ::= ...| InfixType ;
InfixType ::= RefinedType {id [nl] RefinedType} ;
```
Type ::= ...| InfixType
InfixType ::= RefinedType {id [nl] RefinedType}
```

## Subtyping Rules
Expand Down
Loading