Skip to content

Commit a02febc

Browse files
Backport "[spec] Cosmetic changes in the lexical syntax chapter" to LTS (#20625)
Backports #18608 to the LTS branch. PR submitted by the release tooling. [skip ci]
2 parents d964c22 + 6cda0e8 commit a02febc

File tree

3 files changed

+27
-30
lines changed

3 files changed

+27
-30
lines changed

Diff for: docs/_spec/01-lexical-syntax.md

+25-28
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,17 @@ colon ::= ':' -- with side conditions explained above
4343
## Identifiers
4444

4545
```ebnf
46-
op ::= opchar {opchar}
47-
varid ::= lower idrest
48-
boundvarid ::= varid
49-
| ‘`’ varid ‘`’
50-
alphaid ::= upper idrest
51-
| varid
52-
plainid ::= alphaid
53-
| op
54-
id ::= plainid
55-
| ‘`’ { charNoBackQuoteOrNewline | escapeSeq } ‘`’
56-
idrest ::= {letter | digit} [‘_’ op]
46+
op ::= opchar {opchar}
47+
varid ::= lower idrest
48+
boundvarid ::= varid
49+
| ‘`’ varid ‘`’
50+
alphaid ::= upper idrest
51+
| varid
52+
plainid ::= alphaid
53+
| op
54+
id ::= plainid
55+
| ‘`’ { charNoBackQuoteOrNewline | escapeSeq } ‘`’
56+
idrest ::= {letter | digit} [‘_’ op]
5757
escapeSeq ::= UnicodeEscape | charEscapeSeq
5858
UnicodeEscape ::= ‘\’ ‘u’ {‘u’} hexDigit hexDigit hexDigit hexDigit
5959
hexDigit ::= ‘0’ | ... | ‘9’ | ‘A’ | ... | ‘F’ | ‘a’ | ... | ‘f’
@@ -83,7 +83,7 @@ For this purpose, lower case letters include not only a-z, but also all characte
8383

8484
The following are examples of variable identifiers:
8585

86-
> ```scala
86+
> ```
8787
> x maxIndex p2p empty_?
8888
> `yield` αρετη _y dot_product_*
8989
> __system _MAX_LEN_
@@ -92,7 +92,7 @@ The following are examples of variable identifiers:
9292
9393
Some examples of constant identifiers are
9494
95-
> ```scala
95+
> ```
9696
> + Object $reserved Džul ǂnûm
9797
> ⅰ_ⅲ Ⅰ_Ⅲ ↁelerious ǃqhàà ʹthatsaletter
9898
> ```
@@ -104,7 +104,7 @@ User programs should not define identifiers that contain ‘$’ characters.
104104
105105
The following names are reserved words instead of being members of the syntactic class `id` of lexical identifiers.
106106
107-
```scala
107+
```
108108
abstract case catch class def do else
109109
enum export extends false final finally for
110110
given if implicit import lazy match new
@@ -169,17 +169,16 @@ A newline in a Scala source text is treated as the special token “nl” if the
169169

170170
The tokens that can terminate a statement are: literals, identifiers and the following delimiters and reserved words:
171171

172-
```scala
172+
```
173173
this null true false return type <xml-start>
174174
_ ) ] }
175175
```
176176

177177
The tokens that can begin a statement are all Scala tokens _except_ the following delimiters and reserved words:
178178

179-
```scala
180-
catch else extends finally forSome match
181-
with yield , . ; : = => <- <: <%
182-
>: # [ ) ] }
179+
```
180+
catch else extends finally forSome match with yield
181+
, . ; : = => <- <: <% >: # [ ) ] }
183182
```
184183

185184
A `case` token can begin a statement only if followed by a
@@ -334,8 +333,7 @@ Literal ::= [‘-’] integerLiteral
334333
### Integer Literals
335334

336335
```ebnf
337-
integerLiteral ::= (decimalNumeral | hexNumeral)
338-
[‘L’ | ‘l’]
336+
integerLiteral ::= (decimalNumeral | hexNumeral) [‘L’ | ‘l’]
339337
decimalNumeral ::= ‘0’ | digit [{digit | ‘_’} digit]
340338
hexNumeral ::= ‘0’ (‘x’ | ‘X’) hexDigit [{hexDigit | ‘_’} hexDigit]
341339
```
@@ -366,11 +364,10 @@ The digits of a numeric literal may be separated by arbitrarily many underscores
366364
### Floating Point Literals
367365
368366
```ebnf
369-
floatingPointLiteral
370-
::= [decimalNumeral] ‘.’ digit [{digit | ‘_’} digit] [exponentPart] [floatType]
371-
| decimalNumeral exponentPart [floatType]
372-
| decimalNumeral floatType
373-
exponentPart ::= (‘E| ‘e’) [‘+|-’] digit [{digit | ‘_’} digit]
367+
floatingPointLiteral ::= [decimalNumeral] ‘.’ digit [{digit | ‘_’} digit] [exponentPart] [floatType]
368+
| decimalNumeral exponentPart [floatType]
369+
| decimalNumeral floatType
370+
exponentPart ::= (‘E| ‘e’) [‘+|-’] digit [{digit | ‘_’} digit]
374371
```
375372
376373
Floating point literals are of type `Float` when followed by a floating point type suffix `F` or `f`, and are of type `Double` otherwise.
@@ -452,7 +449,7 @@ Characters must not necessarily be printable; newlines or other control characte
452449
>
453450
> This would produce the string:
454451
>
455-
> ```scala
452+
> ```
456453
> the present string
457454
> spans three
458455
> lines.
@@ -469,7 +466,7 @@ Characters must not necessarily be printable; newlines or other control characte
469466
>
470467
> evaluates to
471468
>
472-
> ```scala
469+
> ```
473470
> the present string
474471
> spans three
475472
> lines.

Diff for: docs/_spec/_layouts/default.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
<header class="hidden-print">
2828
<nav id="chapters">
2929
<a href="{{site.baseurl}}/" title="Table of Contents">Scala {{ site.thisScalaVersion }}</a>
30-
<a id="github" href="https://github.com/scala/scala/tree/2.13.x/spec"><img src="public/images/[email protected]" alt="Edit at GitHub"></a>
30+
<a id="github" href="https://github.com/lampepfl/dotty/tree/main/docs/_spec"><img src="public/images/[email protected]" alt="Edit at GitHub"></a>
3131
{% assign sorted_pages = site.pages | sort:"name" %}
3232
{% for post in sorted_pages %}
3333
{% if post.chapter >= 0 %}

Diff for: docs/_spec/_layouts/toc.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<div id="header-main">
2121
<img id="scala-logo" src="public/images/scala-spiral-white.png" />
2222
<span id="title">Scala Language Specification</span>
23-
<a id="github" href="https://github.com/scala/scala/tree/{{ site.thisScalaVersion }}.x/spec"><img src="public/images/[email protected]" alt="Edit at GitHub"></a>
23+
<a id="github" href="https://github.com/lampepfl/dotty/tree/main/docs/_spec"><img src="public/images/[email protected]" alt="Edit at GitHub"></a>
2424
</div>
2525
<div id="header-sub">Version {{ site.thisScalaVersion }}</div>
2626
</header>

0 commit comments

Comments
 (0)