Skip to content
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

[spec] Cosmetic changes in the lexical syntax chapter #18608

Merged
merged 3 commits into from
Sep 28, 2023
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
53 changes: 25 additions & 28 deletions docs/_spec/01-lexical-syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,17 @@ colon ::= ':' -- with side conditions explained above
## Identifiers

```ebnf
op ::= opchar {opchar}
varid ::= lower idrest
boundvarid ::= varid
| ‘`’ varid ‘`’
alphaid ::= upper idrest
| varid
plainid ::= alphaid
| op
id ::= plainid
| ‘`’ { charNoBackQuoteOrNewline | escapeSeq } ‘`’
idrest ::= {letter | digit} [‘_’ op]
op ::= opchar {opchar}
varid ::= lower idrest
boundvarid ::= varid
| ‘`’ varid ‘`’
alphaid ::= upper idrest
| varid
plainid ::= alphaid
| op
id ::= plainid
| ‘`’ { charNoBackQuoteOrNewline | escapeSeq } ‘`’
idrest ::= {letter | digit} [‘_’ op]
escapeSeq ::= UnicodeEscape | charEscapeSeq
UnicodeEscape ::= ‘\’ ‘u’ {‘u’} hexDigit hexDigit hexDigit hexDigit
hexDigit ::= ‘0’ | ... | ‘9’ | ‘A’ | ... | ‘F’ | ‘a’ | ... | ‘f’
Expand Down Expand Up @@ -83,7 +83,7 @@ For this purpose, lower case letters include not only a-z, but also all characte

The following are examples of variable identifiers:

> ```scala
> ```
> x maxIndex p2p empty_?
> `yield` αρετη _y dot_product_*
> __system _MAX_LEN_
Expand All @@ -92,7 +92,7 @@ The following are examples of variable identifiers:

Some examples of constant identifiers are

> ```scala
> ```
> + Object $reserved Džul ǂnûm
> ⅰ_ⅲ Ⅰ_Ⅲ ↁelerious ǃqhàà ʹthatsaletter
> ```
Expand All @@ -104,7 +104,7 @@ User programs should not define identifiers that contain ‘$’ characters.

The following names are reserved words instead of being members of the syntactic class `id` of lexical identifiers.

```scala
```
abstract case catch class def do else
enum export extends false final finally for
given if implicit import lazy match new
Expand Down Expand Up @@ -169,17 +169,16 @@ A newline in a Scala source text is treated as the special token “nl” if the

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

```scala
```
this null true false return type <xml-start>
_ ) ] }
```

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

```scala
catch else extends finally forSome match
with yield , . ; : = => <- <: <%
>: # [ ) ] }
```
catch else extends finally forSome match with yield
, . ; : = => <- <: <% >: # [ ) ] }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
, . ; : = => <- <: <% >: # [ ) ] }
, . ; : = => <- <: <% >: # ) ] }

looks like this can go due to polymorphic lambdas now being added

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, good point. That's a normative change, though, so I'll do that in a separate PR.

```

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

```ebnf
integerLiteral ::= (decimalNumeral | hexNumeral)
[‘L’ | ‘l’]
integerLiteral ::= (decimalNumeral | hexNumeral) [‘L’ | ‘l’]
decimalNumeral ::= ‘0’ | digit [{digit | ‘_’} digit]
hexNumeral ::= ‘0’ (‘x’ | ‘X’) hexDigit [{hexDigit | ‘_’} hexDigit]
```
Expand Down Expand Up @@ -366,11 +364,10 @@ The digits of a numeric literal may be separated by arbitrarily many underscores
### Floating Point Literals

```ebnf
floatingPointLiteral
::= [decimalNumeral] ‘.’ digit [{digit | ‘_’} digit] [exponentPart] [floatType]
| decimalNumeral exponentPart [floatType]
| decimalNumeral floatType
exponentPart ::= (‘E’ | ‘e’) [‘+’ | ‘-’] digit [{digit | ‘_’} digit]
floatingPointLiteral ::= [decimalNumeral] ‘.’ digit [{digit | ‘_’} digit] [exponentPart] [floatType]
| decimalNumeral exponentPart [floatType]
| decimalNumeral floatType
exponentPart ::= (‘E’ | ‘e’) [‘+’ | ‘-’] digit [{digit | ‘_’} digit]
```

Floating point literals are of type `Float` when followed by a floating point type suffix `F` or `f`, and are of type `Double` otherwise.
Expand Down Expand Up @@ -452,7 +449,7 @@ Characters must not necessarily be printable; newlines or other control characte
>
> This would produce the string:
>
> ```scala
> ```
> the present string
> spans three
> lines.
Expand All @@ -469,7 +466,7 @@ Characters must not necessarily be printable; newlines or other control characte
>
> evaluates to
>
> ```scala
> ```
> the present string
> spans three
> lines.
Expand Down
2 changes: 1 addition & 1 deletion docs/_spec/_layouts/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<header class="hidden-print">
<nav id="chapters">
<a href="{{site.baseurl}}/" title="Table of Contents">Scala {{ site.thisScalaVersion }}</a>
<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>
<a id="github" href="https://github.com/lampepfl/dotty/tree/main/docs/_spec"><img src="public/images/[email protected]" alt="Edit at GitHub"></a>
{% assign sorted_pages = site.pages | sort:"name" %}
{% for post in sorted_pages %}
{% if post.chapter >= 0 %}
Expand Down
2 changes: 1 addition & 1 deletion docs/_spec/_layouts/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<div id="header-main">
<img id="scala-logo" src="public/images/scala-spiral-white.png" />
<span id="title">Scala Language Specification</span>
<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>
<a id="github" href="https://github.com/lampepfl/dotty/tree/main/docs/_spec"><img src="public/images/[email protected]" alt="Edit at GitHub"></a>
</div>
<div id="header-sub">Version {{ site.thisScalaVersion }}</div>
</header>
Expand Down